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 18, 2023
2 parents c9883a7 + dcc92bf commit 00c27ff
Show file tree
Hide file tree
Showing 45 changed files with 2,278 additions and 195 deletions.
10 changes: 10 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,11 @@ 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.InputCoordinateScreen
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 +53,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 +176,15 @@ 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()
Components.INPUT_COORDINATE -> InputCoordinateScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ 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"),
INPUT_COORDINATE("Input Coordinate"),
}
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,73 @@
package org.hisp.dhis.common.screens

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
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 org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.Coordinates
import org.hisp.dhis.mobile.ui.designsystem.component.InputCoordinate
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
import org.hisp.dhis.mobile.ui.designsystem.component.Title
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
fun InputCoordinateScreen() {
ColumnComponentContainer {
Title("Input Coordinates", textColor = TextColor.OnSurfaceVariant)

SubTitle("Basic Input Coordinates ", textColor = TextColor.OnSurfaceVariant)
var coordinates by rememberSaveable { mutableStateOf<Coordinates?>(null) }
InputCoordinate(
title = "Label",
state = InputShellState.UNFOCUSED,
coordinates = coordinates,
onResetButtonClicked = {
coordinates = null
},
onUpdateButtonClicked = {
coordinates = Coordinates(latitude = 39.46263, longitude = -0.33617)
},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Disabled Input Coordinates without data ", textColor = TextColor.OnSurfaceVariant)
var coordinates1 by rememberSaveable {
mutableStateOf<Coordinates?>(null)
}
InputCoordinate(
title = "Label",
state = InputShellState.DISABLED,
coordinates = coordinates1,
onResetButtonClicked = {
coordinates1 = null
},
onUpdateButtonClicked = {
coordinates1 = Coordinates(latitude = 39.46263, longitude = -0.33617)
},
)

SubTitle("Disabled Input Coordinates with data ", textColor = TextColor.OnSurfaceVariant)
var coordinates2 by rememberSaveable {
mutableStateOf<Coordinates?>(Coordinates(latitude = 39.46263, longitude = -0.33617))
}
InputCoordinate(
title = "Label",
state = InputShellState.DISABLED,
coordinates = coordinates2,
onResetButtonClicked = {
coordinates2 = null
},
onUpdateButtonClicked = {
coordinates2 = Coordinates(latitude = 39.46263, longitude = -0.33617)
},
)
Spacer(Modifier.size(Spacing.Spacing18))
}
}
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 00c27ff

Please sign in to comment.