Skip to content

Commit c21cc35

Browse files
committed
Adds a "Clear" button to the NumberInputDialog to allow users to quickly reset the input field. This update includes the necessary string resources for English and German locales, see issue #1292
1 parent b59f6b4 commit c21cc35

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

android_app/app/src/main/java/com/health/openscale/ui/screen/dialog/NumberInputDialog.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.health.openscale.ui.screen.dialog
22

3+
import android.R.attr.inputType
4+
import android.R.attr.onClick
35
import android.R.attr.type
46
import androidx.compose.foundation.clickable
57
import androidx.compose.foundation.layout.*
@@ -293,6 +295,14 @@ fun NumberInputDialog(
293295
}
294296
},
295297
dismissButton = {
298+
TextButton(
299+
onClick = {
300+
currentValueForDialog = ""
301+
}
302+
) {
303+
Text(stringResource(R.string.clear_button))
304+
}
305+
296306
TextButton(onClick = onDismiss) {
297307
Text(stringResource(R.string.cancel_button))
298308
}
@@ -309,7 +319,7 @@ fun NumberInputDialog(
309319
},
310320
text = {
311321
NumberInputField(
312-
initialValue = initialValue,
322+
initialValue = currentValueForDialog,
313323
inputType = inputType,
314324
unit = unit,
315325
onValueChange = { newValueFromField ->

android_app/app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<!-- Generische UI-Elemente & Aktionen -->
1111
<string name="enable_button">Aktivieren</string>
1212
<string name="cancel_button">Abbrechen</string>
13+
<string name="clear_button">Löschen</string>
1314
<string name="confirm_button">Bestätigen</string>
1415
<string name="dialog_ok">OK</string>
1516
<string name="switch_on">An</string>

android_app/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<!-- Generic UI Elements & Actions -->
1212
<string name="enable_button">Enable</string>
1313
<string name="cancel_button">Cancel</string>
14+
<string name="clear_button">Clear</string>
1415
<string name="confirm_button">Confirm</string>
1516
<string name="dialog_ok">OK</string>
1617
<string name="switch_on">On</string>

0 commit comments

Comments
 (0)