#30 added two timepicker cards to break timer edit screen

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

View file

@ -1,10 +1,16 @@
package be.ugent.sel.studeez.screens.timer_edit.editScreens 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 be.ugent.sel.studeez.R
import be.ugent.sel.studeez.common.composable.TimePickerButton 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.HoursMinutesSeconds
import be.ugent.sel.studeez.data.local.models.timer_functional.Time 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.EndlessTimerInfo
import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo
import be.ugent.sel.studeez.ui.theme.StudeezTheme
class BreakTimerEditScreen( class BreakTimerEditScreen(
private val breakTimerInfo: PomodoroTimerInfo private val breakTimerInfo: PomodoroTimerInfo
@ -13,17 +19,28 @@ class BreakTimerEditScreen(
@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 // If the user presses the OK button on the timepicker, the time in the button should change
var studyTime: Int by remember { mutableStateOf(breakTimerInfo.studyTime) }
var breakTime: Int by remember { mutableStateOf(breakTimerInfo.breakTime) }
val breakHms: HoursMinutesSeconds = Time(breakTime).getAsHMS() TimePickerCard(R.string.studyTime, breakTimerInfo.studyTime) { newTime ->
val studyHms: HoursMinutesSeconds = Time(studyTime).getAsHMS() breakTimerInfo.studyTime = newTime
TimePickerButton(studyHms) { _, hour, minute ->
studyTime = hour * 60 * 60 + minute * 60
} }
TimePickerButton(breakHms) { _, hour, minute -> TimePickerCard(R.string.breakTime, breakTimerInfo.breakTime) { newTime ->
breakTime = hour * 60 * 60 + minute * 60 breakTimerInfo.breakTime = newTime
} }
} }
}
@Preview
@Composable
fun BreakEditScreenPreview() {
val pomodoroTimerInfo = PomodoroTimerInfo(
"Breaky the Breaktimer",
"Breaky is a breakdancer",
10 * 60,
60,
5
)
StudeezTheme {
BreakTimerEditScreen(pomodoroTimerInfo).invoke(onSaveClick = {})
}
} }