Skip to content

Commit e71a65b

Browse files
sorenoidSoren Roth
andauthored
replace clear button on required date time fields (#351)
* replace clear button from required date time fields with date time picker dialog button * just use the edit calendar icon. --------- Co-authored-by: Soren Roth <sor10874@esri.com>
1 parent 7c6ab07 commit e71a65b

File tree

2 files changed

+16
-6
lines changed
  • toolkit/featureforms/src

2 files changed

+16
-6
lines changed

toolkit/featureforms/src/androidTest/java/com/arcgismaps/toolkit/featureforms/DateTimeFieldTests.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class DateTimeFieldTests {
117117
"expected helper text: Date Entry is Required"
118118

119119
}
120-
val iconMatcher = hasContentDescription("field icon")
120+
val iconMatcher = hasContentDescription("date time picker button")
121121
assert(iconMatcher.matches(dateTimeField.fetchSemanticsNode()))
122122
}
123123

@@ -136,7 +136,7 @@ class DateTimeFieldTests {
136136
val col = composeTestRule.onNodeWithContentDescription("lazy column")
137137
col.performScrollToIndex(8)
138138
val dateTimeField = composeTestRule.onNodeWithText("${formElement.label} *")
139-
val iconMatcher = hasContentDescription("field icon")
139+
val iconMatcher = hasContentDescription("date time picker button")
140140
assert(iconMatcher.matches(dateTimeField.fetchSemanticsNode()))
141141
dateTimeField.assertHasClickAction()
142142
dateTimeField.performClick()
@@ -150,7 +150,6 @@ class DateTimeFieldTests {
150150
helperTextInDialog.assertIsDisplayed()
151151
}
152152

153-
154153
/**
155154
* Given a FieldFormElement with an editable datetime input
156155
* When the date value is displayed

toolkit/featureforms/src/main/java/com/arcgismaps/toolkit/featureforms/internal/components/datetime/DateTimeField.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ package com.arcgismaps.toolkit.featureforms.internal.components.datetime
2121
import androidx.compose.foundation.interaction.MutableInteractionSource
2222
import androidx.compose.foundation.interaction.PressInteraction
2323
import androidx.compose.material.icons.Icons
24-
import androidx.compose.material.icons.rounded.CalendarMonth
2524
import androidx.compose.material.icons.rounded.EditCalendar
25+
import androidx.compose.material3.Icon
2626
import androidx.compose.material3.MaterialTheme
2727
import androidx.compose.runtime.Composable
2828
import androidx.compose.runtime.LaunchedEffect
@@ -76,8 +76,19 @@ internal fun DateTimeField(
7676
isRequired = isRequired,
7777
singleLine = true,
7878
interactionSource = interactionSource,
79-
trailingIcon = if (isEditable) Icons.Rounded.EditCalendar else Icons.Rounded.CalendarMonth,
80-
onFocusChange = state::onFocusChanged
79+
trailingIcon = Icons.Rounded.EditCalendar,
80+
onFocusChange = state::onFocusChanged,
81+
trailingContent =
82+
if (isRequired) {
83+
{
84+
Icon(
85+
imageVector = Icons.Rounded.EditCalendar,
86+
contentDescription = "date time picker button"
87+
)
88+
}
89+
} else {
90+
null
91+
}
8192
)
8293

8394
LaunchedEffect(interactionSource) {

0 commit comments

Comments
 (0)