diff --git a/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt b/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt index 9fee81460..4cc9abe49 100644 --- a/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt @@ -1,8 +1,11 @@ package com.android.unio.components.authentication +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertTextContains +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick @@ -125,6 +128,27 @@ class AccountDetailsTest : TearDown() { .assertTextContains("I am a student") } + @Test + fun testClearButtonFunctionality() { + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD) + .performTextInput("John") + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals("John", includeEditableText = true) + composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText("")) + + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD) + .performTextInput("Doe") + composeTestRule + .onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals("Doe", includeEditableText = true) + composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD).assert(hasText("")) + } + @Test fun testInterestsButtonWorksCorrectly() { composeTestRule diff --git a/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt b/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt index fa43c131e..83bc56ecd 100644 --- a/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/event/EventCreationTest.kt @@ -1,7 +1,9 @@ package com.android.unio.components.event +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag @@ -281,6 +283,48 @@ class EventCreationTest : TearDown() { composeTestRule.onNodeWithTag(EventCreationTestTags.DESCRIPTION).performTextClearance() } + @Test + fun testClearButtonFunctionality() { + nominatimLocationSearchViewModel = + NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality) + composeTestRule.setContent { + EventCreationScreen( + navigationAction, + searchViewModel, + associationViewModel, + eventViewModel, + nominatimLocationSearchViewModel) + } + + composeTestRule.waitForIdle() + + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_TITLE) + .performScrollTo() + .performTextClearance() + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).performTextInput("Test Title") + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_TITLE, useUnmergedTree = true) + .assertTextEquals("Test Title", includeEditableText = true) + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).assert(hasText("")) + + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION) + .performScrollTo() + .performTextClearance() + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION) + .performTextInput("Test Short Description") + composeTestRule + .onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION, useUnmergedTree = true) + .assertTextEquals("Test Short Description", includeEditableText = true) + composeTestRule + .onNodeWithTag(EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON) + .performClick() + composeTestRule.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION).assert(hasText("")) + } + @Test fun testLocationInputFunctionality() { server = MockWebServer() diff --git a/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt b/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt index 10aa61e0d..488788606 100644 --- a/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt +++ b/app/src/androidTest/java/com/android/unio/components/event/EventEditTests.kt @@ -1,13 +1,17 @@ package com.android.unio.components.event +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotEnabled +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextClearance +import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTextReplacement import com.android.unio.TearDown import com.android.unio.assertDisplayComponentInScroll @@ -281,4 +285,42 @@ class EventEditTests : TearDown() { assert(result.title != mockEvent.title) assert(result.description == mockEvent.description) } + + @Test + fun testClearButtonFunctionality() { + nominatimLocationSearchViewModel = + NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality) + composeTestRule.setContent { + EventEditScreen( + navigationAction, + searchViewModel, + associationViewModel, + eventViewModel, + nominatimLocationSearchViewModel) + } + + composeTestRule + .onNodeWithTag(EventEditTestTags.EVENT_TITLE) + .performScrollTo() + .performTextClearance() + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).performTextInput("New Event Title") + composeTestRule + .onNodeWithTag(EventEditTestTags.EVENT_TITLE, useUnmergedTree = true) + .assertTextEquals("New Event Title", includeEditableText = true) + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).assert(hasText("")) + + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION) + .performScrollTo() + .performTextClearance() + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION) + .performTextInput("New Short Description") + composeTestRule + .onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION, useUnmergedTree = true) + .assertTextEquals("New Short Description", includeEditableText = true) + composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION).assert(hasText("")) + } } diff --git a/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt b/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt index c37d5ad69..31f84a5a6 100644 --- a/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt +++ b/app/src/androidTest/java/com/android/unio/components/user/UserProfileEditionTest.kt @@ -2,8 +2,11 @@ package com.android.unio.components.user import android.net.ConnectivityManager import android.net.Network +import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.assertTextEquals +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick @@ -313,6 +316,29 @@ class UserProfileEditionTest : TearDown() { composeTestRule.onNodeWithTag(UserEditionTestTags.BIOGRAPHY_TEXT_FIELD).performTextClearance() } + @Test + fun testClearButtonFunctionality() { + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).performTextClearance() + composeTestRule + .onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD) + .performTextInput(UserUpdate.FIRST_NAME) + composeTestRule + .onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals(UserUpdate.FIRST_NAME, includeEditableText = true) + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText("")) + + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).performTextClearance() + composeTestRule + .onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD) + .performTextInput(UserUpdate.LAST_NAME) + composeTestRule + .onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true) + .assertTextEquals(UserUpdate.LAST_NAME, includeEditableText = true) + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON).performClick() + composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).assert(hasText("")) + } + object UserUpdate { const val FIRST_NAME = "Johnny" const val LAST_NAME = "Däpp" diff --git a/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt b/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt index cdb33cc8c..7ffbcf48a 100644 --- a/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt +++ b/app/src/androidTest/java/com/android/unio/end2end/EventCreationE2ETest.kt @@ -121,7 +121,7 @@ class EventCreationE2ETest : EndToEndTest() { val dateToSelect = LocalDate.of(currentDate.year, currentDate.month, day) val dateString = dateToSelect.format(dateFormatter) - composeTestRule.onNodeWithText(dateString, true).performClick() + composeTestRule.onNodeWithText(text = dateString, substring = true).performClick() composeTestRule .onNodeWithText(context.getString(R.string.event_creation_dialog_ok)) diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt index 0536ab5af..bf8ab87dd 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/authentication/AuthenticationTestTags.kt @@ -10,12 +10,14 @@ object AccountDetailsTestTags { const val FIRST_NAME_TEXT = "accountDetailsFirstNameText" const val FIRST_NAME_ERROR_TEXT = "accountDetailsFirstNameErrorText" const val FIRST_NAME_CHARACTER_COUNTER = "accountDetailsFirstNameCharacterCounter" + const val FIRST_NAME_CLEAR_BUTTON = "accountDetailsFirstNameClearButton" // LAST NAME TEXT FIELD const val LAST_NAME_TEXT_FIELD = "accountDetailsLastNameTextField" const val LAST_NAME_TEXT = "accountDetailsLastNameText" const val LAST_NAME_ERROR_TEXT = "accountDetailsLastNameErrorText" const val LAST_NAME_CHARACTER_COUNTER = "accountDetailsLastNameCharacterCounter" + const val LAST_NAME_CLEAR_BUTTON = "accountDetailsLastNameClearButton" // BIOGRAPHY TEXT FIELD const val BIOGRAPHY_TEXT_FIELD = "accountDetailsBioTextField" diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt index 3b41aec7a..50a5fba41 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/event/EventTestTags.kt @@ -17,7 +17,9 @@ object EventCreationTestTags { const val SCREEN = "eventCreationScreen" const val TITLE = "eventCreationTitle" const val EVENT_TITLE = "eventCreationEventTitle" + const val EVENT_TITLE_CLEAR_BUTTON = "eventCreationEventTitleClearButton" const val SHORT_DESCRIPTION = "eventCreationShortDescription" + const val EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON = "eventCreationShortDescriptionClearButton" const val COAUTHORS = "eventCreationCoauthors" const val TAGGED_ASSOCIATIONS = "eventCreationTaggedAssociations" const val DESCRIPTION = "eventCreationDescription" @@ -56,7 +58,9 @@ object EventEditTestTags { const val SCREEN = "eventEditScreen" const val TITLE = "eventEditTitle" const val EVENT_TITLE = "eventEditEventTitle" + const val EVENT_TITLE_CLEAR_BUTTON = "eventEditEventTitleClearButton" const val SHORT_DESCRIPTION = "eventEditShortDescription" + const val SHORT_DESCRIPTION_CLEAR_BUTTON = "eventEditShortDescriptionClearButton" const val COAUTHORS = "eventEditCoauthors" const val TAGGED_ASSOCIATIONS = "eventEditTaggedAssociations" const val DESCRIPTION = "eventEditDescription" diff --git a/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt b/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt index 73ad53b61..988e47fcb 100644 --- a/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt +++ b/app/src/main/java/com/android/unio/model/strings/test_tags/user/UserEditionTestTags.kt @@ -10,12 +10,14 @@ object UserEditionTestTags { const val FIRST_NAME_TEXT = "userSettingsFirstNameText" const val FIRST_NAME_ERROR_TEXT = "userSettingsFirstNameErrorText" const val FIRST_NAME_CHARACTER_COUNTER = "userSettingsFirstNameCharacterCounter" + const val FIRST_NAME_CLEAR_BUTTON = "userSettingsFirstNameClearButton" // LAST NAME TEXT FIELD const val LAST_NAME_TEXT_FIELD = "userSettingsLastNameTextField" const val LAST_NAME_TEXT = "userSettingsLastNameText" const val LAST_NAME_ERROR_TEXT = "userSettingsLastNameErrorText" const val LAST_NAME_CHARACTER_COUNTER = "userSettingsLastNameCharacterCounter" + const val LAST_NAME_CLEAR_BUTTON = "userSettingsLastNameClearButton" // BIOGRAPHY TEXT FIELD const val BIOGRAPHY_TEXT_FIELD = "userSettingsBioTextField" diff --git a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt index 8ff2c93b3..a85189536 100644 --- a/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt +++ b/app/src/main/java/com/android/unio/ui/authentication/AccountDetails.kt @@ -15,8 +15,10 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold @@ -306,7 +308,19 @@ private fun UserTextFields( onFirstNameChange(it) } }, - value = firstName) + value = firstName, + trailingIcon = { + 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( modifier = @@ -340,7 +354,19 @@ private fun UserTextFields( onLastNameChange(it) } }, - value = lastName) + value = lastName, + trailingIcon = { + 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( modifier = diff --git a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt index 424dbd2bc..dbc1afd62 100644 --- a/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt +++ b/app/src/main/java/com/android/unio/ui/components/EventEditComponents.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccessTime import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.DateRange +import androidx.compose.material.icons.outlined.LocationOn import androidx.compose.material3.AlertDialog import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog @@ -122,7 +123,12 @@ fun NominatimLocationPicker( }, label = { Text(context.getString(R.string.event_creation_location_label)) }, placeholder = { Text(context.getString(R.string.event_creation_location_input_label)) }, - modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag)) + modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag), + trailingIcon = { + Icon( + imageVector = Icons.Outlined.LocationOn, + contentDescription = context.getString(R.string.event_creation_location_icon)) + }) DropdownMenu( expanded = showDropdown && locationSuggestions.isNotEmpty(), diff --git a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt index cad4d1ded..f1721c76b 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventCreation.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventCreation.kt @@ -14,6 +14,8 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear +import androidx.compose.material.icons.rounded.Clear import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -145,6 +147,18 @@ fun EventCreationScreen( Modifier.testTag(EventCreationTestTags.TITLE_CHARACTER_COUNTER)) } } + }, + trailingIcon = { + 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( @@ -177,6 +191,21 @@ fun EventCreationScreen( EventCreationTestTags.SHORT_DESCRIPTION_CHARACTER_COUNTER)) } } + }, + trailingIcon = { + 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( diff --git a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt index e76a4ad7c..9247721e7 100644 --- a/app/src/main/java/com/android/unio/ui/event/EventEdit.kt +++ b/app/src/main/java/com/android/unio/ui/event/EventEdit.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon @@ -146,7 +147,19 @@ fun EventEditScreen( } }, onValueChange = { name = it }, - label = { Text(context.getString(R.string.event_creation_name_label)) }) + label = { Text(context.getString(R.string.event_creation_name_label)) }, + trailingIcon = { + 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( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.SHORT_DESCRIPTION), @@ -158,7 +171,20 @@ fun EventEditScreen( } }, onValueChange = { shortDescription = it }, - label = { Text(context.getString(R.string.event_creation_short_description_label)) }) + label = { Text(context.getString(R.string.event_creation_short_description_label)) }, + trailingIcon = { + 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( eventBannerUri, modifier = Modifier.testTag(EventEditTestTags.EVENT_IMAGE)) diff --git a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt index 3cce112f7..4af4a7553 100644 --- a/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt +++ b/app/src/main/java/com/android/unio/ui/user/UserProfileEdition.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card @@ -406,7 +407,18 @@ private fun EditUserTextFields( onFirstNameChange(it) } }, - value = firstName) + value = firstName, + trailingIcon = { + 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( modifier = @@ -440,7 +452,18 @@ private fun EditUserTextFields( onLastNameChange(it) } }, - value = lastName) + value = lastName, + trailingIcon = { + 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( modifier = diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 4a73650a3..055e119fd 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -103,6 +103,8 @@ Icône de liens Photo de profile Supprimer la photo de profil + Effacer prénom + Effacer nom Supprimer le compte @@ -121,8 +123,8 @@ Annuler vos modifications Sauvegarder vos modifications Changements correctement modifiés - - + Effacer prénom + Effacer nom Échec de l\'actualisation @@ -213,6 +215,9 @@ Entrez un nom d\'événement Entrez une courte description de l\'événement Entrez une description de l\'événement + Effacer titre + Effacer description courte + Icône de localisation Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5f70620c5..6b8e6d412 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -109,6 +109,8 @@ Links icon Profile Picture Remove Profile Picture + Clear first name + Clear last name Remove User Social @@ -127,6 +129,8 @@ Failed to delete account, try again later Deleted user offline Please be connected to the internet to delete your Account + Clear first name + Clear last name @@ -217,6 +221,9 @@ Enter an event name Enter an event short description Enter an event description + Clear title + Clear short description + Location icon Edit