-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from dhis2/ANDROAPP-5512
ANDROAPP-5512-mobile-ui-Create-section-component
- Loading branch information
Showing
17 changed files
with
837 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
common/src/commonMain/kotlin/org/hisp/dhis/common/screens/SectionScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package org.hisp.dhis.common.screens | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import org.hisp.dhis.common.screens.previews.lorem | ||
import org.hisp.dhis.common.screens.previews.lorem_medium | ||
import org.hisp.dhis.common.screens.previews.lorem_short | ||
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer | ||
import org.hisp.dhis.mobile.ui.designsystem.component.InputText | ||
import org.hisp.dhis.mobile.ui.designsystem.component.Section | ||
import org.hisp.dhis.mobile.ui.designsystem.component.SectionState | ||
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle | ||
|
||
@Composable | ||
fun SectionScreen() { | ||
ColumnComponentContainer(title = "Section Header") { | ||
SubTitle("Collapsible header") | ||
|
||
Column { | ||
Section( | ||
title = "Section title", | ||
description = null, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.CLOSE, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.CLOSE, | ||
errorCount = 2, | ||
warningCount = 1, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem_short, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.CLOSE, | ||
errorCount = 2, | ||
warningCount = 1, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem_medium, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.CLOSE, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title Section title Section title Section title Section title", | ||
description = null, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.CLOSE, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
} | ||
|
||
SubTitle("Flat header") | ||
Section( | ||
title = "Section title", | ||
description = null, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.FIXED, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.FIXED, | ||
errorCount = 2, | ||
warningCount = 1, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem_short, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.FIXED, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title", | ||
description = lorem_medium, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.FIXED, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
Section( | ||
title = "Section title Section title Section title Section title Section title", | ||
description = lorem_medium, | ||
completedFields = 2, | ||
totalFields = 3, | ||
state = SectionState.FIXED, | ||
errorCount = 0, | ||
warningCount = 0, | ||
content = { TestingFields() }, | ||
onNextSection = { }, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun TestingFields() { | ||
var inputValue1: String by rememberSaveable { mutableStateOf("Input") } | ||
var inputValue2: String by rememberSaveable { mutableStateOf("") } | ||
var inputValue3: String by rememberSaveable { mutableStateOf("") } | ||
InputText( | ||
title = "Label", | ||
inputText = inputValue1, | ||
onValueChanged = { inputValue1 = it ?: "" }, | ||
) | ||
InputText( | ||
title = "Label", | ||
inputText = inputValue2, | ||
onValueChanged = { inputValue2 = it ?: "" }, | ||
) | ||
InputText( | ||
title = "Label", | ||
inputText = inputValue3, | ||
onValueChanged = { inputValue3 = it ?: "" }, | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
common/src/commonMain/kotlin/org/hisp/dhis/common/screens/TagsScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.hisp.dhis.common.screens | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.hisp.dhis.common.screens.previews.TagsPreview | ||
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer | ||
|
||
@Composable | ||
fun TagsScreen() { | ||
ColumnComponentContainer(title = "Tags") { | ||
TagsPreview() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/LoremIpsum.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.hisp.dhis.common.screens.previews | ||
|
||
const val lorem = | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dolor lacus, aliquam. Lorem ipsum dolor sit amet, consectetur adipiscing elit." | ||
const val lorem_short = | ||
"Lorem ipsum dolor sit amet" | ||
const val lorem_medium = | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit." |
17 changes: 17 additions & 0 deletions
17
common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/TagsPreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.hisp.dhis.common.screens.previews | ||
|
||
import androidx.compose.foundation.layout.Arrangement.spacedBy | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.unit.dp | ||
import org.hisp.dhis.mobile.ui.designsystem.component.Tag | ||
import org.hisp.dhis.mobile.ui.designsystem.component.TagType | ||
|
||
@Composable | ||
fun TagsPreview() { | ||
Column(verticalArrangement = spacedBy(20.dp)) { | ||
TagType.values().forEach { | ||
Tag(label = "label", type = it) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.