Skip to content

Commit

Permalink
Merge branch 'main' into ANDROAPP-5575-mobile-ui-Create-InputFileReso…
Browse files Browse the repository at this point in the history
…urce-component
  • Loading branch information
DavidAparicioAlbaAsenjo authored Oct 10, 2023
2 parents f29c39b + e7ad9c1 commit 88262e2
Show file tree
Hide file tree
Showing 85 changed files with 1,363 additions and 62 deletions.
5 changes: 4 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ kotlin {
implementation(compose.foundation)
implementation(compose.ui)
implementation(compose.material3)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(project(":designsystem"))
}
}
Expand Down Expand Up @@ -49,7 +51,8 @@ android {
namespace = "org.hisp.dhis.mobile.ui.common"

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].res.srcDirs("src/androidMain/res", "src/commonMain/resources")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")

defaultConfig {
minSdk = (findProperty("android.minSdk") as String).toInt()
Expand Down
4 changes: 4 additions & 0 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.hisp.dhis.common.screens.Components
import org.hisp.dhis.common.screens.FormShellsScreen
import org.hisp.dhis.common.screens.FormsComponentsScreen
import org.hisp.dhis.common.screens.IconButtonScreen
import org.hisp.dhis.common.screens.ImageBlockScreen
import org.hisp.dhis.common.screens.InputAgeScreen
import org.hisp.dhis.common.screens.InputCheckBoxScreen
import org.hisp.dhis.common.screens.InputEmailScreen
Expand All @@ -45,6 +46,7 @@ import org.hisp.dhis.common.screens.InputLongTextScreen
import org.hisp.dhis.common.screens.InputMatrixScreen
import org.hisp.dhis.common.screens.InputNegativeIntegerScreen
import org.hisp.dhis.common.screens.InputNumberScreen
import org.hisp.dhis.common.screens.InputOrgUnitScreen
import org.hisp.dhis.common.screens.InputPercentageScreen
import org.hisp.dhis.common.screens.InputPhoneNumberScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerOrZeroScreen
Expand Down Expand Up @@ -171,6 +173,8 @@ fun Main() {
Components.INPUT_EMAIL -> InputEmailScreen()
Components.CAROUSEL_BUTTONS -> ButtonCarouselScreen()
Components.INPUT_FILE_RESOURCE -> InputFileResourceScreen()
Components.INPUT_ORG_UNIT -> InputOrgUnitScreen()
Components.IMAGE_BLOCK -> ImageBlockScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ enum class Components(val label: String) {
INPUT_EMAIL("Input Email"),
CAROUSEL_BUTTONS("Carousel buttons"),
INPUT_FILE_RESOURCE("Input File Resource"),
INPUT_ORG_UNIT("Input Org. Unit"),
IMAGE_BLOCK("Image Block"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun FormShellsScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -52,7 +53,7 @@ fun FormShellsScreen() {
inputValue2 = it
}
},

state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -124,6 +125,7 @@ fun FormShellsScreen() {
inputValue7 = it
}
},
state = InputShellState.ERROR,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -159,6 +161,7 @@ fun FormShellsScreen() {
inputValue9 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -178,6 +181,8 @@ fun FormShellsScreen() {
inputValue10 = it
}
},
state = InputShellState.UNFOCUSED,

)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down Expand Up @@ -263,6 +268,7 @@ fun FormShellsScreen() {
inputValue14 = it
}
},
state = InputShellState.UNFOCUSED,
)

var inputValue15 by rememberSaveable { mutableStateOf("Input") }
Expand All @@ -275,6 +281,7 @@ fun FormShellsScreen() {
inputValue15 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -296,6 +303,7 @@ fun FormShellsScreen() {
inputValue16 = it
}
},
state = InputShellState.UNFOCUSED,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.hisp.dhis.common.screens

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.painter.Painter
import org.hisp.dhis.mobile.ui.designsystem.component.ImageBlock
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@Composable
fun ImageBlockScreen() {
val sampleImage = provideSampleImage()
ImageBlock(
load = { sampleImage },
painterFor = { remember { it } },
onClick = {},
)
}

@OptIn(ExperimentalResourceApi::class)
@Composable
private fun provideSampleImage(): Painter =
painterResource("drawable/sample.png")
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.Orientation
import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonData
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
Expand All @@ -14,13 +17,94 @@ import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues

@Composable
fun InputAgeScreen() {
ColumnComponentContainer("Age Field components") {
ColumnComponentContainer {
SubTitle("Horizontal Age Field Helper")
var selectedFieldHorizontal by remember {
mutableStateOf(RadioButtonData("0", selected = true, enabled = true, textInput = TimeUnitValues.YEARS.value))
}
TimeUnitSelector(Orientation.HORIZONTAL, TimeUnitValues.YEARS.value) {
selectedFieldHorizontal = it
}

SubTitle("Input Age Component - Idle")
var inputType by remember { mutableStateOf<AgeInputType>(AgeInputType.None) }

InputAge(
title = "Label",
inputType = inputType,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Idle Disabled")
InputAge(
title = "Label",
inputType = AgeInputType.None,
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Date Of Birth")
InputAge(
title = "Label",
inputType = AgeInputType.DateOfBirth("01011985"),
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Date Of Birth Required Error")
InputAge(
title = "Label",
inputType = AgeInputType.DateOfBirth("010"),
state = InputShellState.ERROR,
isRequired = true,
onCalendarActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)

SubTitle("Input Age Component - Age Disabled")
InputAge(
title = "Label",
inputType = AgeInputType.Age(value = "56", unit = TimeUnitValues.YEARS),
state = InputShellState.DISABLED,
onCalendarActionClicked = {
// no-op
},
onValueChanged = { newInputType ->
inputType = newInputType
},
)

SubTitle("Input Age Component - Age Required Error")
InputAge(
title = "Label",
inputType = AgeInputType.Age(value = "56", unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,
onCalendarActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fun InputCheckBoxScreen() {
checkBoxDataItemsVertical[index] = checkBoxData.copy(checked = !checkBoxData.checked)
},
onClearSelection = { checkBoxDataItemsVertical.replaceAll { it.copy(checked = false) } },
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))
InputCheckBox(
Expand Down Expand Up @@ -99,6 +100,7 @@ fun InputCheckBoxScreen() {
checkBoxDataItemsHorizontal[index] = checkBoxData.copy(checked = !checkBoxData.checked)
},
onClearSelection = { checkBoxDataItemsHorizontal.replaceAll { it.copy(checked = false) } },
state = InputShellState.UNFOCUSED,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun InputEmailScreen() {
}
},
onEmailActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -51,6 +52,7 @@ fun InputEmailScreen() {
}
},
onEmailActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputIntegerScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputLetterScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -51,6 +52,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -67,6 +69,7 @@ fun InputLinkScreen() {
}
},
onLinkActionCLicked = {},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun InputLongTextScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun InputMatrixScreen() {
newSelectedItem
}
},
state = InputShellState.UNFOCUSED,
)

InputMatrix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputNegativeIntegerScreen() {
inputValue1 = it
}
},
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fun InputNumberScreen() {
}
},
notation = RegExValidations.BRITISH_DECIMAL_NOTATION,
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -49,6 +50,7 @@ fun InputNumberScreen() {
}
},
notation = RegExValidations.EUROPEAN_DECIMAL_NOTATION,
state = InputShellState.UNFOCUSED,
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand Down
Loading

0 comments on commit 88262e2

Please sign in to comment.