map implementation

This commit is contained in:
Lukas Barragan Torres 2023-05-13 17:27:13 +02:00
parent eb28fa4ae4
commit 2971ae85aa

View file

@ -15,6 +15,8 @@ class BreakTimerFormScreen(
private val breakTimerInfo: PomodoroTimerInfo
): AbstractTimerFormScreen(breakTimerInfo) {
@Composable
override fun ExtraFields() {
// If the user presses the OK button on the timepicker, the time in the button should change
@ -26,13 +28,17 @@ class BreakTimerFormScreen(
breakTimerInfo.breakTime = newTime
}
valids["repeats"] = remember {mutableStateOf(true)}
firsts["repeats"] = remember { mutableStateOf(true) }
LabeledErrorTextField(
initialValue = breakTimerInfo.repeats.toString(),
label = R.string.repeats,
errorText = AppText.repeats_error,
isValid = mutableStateOf(false),
isValid = valids.getValue("repeats"),
isFirst = firsts.getValue("repeats"),
keyboardType = KeyboardType.Decimal,
predicate = { it.matches(Regex("[1-9]+\\d*")) }
predicate = { isNumber(it) }
) { correctlyTypedInt ->
breakTimerInfo.repeats = correctlyTypedInt.toInt()
}
@ -40,6 +46,10 @@ class BreakTimerFormScreen(
}
}
fun isNumber(text: String): Boolean {
return text.matches(Regex("[1-9]+\\d*"))
}
@Preview
@Composable
fun BreakEditScreenPreview() {