diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/actionInputs/InputDateTimeScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/actionInputs/InputDateTimeScreen.kt index 2148f89d9..30afa27f4 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/actionInputs/InputDateTimeScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/actionInputs/InputDateTimeScreen.kt @@ -13,9 +13,9 @@ import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionType 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.SelectableDates -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 +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTimeTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.TimeTransformation import org.hisp.dhis.mobile.ui.designsystem.component.state.InputDateTimeData import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputDateTimeState diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/basicTextInputs/InputNumberScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/basicTextInputs/InputNumberScreen.kt index 3d06024c9..40193455d 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/basicTextInputs/InputNumberScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/basicTextInputs/InputNumberScreen.kt @@ -10,7 +10,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer import org.hisp.dhis.mobile.ui.designsystem.component.InputNumber import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations @Composable fun InputNumberScreen() { diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt index e4afe9359..759245159 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt @@ -15,11 +15,11 @@ import org.hisp.dhis.mobile.ui.designsystem.component.AvatarStyleData import org.hisp.dhis.mobile.ui.designsystem.component.Button import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle import org.hisp.dhis.mobile.ui.designsystem.component.ExpandableItemColumn +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.ListCardDescriptionModel import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel import org.hisp.dhis.mobile.ui.designsystem.component.MetadataAvatarSize import org.hisp.dhis.mobile.ui.designsystem.component.VerticalInfoListCard -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberAdditionalInfoColumnState import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberListCardState import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ListCardScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ListCardScreen.kt index 47a40559c..522e2212c 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ListCardScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ListCardScreen.kt @@ -36,11 +36,11 @@ import org.hisp.dhis.mobile.ui.designsystem.component.Button import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.ListCard import org.hisp.dhis.mobile.ui.designsystem.component.ListCardDescriptionModel import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel import org.hisp.dhis.mobile.ui.designsystem.component.MetadataAvatarSize -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberAdditionalInfoColumnState import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberListCardState import org.hisp.dhis.mobile.ui.designsystem.resource.provideDHIS2Icon diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/parameter/ParameterSelectorScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/parameter/ParameterSelectorScreen.kt index 794a3ff28..58c58c1e2 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/parameter/ParameterSelectorScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/parameter/ParameterSelectorScreen.kt @@ -16,6 +16,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.CheckBoxData import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionType import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.InputAge import org.hisp.dhis.mobile.ui.designsystem.component.InputAgeModel import org.hisp.dhis.mobile.ui.designsystem.component.InputBarCode @@ -36,8 +37,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState import org.hisp.dhis.mobile.ui.designsystem.component.InputStyle import org.hisp.dhis.mobile.ui.designsystem.component.InputText import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonData -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTimeTransformation -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTimeTransformation import org.hisp.dhis.mobile.ui.designsystem.component.parameter.ParameterSelectorItem import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel.Status.CLOSED diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputMatrixScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputMatrixScreen.kt index d40acb53f..813b94573 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputMatrixScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputMatrixScreen.kt @@ -12,9 +12,9 @@ import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.graphics.painter.Painter import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.InputMatrix import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor @Composable diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputSequentialScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputSequentialScreen.kt index eebd8858b..6056c87c2 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputSequentialScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/toggleableInputs/InputSequentialScreen.kt @@ -12,9 +12,9 @@ import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.graphics.painter.Painter import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.InputSequential import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor @Composable diff --git a/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt b/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt index ae4b0a3c0..9496f848d 100644 --- a/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt +++ b/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt @@ -10,7 +10,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalView @Composable -actual fun keyboardAsState(): State { +internal actual fun keyboardAsState(): State { val keyboardState = remember { mutableStateOf(Keyboard.Closed) } val view = LocalView.current DisposableEffect(view) { diff --git a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/ExpandableItemColumnSnapshotTest.kt b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/ExpandableItemColumnSnapshotTest.kt index 14477af06..6dab31887 100644 --- a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/ExpandableItemColumnSnapshotTest.kt +++ b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/ExpandableItemColumnSnapshotTest.kt @@ -14,11 +14,11 @@ import org.hisp.dhis.mobile.ui.designsystem.component.AvatarStyleData import org.hisp.dhis.mobile.ui.designsystem.component.Button import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle import org.hisp.dhis.mobile.ui.designsystem.component.ExpandableItemColumn +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.ListCardDescriptionModel import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel import org.hisp.dhis.mobile.ui.designsystem.component.MetadataAvatarSize import org.hisp.dhis.mobile.ui.designsystem.component.VerticalInfoListCard -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberAdditionalInfoColumnState import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberListCardState import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor diff --git a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputMatrixSnapshotTest.kt b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputMatrixSnapshotTest.kt index 4557bcb4d..7e44071d9 100644 --- a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputMatrixSnapshotTest.kt +++ b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputMatrixSnapshotTest.kt @@ -9,9 +9,9 @@ import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.platform.LocalContext import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.InputMatrix import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.junit.Rule import org.junit.Test diff --git a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputSequentialSnapshotTest.kt b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputSequentialSnapshotTest.kt index f9f422359..ec4c4e301 100644 --- a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputSequentialSnapshotTest.kt +++ b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/InputSequentialSnapshotTest.kt @@ -9,9 +9,9 @@ import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.platform.LocalContext import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer +import org.hisp.dhis.mobile.ui.designsystem.component.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.InputSequential import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.junit.Rule import org.junit.Test diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Avatar.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Avatar.kt index 891e02019..5a388898c 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Avatar.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Avatar.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.resource.provideDHIS2Icon import org.hisp.dhis.mobile.ui.designsystem.theme.Radius import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt index d1c401edb..3ebaf8d6c 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt @@ -29,7 +29,7 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.window.PopupProperties -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations import org.hisp.dhis.mobile.ui.designsystem.theme.InternalSizeValues import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/IconCard.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/IconCard.kt similarity index 97% rename from designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/IconCard.kt rename to designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/IconCard.kt index d284a4a8e..56b3bbbee 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/IconCard.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/IconCard.kt @@ -1,4 +1,4 @@ -package org.hisp.dhis.mobile.ui.designsystem.component.internal +package org.hisp.dhis.mobile.ui.designsystem.component import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.ColumnScope diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputAge.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputAge.kt index 1784560f3..bd1249127 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputAge.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputAge.kt @@ -33,11 +33,11 @@ import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType.Age import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType.DateOfBirth import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType.None import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues.YEARS -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation.Companion.DATE_MASK -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations import org.hisp.dhis.mobile.ui.designsystem.component.internal.dateIsInRange import org.hisp.dhis.mobile.ui.designsystem.component.internal.isValidDate import org.hisp.dhis.mobile.ui.designsystem.component.internal.parseStringDateToMillis +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation.Companion.DATE_MASK +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2LightColorScheme import org.hisp.dhis.mobile.ui.designsystem.theme.Outline diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTime.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTime.kt index 35ff1aa58..c24272fe5 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTime.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTime.kt @@ -52,9 +52,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTimeVisualTransformation -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations import org.hisp.dhis.mobile.ui.designsystem.component.internal.convertStringToTextFieldValue import org.hisp.dhis.mobile.ui.designsystem.component.internal.formatStoredDateToUI import org.hisp.dhis.mobile.ui.designsystem.component.internal.formatUIDateToStored @@ -65,10 +62,12 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.getTime import org.hisp.dhis.mobile.ui.designsystem.component.internal.getTimePickerState import org.hisp.dhis.mobile.ui.designsystem.component.internal.isValidHourFormat import org.hisp.dhis.mobile.ui.designsystem.component.internal.parseDate -import org.hisp.dhis.mobile.ui.designsystem.component.internal.parseStringDateToMillis import org.hisp.dhis.mobile.ui.designsystem.component.internal.provideDatePickerState import org.hisp.dhis.mobile.ui.designsystem.component.internal.timePickerColors import org.hisp.dhis.mobile.ui.designsystem.component.internal.yearIsInRange +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTimeVisualTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations import org.hisp.dhis.mobile.ui.designsystem.component.state.InputDateTimeState import org.hisp.dhis.mobile.ui.designsystem.resource.provideStringResource import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2LightColorScheme diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmail.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmail.kt index 01dcea09d..5722abfbc 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmail.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputEmail.kt @@ -10,7 +10,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input email. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputField.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputField.kt index 9a5ec7edc..cb702fd42 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputField.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputField.kt @@ -23,9 +23,9 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.VisualTransformation -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation import org.hisp.dhis.mobile.ui.designsystem.component.internal.PrefixTransformation import org.hisp.dhis.mobile.ui.designsystem.component.internal.SuffixTransformer +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation import org.hisp.dhis.mobile.ui.designsystem.theme.Color.Blue300 import org.hisp.dhis.mobile.ui.designsystem.theme.InternalFloatValues import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputInteger.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputInteger.kt index 232b3fc2d..dd9a6730b 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputInteger.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputInteger.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input Integer. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetter.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetter.kt index 353eacb00..06f31f8fc 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetter.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLetter.kt @@ -7,7 +7,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input Letter. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLink.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLink.kt index 3c697e581..fb20db6ac 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLink.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputLink.kt @@ -10,7 +10,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input link. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrix.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrix.kt index b75f373da..49158b573 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrix.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrix.kt @@ -14,8 +14,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.testTag -import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCard -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.component.internal.VerticalGrid import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeInteger.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeInteger.kt index 749e5cf4d..081669a7e 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeInteger.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNegativeInteger.kt @@ -11,7 +11,7 @@ import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input negative Integer. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumber.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumber.kt index 4f729a5be..90472c4da 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumber.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputNumber.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input Number. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentage.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentage.kt index d9fd4324c..cabe3c57c 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentage.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPercentage.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input percentage. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt index e93608022..0f4676845 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPhoneNumber.kt @@ -10,7 +10,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input Phone Number. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveInteger.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveInteger.kt index 5e4c820e8..fe7e453a2 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveInteger.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveInteger.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input positive Integer. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZero.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZero.kt index 65a053913..cf5e0c77b 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZero.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputPositiveIntegerOrZero.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input positive Integer or zero. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequential.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequential.kt index 2422ece25..5199d5718 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequential.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequential.kt @@ -15,8 +15,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.testTag -import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCard -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitInterval.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitInterval.kt index 7906305c4..9cb5cadda 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitInterval.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputUnitInterval.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations +import org.hisp.dhis.mobile.ui.designsystem.component.model.RegExValidations /** * DHIS2 Input Unit Interval. Wraps DHIS · [BasicTextInput]. diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/MetadataIcon.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/MetadataIcon.kt index d740a4e80..1e82ab85f 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/MetadataIcon.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/MetadataIcon.kt @@ -7,7 +7,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.resource.provideDHIS2Icon /** diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeUtils.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeUtils.kt index a6f420c37..443a1d668 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeUtils.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeUtils.kt @@ -251,7 +251,7 @@ internal fun getTime(timePickerState: TimePickerState, format: String = "HHmm"): @Suppress("deprecation") @Deprecated("This function is deprecated and will be removed once new implementation is added to the capture app. ") @OptIn(ExperimentalMaterial3Api::class) -fun getSelectableDates(uiModel: InputDateTimeModel): androidx.compose.material3.SelectableDates { +internal fun getSelectableDates(uiModel: InputDateTimeModel): androidx.compose.material3.SelectableDates { return object : androidx.compose.material3.SelectableDates { override fun isSelectableDate(utcTimeMillis: Long): Boolean { return dateIsInRange(utcTimeMillis, uiModel.selectableDates, uiModel.format) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt index b2cf2cb82..43e18deae 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt @@ -3,7 +3,7 @@ package org.hisp.dhis.mobile.ui.designsystem.component.internal import androidx.compose.runtime.Composable import androidx.compose.runtime.State -enum class Keyboard { +internal enum class Keyboard { Opened, Closed } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/StringUtils.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/StringUtils.kt index 853064a87..9da9450a6 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/StringUtils.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/StringUtils.kt @@ -2,7 +2,6 @@ package org.hisp.dhis.mobile.ui.designsystem.component.internal import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextRange -import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.input.OffsetMapping import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.TransformedText @@ -10,13 +9,18 @@ import androidx.compose.ui.text.input.VisualTransformation import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor -internal class PrefixTransformation(private val prefix: String, val enabled: Boolean) : VisualTransformation { +internal class PrefixTransformation(private val prefix: String, val enabled: Boolean) : + VisualTransformation { override fun filter(text: AnnotatedString): TransformedText { return prefixFilter(text, prefix, enabled = enabled) } } -internal fun prefixFilter(text: AnnotatedString, prefix: String, enabled: Boolean = true): TransformedText { +internal fun prefixFilter( + text: AnnotatedString, + prefix: String, + enabled: Boolean = true, +): TransformedText { val out = AnnotatedString( "$prefix ", spanStyle = DHIS2SCustomTextStyles.inputFieldHelper, @@ -65,229 +69,9 @@ internal class SuffixTransformer(val suffix: String) : VisualTransformation { } } -interface DateTimeVisualTransformation : VisualTransformation { - val maskLength: Int -} - -class DateTransformation : DateTimeVisualTransformation { - - companion object { - private const val SEPARATOR = "/" - - // Check the usages before modifying - internal const val DATE_MASK = "DDMMYYYY" - } - - override val maskLength: Int - get() = DATE_MASK.length - - override fun filter(text: AnnotatedString): TransformedText { - return dateFilter(text) - } - - private fun dateFilter(text: AnnotatedString): TransformedText { - val trimmed = if (text.text.length > DATE_MASK.length) text.text.substring(0..DATE_MASK.length) else text.text - val output = buildAnnotatedString { - for (i in DATE_MASK.indices) { - val dateChar = trimmed.getOrNull(i) - if (dateChar == null) { - append(AnnotatedString(DATE_MASK[i].toString(), DHIS2SCustomTextStyles.inputFieldHelper)) - } else { - append(trimmed[i]) - } - - if (i % 2 == 1 && i < 4) { - val separator = if (dateChar != null) { - SEPARATOR - } else { - AnnotatedString(SEPARATOR, DHIS2SCustomTextStyles.inputFieldHelper) - } - append(separator) - } - } - } - - val offsetMapping = object : OffsetMapping { - override fun originalToTransformed(offset: Int): Int { - if (trimmed.lastIndex >= 0) { - if (offset <= 1) return offset - if (offset <= 3) return offset + 1 - if (offset <= 8) return offset + 2 - return 10 - } else { - return 0 - } - } - - override fun transformedToOriginal(offset: Int): Int { - if (offset > text.length) return text.length - return offset - } - } - - return TransformedText(output, offsetMapping) - } -} - -class TimeTransformation : DateTimeVisualTransformation { - - companion object { - private const val SEPARATOR = ":" - - // Check the usages before modifying - internal const val TIME_MASK = "HHMM" - } - - override val maskLength: Int - get() = TIME_MASK.length - - override fun filter(text: AnnotatedString): TransformedText { - return timeFilter(text) - } - - private fun timeFilter(text: AnnotatedString): TransformedText { - val trimmed = if (text.text.length > TIME_MASK.length) text.text.substring(0..TIME_MASK.length) else text.text - val output = buildAnnotatedString { - for (i in TIME_MASK.indices) { - val timeChar = trimmed.getOrNull(i) - if (timeChar == null) { - append(AnnotatedString(TIME_MASK[i].toString(), DHIS2SCustomTextStyles.inputFieldHelper)) - } else { - append(trimmed[i]) - } - - if (i == 1) { - val separator = if (timeChar != null) { - SEPARATOR - } else { - AnnotatedString(SEPARATOR, DHIS2SCustomTextStyles.inputFieldHelper) - } - append(separator) - } - } - } - - val offsetMapping = object : OffsetMapping { - override fun originalToTransformed(offset: Int): Int { - if (trimmed.lastIndex >= 0) { - if (offset <= 1) return offset - return offset + 1 - } else { - return 0 - } - } - - override fun transformedToOriginal(offset: Int): Int { - if (offset > text.length) return text.length - return offset - } - } - - return TransformedText(output, offsetMapping) - } -} - -class DateTimeTransformation : DateTimeVisualTransformation { - - companion object { - private const val SEPARATOR_DATE = "/" - private const val SEPARATOR_TIME = ":" - private const val SEPARATOR_DATE_TIME = " - " - - // Check the usages before modifying - internal const val DATETIME_MASK = "DDMMYYYYhhmm" - } - - override val maskLength: Int - get() = DATETIME_MASK.length - - override fun filter(text: AnnotatedString): TransformedText { - return dateTimeFilter(text) - } - - private fun dateTimeFilter(text: AnnotatedString): TransformedText { - val trimmed = if (text.text.length > DATETIME_MASK.length) text.text.substring(0..DATETIME_MASK.length) else text.text - val output = buildAnnotatedString { - for (i in DATETIME_MASK.indices) { - val char = trimmed.getOrNull(i) - if (char == null) { - append(AnnotatedString(DATETIME_MASK[i].toString(), DHIS2SCustomTextStyles.inputFieldHelper)) - } else { - append(trimmed[i]) - } - - when (i) { - 1, 3 -> { - val separator = if (char == null) { - AnnotatedString(SEPARATOR_DATE, DHIS2SCustomTextStyles.inputFieldHelper) - } else { - SEPARATOR_DATE - } - append(separator) - } - 7 -> { - val separator = if (char == null) { - AnnotatedString(SEPARATOR_DATE_TIME, DHIS2SCustomTextStyles.inputFieldHelper) - } else { - SEPARATOR_DATE_TIME - } - append(separator) - } - 9 -> { - val separator = if (char == null) { - AnnotatedString(SEPARATOR_TIME, DHIS2SCustomTextStyles.inputFieldHelper) - } else { - SEPARATOR_TIME - } - append(separator) - } - } - } - } - - val offsetMapping = object : OffsetMapping { - override fun originalToTransformed(offset: Int): Int { - return if (trimmed.lastIndex >= 0) { - if (offset <= 1) return offset - if (offset <= 3) return offset + 1 - if (offset < 8) return offset + 2 - if (offset == 8) return offset + 5 - if (offset <= 11) return offset + 6 - return 18 - } else { - 0 - } - } - - override fun transformedToOriginal(offset: Int): Int { - if (offset > text.length) return text.length - return offset - } - } - - return TransformedText(output, offsetMapping) - } -} - internal fun convertStringToTextFieldValue(inputDateString: String?): TextFieldValue { inputDateString?.let { return TextFieldValue(inputDateString, TextRange(inputDateString.length)) } return TextFieldValue() } - -enum class RegExValidations(val regex: Regex) { - BRITISH_DECIMAL_NOTATION("""^(?!\.)(?!.*-[^0-9])(?!(?:[^.]*\.){3})[-0-9]*(?:\.[0-9]*)?$""".toRegex()), - EUROPEAN_DECIMAL_NOTATION("""^(?!.*,.+,|.*-.*-)[0-9,-]*$""".toRegex()), - ONLY_INTEGERS("^-?(?!0)\\d*".toRegex()), - SINGLE_LETTER("^[^\\d.,;!?\\s]$".toRegex()), - NEGATIVE_INTEGERS("^(?!0)\\d*".toRegex()), - PERCENTAGE("^([1-9]|[1-9][0-9]|100)\$".toRegex()), - POSITIVE_INTEGER("^(?!0)\\d*".toRegex()), - POSITIVE_INTEGER_OR_ZERO("^(0|[1-9]\\d*)\$".toRegex()), - PHONE_NUMBER("^[+0-9-()]+$".toRegex()), - LINK("((https?|ftp|smtp)://)?(www\\.)?[a-zA-Z0-9@:%._+~#=-]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&/=-]*)".toRegex()), - EMAIL("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}\$".toRegex()), - DATE_TIME("^[0-9]+$".toRegex()), - UNIT_INTERVAL_BETWEEN_0_AND_1("^(0?(\\.\\d*?)?|1(\\.0+)?)\$".toRegex()), -} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeTransformation.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeTransformation.kt new file mode 100644 index 000000000..3803d17f5 --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeTransformation.kt @@ -0,0 +1,100 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.model + +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.input.OffsetMapping +import androidx.compose.ui.text.input.TransformedText +import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles + +class DateTimeTransformation : DateTimeVisualTransformation { + + companion object { + private const val SEPARATOR_DATE = "/" + private const val SEPARATOR_TIME = ":" + private const val SEPARATOR_DATE_TIME = " - " + + // Check the usages before modifying + internal const val DATETIME_MASK = "DDMMYYYYhhmm" + } + + override val maskLength: Int + get() = DATETIME_MASK.length + + override fun filter(text: AnnotatedString): TransformedText { + return dateTimeFilter(text) + } + + private fun dateTimeFilter(text: AnnotatedString): TransformedText { + val trimmed = + if (text.text.length > DATETIME_MASK.length) text.text.substring(0..DATETIME_MASK.length) else text.text + val output = buildAnnotatedString { + for (i in DATETIME_MASK.indices) { + val char = trimmed.getOrNull(i) + if (char == null) { + append( + AnnotatedString( + DATETIME_MASK[i].toString(), + DHIS2SCustomTextStyles.inputFieldHelper, + ), + ) + } else { + append(trimmed[i]) + } + + when (i) { + 1, 3 -> { + val separator = if (char == null) { + AnnotatedString(SEPARATOR_DATE, DHIS2SCustomTextStyles.inputFieldHelper) + } else { + SEPARATOR_DATE + } + append(separator) + } + + 7 -> { + val separator = if (char == null) { + AnnotatedString( + SEPARATOR_DATE_TIME, + DHIS2SCustomTextStyles.inputFieldHelper, + ) + } else { + SEPARATOR_DATE_TIME + } + append(separator) + } + + 9 -> { + val separator = if (char == null) { + AnnotatedString(SEPARATOR_TIME, DHIS2SCustomTextStyles.inputFieldHelper) + } else { + SEPARATOR_TIME + } + append(separator) + } + } + } + } + + val offsetMapping = object : OffsetMapping { + override fun originalToTransformed(offset: Int): Int { + return if (trimmed.lastIndex >= 0) { + if (offset <= 1) return offset + if (offset <= 3) return offset + 1 + if (offset < 8) return offset + 2 + if (offset == 8) return offset + 5 + if (offset <= 11) return offset + 6 + return 18 + } else { + 0 + } + } + + override fun transformedToOriginal(offset: Int): Int { + if (offset > text.length) return text.length + return offset + } + } + + return TransformedText(output, offsetMapping) + } +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeVisualTransformation.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeVisualTransformation.kt new file mode 100644 index 000000000..85d512f41 --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTimeVisualTransformation.kt @@ -0,0 +1,7 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.model + +import androidx.compose.ui.text.input.VisualTransformation + +interface DateTimeVisualTransformation : VisualTransformation { + val maskLength: Int +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTransformation.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTransformation.kt new file mode 100644 index 000000000..3dde52005 --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/DateTransformation.kt @@ -0,0 +1,67 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.model + +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.input.OffsetMapping +import androidx.compose.ui.text.input.TransformedText +import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles + +class DateTransformation : DateTimeVisualTransformation { + + companion object { + private const val SEPARATOR = "/" + + // Check the usages before modifying + internal const val DATE_MASK = "DDMMYYYY" + } + + override val maskLength: Int + get() = DATE_MASK.length + + override fun filter(text: AnnotatedString): TransformedText { + return dateFilter(text) + } + + private fun dateFilter(text: AnnotatedString): TransformedText { + val trimmed = if (text.text.length > DATE_MASK.length) text.text.substring(0..DATE_MASK.length) else text.text + val output = buildAnnotatedString { + for (i in DATE_MASK.indices) { + val dateChar = trimmed.getOrNull(i) + if (dateChar == null) { + append(AnnotatedString(DATE_MASK[i].toString(), DHIS2SCustomTextStyles.inputFieldHelper)) + } else { + append(trimmed[i]) + } + + if (i % 2 == 1 && i < 4) { + val separator = if (dateChar != null) { + SEPARATOR + } else { + AnnotatedString(SEPARATOR, DHIS2SCustomTextStyles.inputFieldHelper) + } + append(separator) + } + } + } + + val offsetMapping = object : OffsetMapping { + override fun originalToTransformed(offset: Int): Int { + if (trimmed.lastIndex >= 0) { + if (offset <= 1) return offset + if (offset <= 3) return offset + 1 + if (offset <= 8) return offset + 2 + return 10 + } else { + return 0 + } + } + + override fun transformedToOriginal(offset: Int): Int { + if (offset > text.length) return text.length + return offset + } + } + + return TransformedText(output, offsetMapping) + } +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/RegExValidations.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/RegExValidations.kt new file mode 100644 index 000000000..c573b5e3b --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/RegExValidations.kt @@ -0,0 +1,17 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.model + +enum class RegExValidations(val regex: Regex) { + BRITISH_DECIMAL_NOTATION("""^(?!\.)(?!.*-[^0-9])(?!(?:[^.]*\.){3})[-0-9]*(?:\.[0-9]*)?$""".toRegex()), + EUROPEAN_DECIMAL_NOTATION("""^(?!.*,.+,|.*-.*-)[0-9,-]*$""".toRegex()), + ONLY_INTEGERS("^-?(?!0)\\d*".toRegex()), + SINGLE_LETTER("^[^\\d.,;!?\\s]$".toRegex()), + NEGATIVE_INTEGERS("^(?!0)\\d*".toRegex()), + PERCENTAGE("^([1-9]|[1-9][0-9]|100)\$".toRegex()), + POSITIVE_INTEGER("^(?!0)\\d*".toRegex()), + POSITIVE_INTEGER_OR_ZERO("^(0|[1-9]\\d*)\$".toRegex()), + PHONE_NUMBER("^[+0-9-()]+$".toRegex()), + LINK("((https?|ftp|smtp)://)?(www\\.)?[a-zA-Z0-9@:%._+~#=-]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&/=-]*)".toRegex()), + EMAIL("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}\$".toRegex()), + DATE_TIME("^[0-9]+$".toRegex()), + UNIT_INTERVAL_BETWEEN_0_AND_1("^(0?(\\.\\d*?)?|1(\\.0+)?)\$".toRegex()), +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/TimeTransformation.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/TimeTransformation.kt new file mode 100644 index 000000000..96640e08e --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/model/TimeTransformation.kt @@ -0,0 +1,65 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.model + +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.input.OffsetMapping +import androidx.compose.ui.text.input.TransformedText +import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles + +class TimeTransformation : DateTimeVisualTransformation { + + companion object { + private const val SEPARATOR = ":" + + // Check the usages before modifying + internal const val TIME_MASK = "HHMM" + } + + override val maskLength: Int + get() = TIME_MASK.length + + override fun filter(text: AnnotatedString): TransformedText { + return timeFilter(text) + } + + private fun timeFilter(text: AnnotatedString): TransformedText { + val trimmed = if (text.text.length > TIME_MASK.length) text.text.substring(0..TIME_MASK.length) else text.text + val output = buildAnnotatedString { + for (i in TIME_MASK.indices) { + val timeChar = trimmed.getOrNull(i) + if (timeChar == null) { + append(AnnotatedString(TIME_MASK[i].toString(), DHIS2SCustomTextStyles.inputFieldHelper)) + } else { + append(trimmed[i]) + } + + if (i == 1) { + val separator = if (timeChar != null) { + SEPARATOR + } else { + AnnotatedString(SEPARATOR, DHIS2SCustomTextStyles.inputFieldHelper) + } + append(separator) + } + } + } + + val offsetMapping = object : OffsetMapping { + override fun originalToTransformed(offset: Int): Int { + if (trimmed.lastIndex >= 0) { + if (offset <= 1) return offset + return offset + 1 + } else { + return 0 + } + } + + override fun transformedToOriginal(offset: Int): Int { + if (offset > text.length) return text.length + return offset + } + } + + return TransformedText(output, offsetMapping) + } +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/state/InputDateTimeState.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/state/InputDateTimeState.kt index e5ddb5df3..efbb2a0ec 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/state/InputDateTimeState.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/state/InputDateTimeState.kt @@ -11,7 +11,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.InputStyle import org.hisp.dhis.mobile.ui.designsystem.component.LegendData import org.hisp.dhis.mobile.ui.designsystem.component.SelectableDates import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextData -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTimeVisualTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTimeVisualTransformation @Stable interface InputDateTimeState { diff --git a/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt b/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt index f3cd01e8d..21adb180b 100644 --- a/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt +++ b/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/Keyboard.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @Composable -actual fun keyboardAsState(): State { +internal actual fun keyboardAsState(): State { val keyboardState = remember { mutableStateOf(Keyboard.Closed) } return keyboardState } diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTimeTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTimeTest.kt index e2aeb3456..a69b4b8f6 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTimeTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTimeTest.kt @@ -9,8 +9,8 @@ import androidx.compose.ui.text.input.TextFieldValue import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionType import org.hisp.dhis.mobile.ui.designsystem.component.InputDateTime import org.hisp.dhis.mobile.ui.designsystem.component.SelectableDates -import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation -import org.hisp.dhis.mobile.ui.designsystem.component.internal.TimeTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation +import org.hisp.dhis.mobile.ui.designsystem.component.model.TimeTransformation import org.hisp.dhis.mobile.ui.designsystem.component.state.InputDateTimeData import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputDateTimeState import org.junit.Rule diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt index 2c03a5222..c8d9b9165 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputMatrixTest.kt @@ -7,7 +7,6 @@ import androidx.compose.ui.test.isNotEnabled import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithTag import androidx.compose.ui.test.onNodeWithTag -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.junit.Rule import org.junit.Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt index e04fdb3e0..8ab068cb9 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt @@ -7,7 +7,6 @@ import androidx.compose.ui.test.isNotEnabled import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithTag import androidx.compose.ui.test.onNodeWithTag -import org.hisp.dhis.mobile.ui.designsystem.component.internal.ImageCardData import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.junit.Rule import org.junit.Test diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeTransformationTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeTransformationTest.kt index 9af3aad32..bddf69b2f 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeTransformationTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeTransformationTest.kt @@ -1,6 +1,7 @@ package org.hisp.dhis.mobile.ui.designsystem.component.internal import androidx.compose.ui.text.AnnotatedString +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTimeTransformation import org.junit.Test class DateTimeTransformationTest { diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTransformationTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTransformationTest.kt index 4c606285f..5954eefea 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTransformationTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTransformationTest.kt @@ -1,6 +1,7 @@ package org.hisp.dhis.mobile.ui.designsystem.component.internal import androidx.compose.ui.text.AnnotatedString +import org.hisp.dhis.mobile.ui.designsystem.component.model.DateTransformation import org.junit.Test class DateTransformationTest { diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/TimeTransformationTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/TimeTransformationTest.kt index b968d9e0f..3c72a289d 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/TimeTransformationTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/TimeTransformationTest.kt @@ -1,6 +1,7 @@ package org.hisp.dhis.mobile.ui.designsystem.component.internal import androidx.compose.ui.text.AnnotatedString +import org.hisp.dhis.mobile.ui.designsystem.component.model.TimeTransformation import org.junit.Test class TimeTransformationTest {