Skip to content

Commit

Permalink
refactor(clear-buttons): change behavior from hiding to enabling
Browse files Browse the repository at this point in the history
  • Loading branch information
Zafouche committed Dec 18, 2024
1 parent 70edeb9 commit c8514d7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,16 @@ private fun UserTextFields(
},
value = firstName,
trailingIcon = {
if (firstName.isNotEmpty()) {
IconButton(
onClick = { onFirstNameChange("") },
modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_first_name))
}
}
IconButton(
onClick = { onFirstNameChange("") },
enabled = firstName.isNotEmpty(),
modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_first_name))
}
})

OutlinedTextField(
Expand Down Expand Up @@ -357,17 +356,16 @@ private fun UserTextFields(
},
value = lastName,
trailingIcon = {
if (lastName.isNotEmpty()) {
IconButton(
onClick = { onLastNameChange("") },
modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_last_name))
}
}
IconButton(
onClick = { onLastNameChange("") },
enabled = lastName.isNotEmpty(),
modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_last_name))
}
})

OutlinedTextField(
Expand Down
48 changes: 23 additions & 25 deletions app/src/main/java/com/android/unio/ui/event/EventCreation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,16 @@ fun EventCreationScreen(
}
},
trailingIcon = {
if (name.isNotEmpty()) {
IconButton(
onClick = { name = "" },
modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.event_creation_content_description_clear_title))
}
}
IconButton(
onClick = { name = "" },
enabled = name.isNotEmpty(),
modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.event_creation_content_description_clear_title))
}
})

OutlinedTextField(
Expand Down Expand Up @@ -194,20 +193,19 @@ fun EventCreationScreen(
}
},
trailingIcon = {
if (shortDescription.isNotEmpty()) {
IconButton(
onClick = { shortDescription = "" },
modifier =
Modifier.testTag(
EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string
.event_creation_content_description_clear_short_description))
}
}
IconButton(
onClick = { shortDescription = "" },
enabled = shortDescription.isNotEmpty(),
modifier =
Modifier.testTag(
EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string
.event_creation_content_description_clear_short_description))
}
})

BannerImagePicker(
Expand Down
45 changes: 21 additions & 24 deletions app/src/main/java/com/android/unio/ui/event/EventEdit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,16 @@ fun EventEditScreen(
onValueChange = { name = it },
label = { Text(context.getString(R.string.event_creation_name_label)) },
trailingIcon = {
if (name.isNotEmpty()) {
IconButton(
onClick = { name = "" },
modifier = Modifier.testTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.event_creation_content_description_clear_title))
}
}
IconButton(
onClick = { name = "" },
enabled = name.isNotEmpty(),
modifier = Modifier.testTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.event_creation_content_description_clear_title))
}
})

OutlinedTextField(
Expand All @@ -174,19 +173,17 @@ fun EventEditScreen(
onValueChange = { shortDescription = it },
label = { Text(context.getString(R.string.event_creation_short_description_label)) },
trailingIcon = {
if (shortDescription.isNotEmpty()) {
IconButton(
onClick = { shortDescription = "" },
modifier =
Modifier.testTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string
.event_creation_content_description_clear_short_description))
}
}
IconButton(
onClick = { shortDescription = "" },
enabled = shortDescription.isNotEmpty(),
modifier = Modifier.testTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string
.event_creation_content_description_clear_short_description))
}
})

BannerImagePicker(
Expand Down
40 changes: 18 additions & 22 deletions app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,15 @@ private fun EditUserTextFields(
},
value = firstName,
trailingIcon = {
if (firstName.isNotEmpty()) {
IconButton(
onClick = { onFirstNameChange("") },
modifier = Modifier.testTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.user_edition_content_description_clear_first_name))
}
}
IconButton(
onClick = { onFirstNameChange("") },
enabled = firstName.isNotEmpty(),
modifier = Modifier.testTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(R.string.user_edition_content_description_clear_first_name))
}
})

OutlinedTextField(
Expand Down Expand Up @@ -454,17 +452,15 @@ private fun EditUserTextFields(
},
value = lastName,
trailingIcon = {
if (lastName.isNotEmpty()) {
IconButton(
onClick = { onLastNameChange("") },
modifier = Modifier.testTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.user_edition_content_description_clear_last_name))
}
}
IconButton(
onClick = { onLastNameChange("") },
enabled = lastName.isNotEmpty(),
modifier = Modifier.testTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(R.string.user_edition_content_description_clear_last_name))
}
})

OutlinedTextField(
Expand Down

0 comments on commit c8514d7

Please sign in to comment.