You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* expect a formatted value to be UTC
* make BaseFieldState generic
* make DateTimeFieldState vary with Instant?
make DateTimeField work with Instant, not Long.
* only support date time text field value changes that clear the text.
* PR review suggestions
* fuse usage of formattedValue and value into one type safe generic function
---------
Co-authored-by: Soren Roth <[email protected]>
Copy file name to clipboardExpand all lines: toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/components/codedvalue/CodedValueFieldState.kt
Copy file name to clipboardExpand all lines: toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/components/codedvalue/RadioButtonFieldState.kt
Copy file name to clipboardExpand all lines: toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/components/codedvalue/SwitchFieldState.kt
Copy file name to clipboardExpand all lines: toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/components/datetime/DateTimeField.kt
+8-5
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ internal fun DateTimeField(
50
50
) {
51
51
val isEditable by state.isEditable.collectAsState()
52
52
val isRequired by state.isRequired.collectAsState()
53
-
valepochMillis by state.epochMillis.collectAsState()
53
+
valinstant by state.value.collectAsState()
54
54
val interactionSource = remember { MutableInteractionSource() }
55
55
// to check if the field was ever focused by the user
56
56
var wasFocused by rememberSaveable { mutableStateOf(false) }
@@ -61,9 +61,12 @@ internal fun DateTimeField(
61
61
}
62
62
63
63
BaseTextField(
64
-
text =epochMillis?.formattedDateTime(state.shouldShowTime) ?:"",
64
+
text =instant?.formattedDateTime(state.shouldShowTime) ?:"",
65
65
onValueChange = {
66
-
state.onValueChanged(it)
66
+
// the only allowable change is to clear the text
67
+
if (it.isEmpty()) {
68
+
state.onValueChanged(null)
69
+
}
67
70
},
68
71
modifier = modifier,
69
72
readOnly =true,
@@ -75,7 +78,7 @@ internal fun DateTimeField(
75
78
trailingIcon =Icons.Rounded.EditCalendar,
76
79
supportingText = {
77
80
// if the field was focused and is required, validate the current value
78
-
if (wasFocused && isRequired &&epochMillis==null) {
81
+
if (wasFocused && isRequired &&instant==null) {
79
82
Text(
80
83
text = stringResource(id =R.string.required),
81
84
color =MaterialTheme.colorScheme.error
@@ -111,7 +114,7 @@ private fun DateTimeFieldPreview() {
111
114
label ="Launch Date and Time",
112
115
placeholder ="",
113
116
description ="Enter the date for apollo 11 launch",
Copy file name to clipboardExpand all lines: toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/components/datetime/DateTimeFieldState.kt
0 commit comments