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 17, 2023
2 parents 1d4ac5e + f6234b8 commit 61f2927
Show file tree
Hide file tree
Showing 42 changed files with 1,866 additions and 195 deletions.
8 changes: 8 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 @@ -36,7 +36,10 @@ 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.InputBarCodeScreen
import org.hisp.dhis.common.screens.InputCheckBoxScreen
import org.hisp.dhis.common.screens.InputDateTimeScreen
import org.hisp.dhis.common.screens.InputDropDownScreen
import org.hisp.dhis.common.screens.InputEmailScreen
import org.hisp.dhis.common.screens.InputFileResourceScreen
import org.hisp.dhis.common.screens.InputIntegerScreen
Expand All @@ -49,6 +52,7 @@ 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.InputPolygonScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerOrZeroScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerScreen
import org.hisp.dhis.common.screens.InputQRCodeScreen
Expand Down Expand Up @@ -171,10 +175,14 @@ fun Main() {
Components.INPUT_PHONE_NUMBER -> InputPhoneNumberScreen()
Components.INPUT_LINK -> InputLinkScreen()
Components.INPUT_EMAIL -> InputEmailScreen()
Components.INPUT_BARCODE -> InputBarCodeScreen()
Components.CAROUSEL_BUTTONS -> ButtonCarouselScreen()
Components.INPUT_POLYGON -> InputPolygonScreen()
Components.INPUT_ORG_UNIT -> InputOrgUnitScreen()
Components.IMAGE_BLOCK -> ImageBlockScreen()
Components.INPUT_FILE_RESOURCE -> InputFileResourceScreen()
Components.INPUT_DROPDOWN -> InputDropDownScreen()
Components.INPUT_DATE_TIME -> InputDateTimeScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ enum class Components(val label: String) {
INPUT_PHONE_NUMBER("Input Phone Number"),
INPUT_LINK("Input Link"),
INPUT_EMAIL("Input Email"),
INPUT_BARCODE("Input Barcode"),
CAROUSEL_BUTTONS("Carousel buttons"),
INPUT_POLYGON("Input Polygon"),
INPUT_ORG_UNIT("Input Org. Unit"),
IMAGE_BLOCK("Image Block"),
INPUT_FILE_RESOURCE("Input File Resource"),
INPUT_DROPDOWN("Input Dropdown"),
INPUT_DATE_TIME("Input Date Time"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import org.hisp.dhis.common.screens.previews.regularLegendList
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.LegendData
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
import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitSelector
import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor

@Composable
fun InputAgeScreen() {
Expand Down Expand Up @@ -106,5 +109,20 @@ fun InputAgeScreen() {
// no-op
},
)

SubTitle("Input Age Component - Legend")
InputAge(
title = "Label",
inputType = AgeInputType.Age(value = "56", unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,
onCalendarActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
legendData = LegendData(SurfaceColor.CustomGreen, "Legend", popUpLegendDescriptionData = regularLegendList),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package org.hisp.dhis.common.screens

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Icon
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 androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import org.hisp.dhis.common.screens.previews.threeButtonCarousel
import org.hisp.dhis.mobile.ui.designsystem.component.BarcodeBlock
import org.hisp.dhis.mobile.ui.designsystem.component.BottomSheetShell
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonCarousel
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.Description
import org.hisp.dhis.mobile.ui.designsystem.component.InputBarCode
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextData
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextState
import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
fun InputBarCodeScreen() {
ColumnComponentContainer {
var inputValue1 by rememberSaveable { mutableStateOf("889026a1-d01e-4d34-8209-81e8ed5c614b") }
var showEnabledBarCodeBottomSheet by rememberSaveable { mutableStateOf(false) }

Description("Default Input Barcode", textColor = TextColor.OnSurfaceVariant)
InputBarCode(
"label",
state = InputShellState.UNFOCUSED,
onActionButtonClicked = {
showEnabledBarCodeBottomSheet = !showEnabledBarCodeBottomSheet
},
inputText = inputValue1,
onValueChanged = {
if (it != null) {
inputValue1 = it
}
},
)

if (showEnabledBarCodeBottomSheet) {
BottomSheetShell(
modifier = Modifier.testTag("LEGEND_BOTTOM_SHEET"),
title = provideStringResource("qr_code"),
icon = {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = "Button",
tint = SurfaceColor.Primary,
)
},
content = {
Row(horizontalArrangement = Arrangement.Center) {
BarcodeBlock(data = inputValue1)
}
},
buttonBlock = {
ButtonCarousel(
carouselButtonList = threeButtonCarousel,
)
},
) {
showEnabledBarCodeBottomSheet = false
}
}
Spacer(Modifier.size(Spacing.Spacing18))

var inputValue2 by rememberSaveable { mutableStateOf("") }
Description("Required field Input Barcode", textColor = TextColor.OnSurfaceVariant)
InputBarCode(
"label",
state = InputShellState.ERROR,
onActionButtonClicked = {
},
inputText = inputValue2,
onValueChanged = {
if (it != null) {
inputValue2 = it
}
},
isRequiredField = true,
supportingText = listOf(SupportingTextData("Required", SupportingTextState.ERROR)),
)

Spacer(Modifier.size(Spacing.Spacing18))
var inputValue by rememberSaveable { mutableStateOf("") }
Description("Disabled Input Barcode", textColor = TextColor.OnSurfaceVariant)
InputBarCode(
"label",
state = InputShellState.DISABLED,
onActionButtonClicked = {
},
inputText = inputValue,
onValueChanged = {
if (it != null) {
inputValue = it
}
},
)

Spacer(Modifier.size(Spacing.Spacing18))
var inputValue3 by rememberSaveable { mutableStateOf("889026a1-d01e-4d34-8209-81e8ed5c614b") }
Description("Disabled Input Barcode with content", textColor = TextColor.OnSurfaceVariant)
InputBarCode(
"label",
state = InputShellState.DISABLED,
onActionButtonClicked = {
},
inputText = inputValue3,
onValueChanged = {
if (it != null) {
inputValue3 = it
}
},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.hisp.dhis.common.screens

import androidx.compose.runtime.Composable
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.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionIconType
import org.hisp.dhis.mobile.ui.designsystem.component.InputDateTime
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTimeTransformation
import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation
import org.hisp.dhis.mobile.ui.designsystem.component.internal.TimeTransformation

@Composable
fun InputDateTimeScreen() {
ColumnComponentContainer {
var date by remember { mutableStateOf("") }
var time by remember { mutableStateOf("") }
var dateTime by remember { mutableStateOf("") }

InputDateTime(
title = "Label",
value = date,
visualTransformation = DateTransformation(),
actionIconType = DateTimeActionIconType.DATE,
onActionClicked = {
// no-op
},
onValueChanged = { date = it },
)

InputDateTime(
title = "Label",
value = time,
visualTransformation = TimeTransformation(),
actionIconType = DateTimeActionIconType.TIME,
onActionClicked = {
// no-op
},
onValueChanged = { time = it },
)

InputDateTime(
title = "Label",
value = dateTime,
visualTransformation = DateTimeTransformation(),
actionIconType = DateTimeActionIconType.DATE_TIME,
onActionClicked = {
// no-op
},
onValueChanged = { dateTime = it },
)

InputDateTime(
title = "Label",
value = "",
state = InputShellState.DISABLED,
onActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)

InputDateTime(
title = "Label",
value = "",
isRequired = true,
state = InputShellState.ERROR,
onActionClicked = {
// no-op
},
onValueChanged = {
// no-op
},
)
}
}
Loading

0 comments on commit 61f2927

Please sign in to comment.