#30 added timepicker card to custom timer edit screen

This commit is contained in:
lbarraga 2023-05-01 17:55:25 +02:00
parent 48a1a50a5f
commit ea2c91d59a

View file

@ -2,21 +2,22 @@ package be.ugent.sel.studeez.screens.timer_edit.editScreens
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import be.ugent.sel.studeez.common.composable.TimePickerButton import be.ugent.sel.studeez.common.composable.TimePickerCard
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
import be.ugent.sel.studeez.data.local.models.timer_functional.Time
import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo
import be.ugent.sel.studeez.ui.theme.StudeezTheme
import be.ugent.sel.studeez.R.string as AppText
class CustomTimerEditScreen(private val customTimerInfo: CustomTimerInfo): AbstractTimerEditScreen(customTimerInfo) { class CustomTimerEditScreen(
private val customTimerInfo: CustomTimerInfo
): AbstractTimerEditScreen(customTimerInfo) {
@Composable @Composable
override fun ExtraFields() { override fun ExtraFields() {
// If the user presses the OK button on the timepicker, the time in the button should change TimePickerCard(
var studyTime by remember { mutableStateOf(customTimerInfo.studyTime) } text = AppText.studyTime,
initialSeconds = customTimerInfo.studyTime
val hms: HoursMinutesSeconds = Time(studyTime).getAsHMS() ) { newTime ->
TimePickerButton(hms) { _, hour, minute -> customTimerInfo.studyTime = newTime
studyTime = hour * 60 * 60 + minute * 60
} }
} }
@ -25,7 +26,9 @@ class CustomTimerEditScreen(private val customTimerInfo: CustomTimerInfo): Abstr
@Preview @Preview
@Composable @Composable
fun TimePickerPreview() { fun CustomEditScreenPreview() {
val customTimerInfo = CustomTimerInfo("custom", "my description", 25) val customTimerInfo = CustomTimerInfo("custom", "my description", 25)
CustomTimerEditScreen(customTimerInfo).ExtraFields() StudeezTheme {
CustomTimerEditScreen(customTimerInfo).invoke(onSaveClick = {})
}
} }