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 6, 2023
2 parents b858d91 + eae4495 commit c4214cf
Show file tree
Hide file tree
Showing 35 changed files with 2,798 additions and 72 deletions.
16 changes: 13 additions & 3 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.hisp.dhis.common.screens.BarcodeBlockScreen
import org.hisp.dhis.common.screens.BottomSheetHeaderScreen
import org.hisp.dhis.common.screens.BottomSheetScreen
import org.hisp.dhis.common.screens.ButtonBlockScreen
import org.hisp.dhis.common.screens.ButtonCarouselScreen
import org.hisp.dhis.common.screens.ButtonScreen
import org.hisp.dhis.common.screens.CheckboxScreen
import org.hisp.dhis.common.screens.ChipsScreen
Expand All @@ -36,8 +37,10 @@ import org.hisp.dhis.common.screens.IconButtonScreen
import org.hisp.dhis.common.screens.InputAgeScreen
import org.hisp.dhis.common.screens.InputCheckBoxScreen
import org.hisp.dhis.common.screens.InputFileResourceScreen
import org.hisp.dhis.common.screens.InputEmailScreen
import org.hisp.dhis.common.screens.InputIntegerScreen
import org.hisp.dhis.common.screens.InputLetterScreen
import org.hisp.dhis.common.screens.InputLinkScreen
import org.hisp.dhis.common.screens.InputLongTextScreen
import org.hisp.dhis.common.screens.InputMatrixScreen
import org.hisp.dhis.common.screens.InputNegativeIntegerScreen
Expand All @@ -46,6 +49,7 @@ import org.hisp.dhis.common.screens.InputPercentageScreen
import org.hisp.dhis.common.screens.InputPhoneNumberScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerOrZeroScreen
import org.hisp.dhis.common.screens.InputPositiveIntegerScreen
import org.hisp.dhis.common.screens.InputQRCodeScreen
import org.hisp.dhis.common.screens.InputRadioButtonScreen
import org.hisp.dhis.common.screens.InputScreen
import org.hisp.dhis.common.screens.InputSequentialScreen
Expand All @@ -55,9 +59,9 @@ import org.hisp.dhis.common.screens.InputYesOnlyCheckBoxScreen
import org.hisp.dhis.common.screens.InputYesOnlySwitchScreen
import org.hisp.dhis.common.screens.LegendDescriptionScreen
import org.hisp.dhis.common.screens.LegendScreen
import org.hisp.dhis.common.screens.ListCardScreen
import org.hisp.dhis.common.screens.MetadataAvatarScreen
import org.hisp.dhis.common.screens.ProgressScreen
import org.hisp.dhis.common.screens.QrCodeBlockScreen
import org.hisp.dhis.common.screens.RadioButtonScreen
import org.hisp.dhis.common.screens.SectionScreen
import org.hisp.dhis.common.screens.SupportingTextScreen
Expand All @@ -75,7 +79,9 @@ fun App() {

@Composable
fun Main() {
val currentScreen = remember { mutableStateOf(Components.INPUT_FILE_RESOURCE) }

val currentScreen = remember { mutableStateOf(Components.CAROUSEL_BUTTONS) }

var expanded by remember { mutableStateOf(false) }

Column(
Expand Down Expand Up @@ -155,14 +161,18 @@ fun Main() {
Components.INPUT_RADIO_BUTTON -> InputRadioButtonScreen()
Components.INPUT_MATRIX -> InputMatrixScreen()
Components.INPUT_SEQUENTIAL -> InputSequentialScreen()
Components.QR_CODE_BLOCK -> QrCodeBlockScreen()
Components.INPUT_QR_CODE -> InputQRCodeScreen()
Components.INPUT_CHECK_BOX -> InputCheckBoxScreen()
Components.BARCODE_BLOCK -> BarcodeBlockScreen()
Components.INPUT_YES_ONLY_SWITCH -> InputYesOnlySwitchScreen()
Components.INPUT_YES_ONLY_CHECKBOX -> InputYesOnlyCheckBoxScreen()
Components.INPUT_YES_NO_FIELD -> InputYesNoFieldScreen()
Components.LIST_CARD -> ListCardScreen()
Components.INPUT_PHONE_NUMBER -> InputPhoneNumberScreen()
Components.INPUT_FILE_RESOURCE -> InputFileResourceScreen()
Components.INPUT_LINK -> InputLinkScreen()
Components.INPUT_EMAIL -> InputEmailScreen()
Components.CAROUSEL_BUTTONS -> ButtonCarouselScreen()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.hisp.dhis.common.screens

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.FileDownload
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import org.hisp.dhis.common.screens.previews.fiveButtonCarousel
import org.hisp.dhis.common.screens.previews.overflowButtonCarousel
import org.hisp.dhis.common.screens.previews.threeButtonCarousel
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonCarousel
import org.hisp.dhis.mobile.ui.designsystem.component.CarouselButtonData
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.RowComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
import org.hisp.dhis.mobile.ui.designsystem.component.Title

@Composable
fun ButtonCarouselScreen() {
ColumnComponentContainer {
Title("Carousel Buttons")
RowComponentContainer(
title = "Simple Carousel Button",
) {
ButtonCarousel(
carouselButtonList = listOf(
CarouselButtonData(
enabled = true,
text = "Label",
icon = {
Icon(
imageVector = Icons.Outlined.FileDownload,
contentDescription = "Carousel Button",
)
},
onClick = {},
),
),
)
}
RowComponentContainer(
title = "Buttons Carousel",
) {
Column(
Modifier.fillMaxWidth(),
) {
ButtonCarousel(
carouselButtonList = threeButtonCarousel,
)

ButtonCarousel(
carouselButtonList = fiveButtonCarousel,
)

SubTitle("Overflow case")
ButtonCarousel(
carouselButtonList = overflowButtonCarousel,
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ enum class Components(val label: String) {
SWITCH("Switch"),
INPUT_MATRIX("Input Matrix"),
INPUT_SEQUENTIAL("Input Sequential"),
QR_CODE_BLOCK("QR Code Block"),
INPUT_QR_CODE("Input QR code"),
INPUT_CHECK_BOX("Input Check Box"),
BARCODE_BLOCK("Barcode Block"),
AGE_FIELD("Age Field"),
INPUT_YES_ONLY_SWITCH("Input yes only switch"),
INPUT_YES_ONLY_CHECKBOX("Input yes only checkbox"),
INPUT_YES_NO_FIELD("Input Yes/No field"),
LIST_CARD("List Card"),
INPUT_PHONE_NUMBER("Input Phone Number"),
INPUT_FILE_RESOURCE("Input File Resource"),
INPUT_LINK("Input Link"),
INPUT_EMAIL("Input Email"),
CAROUSEL_BUTTONS("Carousel buttons"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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.InputEmail
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.SupportingTextData
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextState
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 InputEmailScreen() {
ColumnComponentContainer {
Title("Input Email component", textColor = TextColor.OnSurfaceVariant)
SubTitle("Basic Email ", textColor = TextColor.OnSurfaceVariant)
var inputText1 by rememberSaveable { mutableStateOf("") }

InputEmail(
title = "Label",
supportingText = listOf(SupportingTextData("Example: [email protected]")),
inputText = inputText1,
onValueChanged = {
if (it != null) {
inputText1 = it
}
},
onEmailActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Basic Email with content ", textColor = TextColor.OnSurfaceVariant)
var inputText2 by rememberSaveable { mutableStateOf("[email protected]") }

InputEmail(
title = "Label",
supportingText = listOf(SupportingTextData("Example: [email protected]")),
inputText = inputText2,
onValueChanged = {
if (it != null) {
inputText2 = it
}
},
onEmailActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Error Email with content ", textColor = TextColor.OnSurfaceVariant)
var inputText3 by rememberSaveable { mutableStateOf("[email protected]") }

InputEmail(
title = "Label",
state = InputShellState.ERROR,
supportingText = listOf(SupportingTextData("Enter a valid email address", SupportingTextState.ERROR)),
inputText = inputText3,
onValueChanged = {
if (it != null) {
inputText3 = it
}
},
onEmailActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Error Email required field ", textColor = TextColor.OnSurfaceVariant)
var inputText4 by rememberSaveable { mutableStateOf("") }
InputEmail(
title = "Label",
state = InputShellState.ERROR,
supportingText = listOf(SupportingTextData("Enter email address", SupportingTextState.ERROR)),
inputText = inputText4,
isRequiredField = true,
onValueChanged = {
if (it != null) {
inputText4 = it
}
},
onEmailActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Disabled Email with content ", textColor = TextColor.OnSurfaceVariant)
var inputText5 by rememberSaveable { mutableStateOf("[email protected]") }
InputEmail(
title = "Label",
state = InputShellState.DISABLED,
inputText = inputText5,
onValueChanged = {
if (it != null) {
inputText5 = it
}
},
onEmailActionCLicked = {},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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.InputLink
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.SupportingTextData
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextState
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 InputLinkScreen() {
ColumnComponentContainer {
Title("Input Link component", textColor = TextColor.OnSurfaceVariant)
SubTitle("Basic Link ", textColor = TextColor.OnSurfaceVariant)
var inputText1 by rememberSaveable { mutableStateOf("") }

InputLink(
title = "Label",
supportingText = listOf(SupportingTextData("Example: example.com")),
inputText = inputText1,
onValueChanged = {
if (it != null) {
inputText1 = it
}
},
onLinkActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Basic Link with invalid link ", textColor = TextColor.OnSurfaceVariant)
var inputText2 by rememberSaveable { mutableStateOf("example.") }

InputLink(
title = "Label",
supportingText = listOf(SupportingTextData("Example: example.com")),
inputText = inputText2,
onValueChanged = {
if (it != null) {
inputText2 = it
}
},
onLinkActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Basic Link with valid link ", textColor = TextColor.OnSurfaceVariant)
var inputText3 by rememberSaveable { mutableStateOf("example.com") }

InputLink(
title = "Label",
supportingText = listOf(SupportingTextData("Example: example.com")),
inputText = inputText3,
onValueChanged = {
if (it != null) {
inputText3 = it
}
},
onLinkActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Error Link required field ", textColor = TextColor.OnSurfaceVariant)
var inputText4 by rememberSaveable { mutableStateOf("") }
InputLink(
title = "Label",
state = InputShellState.ERROR,
supportingText = listOf(SupportingTextData("Required", SupportingTextState.ERROR)),
inputText = inputText4,
isRequiredField = true,
onValueChanged = {
if (it != null) {
inputText4 = it
}
},
onLinkActionCLicked = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Disabled Link with content ", textColor = TextColor.OnSurfaceVariant)
var inputText5 by rememberSaveable { mutableStateOf("example.com") }
InputLink(
title = "Label",
state = InputShellState.DISABLED,
inputText = inputText5,
onValueChanged = {
if (it != null) {
inputText5 = it
}
},
onLinkActionCLicked = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun InputPhoneNumberScreen() {
onCallActionClicked = {
// no-op
},
onFocusChanged = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -50,6 +51,7 @@ fun InputPhoneNumberScreen() {
onCallActionClicked = {
// no-op
},
onFocusChanged = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -67,6 +69,7 @@ fun InputPhoneNumberScreen() {
onCallActionClicked = {
// no-op
},
onFocusChanged = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -85,6 +88,7 @@ fun InputPhoneNumberScreen() {
onCallActionClicked = {
// no-op
},
onFocusChanged = {},
)
Spacer(Modifier.size(Spacing.Spacing18))
}
Expand Down
Loading

0 comments on commit c4214cf

Please sign in to comment.