From 4fa34777b6d88b34bce49d006b9be1706edc5773 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Dec 2024 10:27:40 +0100 Subject: [PATCH 1/8] fix(EventEdition): add highlight for name field --- app/src/main/java/com/android/unio/ui/event/EventEdit.kt | 6 ++++++ app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 8 insertions(+) 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 7f26a2afb..9af6e9b91 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 @@ -139,6 +139,12 @@ fun EventEditScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.EVENT_TITLE), value = name, + isError = name.isEmpty(), + supportingText = { + if (name.isEmpty()) { + context.getString(R.string.event_creation_name_error) + } + }, onValueChange = { name = it }, label = { Text(context.getString(R.string.event_creation_name_label)) }) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f25249eaa..d408991c7 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -210,6 +210,7 @@ Entrez une addresse Plus… + Entrez un nom d\'événement Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4926a2889..8d115c7c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -214,6 +214,7 @@ Enter an address More… + Enter an event name Edit From 17937ce3d4eda77e300200c3263942b3b612f56c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Dec 2024 10:35:22 +0100 Subject: [PATCH 2/8] fix(EventEdition): add trim to text input --- app/src/main/java/com/android/unio/ui/event/EventEdit.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 9af6e9b91..5e1eb0e0d 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 @@ -83,9 +83,9 @@ fun EventEditScreen( val eventToEdit = remember { eventViewModel.selectedEvent.value!! } - var name by remember { mutableStateOf(eventToEdit.title) } - var shortDescription by remember { mutableStateOf(eventToEdit.catchyDescription) } - var longDescription by remember { mutableStateOf(eventToEdit.description) } + var name by remember { mutableStateOf(eventToEdit.title.trim()) } + var shortDescription by remember { mutableStateOf(eventToEdit.catchyDescription.trim()) } + var longDescription by remember { mutableStateOf(eventToEdit.description.trim()) } var coauthorsAndBoolean = associationViewModel.associations.collectAsState().value.map { From e0b9f55f151b23198bb473adacb5ab5cdcede348 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Dec 2024 10:44:39 +0100 Subject: [PATCH 3/8] fix(EventEdition): add highlight and text for text inputs --- .../java/com/android/unio/ui/event/EventEdit.kt | 14 +++++++++++++- app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) 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 5e1eb0e0d..e76a4ad7c 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 @@ -142,7 +142,7 @@ fun EventEditScreen( isError = name.isEmpty(), supportingText = { if (name.isEmpty()) { - context.getString(R.string.event_creation_name_error) + Text(context.getString(R.string.event_creation_name_error)) } }, onValueChange = { name = it }, @@ -151,6 +151,12 @@ fun EventEditScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.SHORT_DESCRIPTION), value = shortDescription, + isError = shortDescription.isEmpty(), + supportingText = { + if (shortDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_short_description_error)) + } + }, onValueChange = { shortDescription = it }, label = { Text(context.getString(R.string.event_creation_short_description_label)) }) @@ -184,6 +190,12 @@ fun EventEditScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventEditTestTags.DESCRIPTION), value = longDescription, + isError = longDescription.isEmpty(), + supportingText = { + if (longDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_description_error)) + } + }, onValueChange = { longDescription = it }, label = { Text(context.getString(R.string.event_creation_description_label)) }) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d408991c7..9e6914e94 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -211,6 +211,8 @@ Plus… Entrez un nom d\'événement + Entrez une courte description de l\'événement + Entrez une description de l\'événement Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d115c7c1..0eccaf0cf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -215,6 +215,8 @@ More… Enter an event name + Enter an event short description + Enter an event description Edit From b35e1756af305cb983295723241a0394e4646334 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Dec 2024 11:01:57 +0100 Subject: [PATCH 4/8] fix: add highlight on missing input for date picker --- .../unio/ui/components/EventEditComponents.kt | 12 ++++++++++++ app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 16 insertions(+) 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 d16f74fc3..9b203d1d6 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 @@ -271,6 +271,12 @@ fun DateAndTimePicker( ?: "", readOnly = true, onValueChange = {}, + isError = selectedDate == null && initialDate == null, + supportingText = { + if (selectedDate == null && initialDate == null) { + Text(context.getString(R.string.event_edit_date_error)) + } + }, trailingIcon = { Icon( Icons.Default.DateRange, @@ -299,6 +305,12 @@ fun DateAndTimePicker( ?: "", readOnly = true, onValueChange = {}, + isError = selectedTime == null && initialTime == null, + supportingText = { + if (selectedTime == null && initialTime == null) { + Text(context.getString(R.string.event_edit_time_error)) + } + }, trailingIcon = { Icon( Icons.Default.AccessTime, diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9e6914e94..4413227d4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -223,6 +223,8 @@ Sélectionner une date Sélectionner une heure + La date est manquante + L\'heure est manquante Continuez à taper pour voir plus de résultats diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0eccaf0cf..1e7b0bb4f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -227,6 +227,8 @@ Select date Select time + Date is missing + Time is missing Continue typing to see more results From 553191084dabb815037e76981a2466ce82980b5f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2024 11:15:32 +0100 Subject: [PATCH 5/8] fix: highlight input error for location edit event --- .../unio/ui/components/EventEditComponents.kt | 15 +++++++++++++++ app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 17 insertions(+) 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 9b203d1d6..f65d4593b 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 @@ -41,6 +41,7 @@ import androidx.compose.material3.rememberTimePickerState import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -97,15 +98,28 @@ fun NominatimLocationPicker( var showDropdown by remember { mutableStateOf(false) } var shouldDisplayInitialLocation by remember { mutableStateOf(true) } + var selectedLocation by remember { mutableStateOf(initialLocation) } + val isError by remember { + derivedStateOf { + selectedLocation == null || selectedLocation!!.name.isEmpty() && locationQuery.isEmpty() + } + } Box(modifier = Modifier.fillMaxWidth()) { OutlinedTextField( value = if (shouldDisplayInitialLocation) initialLocation?.name ?: "" else locationQuery, onValueChange = { locationSearchViewModel.setQuery(it) + selectedLocation = null shouldDisplayInitialLocation = false showDropdown = true }, + isError = isError, + supportingText = { + if (isError) { + Text(context.getString(R.string.event_edit_location_error)) + } + }, 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)) @@ -129,6 +143,7 @@ fun NominatimLocationPicker( }, onClick = { locationSearchViewModel.setQuery(location.name) + selectedLocation = location onLocationSelected(location) showDropdown = false }, diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 4413227d4..4a73650a3 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -225,6 +225,7 @@ Sélectionner une heure La date est manquante L\'heure est manquante + Localisation erronée Continuez à taper pour voir plus de résultats diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e7b0bb4f..5f70620c5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -229,6 +229,7 @@ Select time Date is missing Time is missing + Wrong location input Continue typing to see more results From b7e63c72af649a8e1f4785621a86927ee1db71be Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2024 11:19:32 +0100 Subject: [PATCH 6/8] fix: highlight input error for event creation --- .../com/android/unio/ui/event/EventCreation.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 a6f1c2ba7..de91ba0c4 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 @@ -119,6 +119,12 @@ fun EventCreationScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventCreationTestTags.EVENT_TITLE), value = name, + isError = name.isEmpty(), + supportingText = { + if (name.isEmpty()) { + Text(context.getString(R.string.event_creation_name_error)) + } + }, onValueChange = { if (Utils.checkInputLength(it, TextLength.SMALL)) { name = it @@ -144,6 +150,12 @@ fun EventCreationScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventCreationTestTags.SHORT_DESCRIPTION), value = shortDescription, + isError = shortDescription.isEmpty(), + supportingText = { + if (shortDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_short_description_error)) + } + }, onValueChange = { if (Utils.checkInputLength(it, TextLength.MEDIUM)) { shortDescription = it @@ -197,6 +209,11 @@ fun EventCreationScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventCreationTestTags.DESCRIPTION), value = longDescription, + supportingText = { + if (longDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_description_error)) + } + }, onValueChange = { if (Utils.checkInputLength(it, TextLength.LARGE)) { longDescription = it From 94650a26a0e0628734480087613db9141dc279bb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2024 11:21:19 +0100 Subject: [PATCH 7/8] style: format code using ktfmt --- .../unio/ui/components/EventEditComponents.kt | 12 ++++++------ .../com/android/unio/ui/event/EventCreation.kt | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) 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 f65d4593b..424dbd2bc 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 @@ -98,11 +98,11 @@ fun NominatimLocationPicker( var showDropdown by remember { mutableStateOf(false) } var shouldDisplayInitialLocation by remember { mutableStateOf(true) } - var selectedLocation by remember { mutableStateOf(initialLocation) } + var selectedLocation by remember { mutableStateOf(initialLocation) } val isError by remember { - derivedStateOf { - selectedLocation == null || selectedLocation!!.name.isEmpty() && locationQuery.isEmpty() - } + derivedStateOf { + selectedLocation == null || selectedLocation!!.name.isEmpty() && locationQuery.isEmpty() + } } Box(modifier = Modifier.fillMaxWidth()) { @@ -110,7 +110,7 @@ fun NominatimLocationPicker( value = if (shouldDisplayInitialLocation) initialLocation?.name ?: "" else locationQuery, onValueChange = { locationSearchViewModel.setQuery(it) - selectedLocation = null + selectedLocation = null shouldDisplayInitialLocation = false showDropdown = true }, @@ -143,7 +143,7 @@ fun NominatimLocationPicker( }, onClick = { locationSearchViewModel.setQuery(location.name) - selectedLocation = location + selectedLocation = location onLocationSelected(location) showDropdown = false }, 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 de91ba0c4..6c034c9df 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 @@ -121,9 +121,9 @@ fun EventCreationScreen( value = name, isError = name.isEmpty(), supportingText = { - if (name.isEmpty()) { - Text(context.getString(R.string.event_creation_name_error)) - } + if (name.isEmpty()) { + Text(context.getString(R.string.event_creation_name_error)) + } }, onValueChange = { if (Utils.checkInputLength(it, TextLength.SMALL)) { @@ -152,9 +152,9 @@ fun EventCreationScreen( value = shortDescription, isError = shortDescription.isEmpty(), supportingText = { - if (shortDescription.isEmpty()) { - Text(context.getString(R.string.event_creation_short_description_error)) - } + if (shortDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_short_description_error)) + } }, onValueChange = { if (Utils.checkInputLength(it, TextLength.MEDIUM)) { @@ -210,9 +210,9 @@ fun EventCreationScreen( modifier = Modifier.fillMaxWidth().testTag(EventCreationTestTags.DESCRIPTION), value = longDescription, supportingText = { - if (longDescription.isEmpty()) { - Text(context.getString(R.string.event_creation_description_error)) - } + if (longDescription.isEmpty()) { + Text(context.getString(R.string.event_creation_description_error)) + } }, onValueChange = { if (Utils.checkInputLength(it, TextLength.LARGE)) { From 59b8b7718f4b88ebe29e4a74ecb5a8d65adcf2a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2024 14:42:53 +0100 Subject: [PATCH 8/8] chore(EventCreation): add missing highlight for descriptio --- app/src/main/java/com/android/unio/ui/event/EventCreation.kt | 1 + 1 file changed, 1 insertion(+) 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 6c034c9df..cad4d1ded 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 @@ -209,6 +209,7 @@ fun EventCreationScreen( OutlinedTextField( modifier = Modifier.fillMaxWidth().testTag(EventCreationTestTags.DESCRIPTION), value = longDescription, + isError = longDescription.isEmpty(), supportingText = { if (longDescription.isEmpty()) { Text(context.getString(R.string.event_creation_description_error))