#30 added two timepicker cards to break timer edit screen
This commit is contained in:
parent
ea2c91d59a
commit
cfb356cbf1
1 changed files with 25 additions and 8 deletions
|
@ -1,10 +1,16 @@
|
|||
package be.ugent.sel.studeez.screens.timer_edit.editScreens
|
||||
|
||||
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.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.EndlessTimerInfo
|
||||
import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo
|
||||
import be.ugent.sel.studeez.ui.theme.StudeezTheme
|
||||
|
||||
class BreakTimerEditScreen(
|
||||
private val breakTimerInfo: PomodoroTimerInfo
|
||||
|
@ -13,17 +19,28 @@ class BreakTimerEditScreen(
|
|||
@Composable
|
||||
override fun ExtraFields() {
|
||||
// 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()
|
||||
val studyHms: HoursMinutesSeconds = Time(studyTime).getAsHMS()
|
||||
TimePickerButton(studyHms) { _, hour, minute ->
|
||||
studyTime = hour * 60 * 60 + minute * 60
|
||||
TimePickerCard(R.string.studyTime, breakTimerInfo.studyTime) { newTime ->
|
||||
breakTimerInfo.studyTime = newTime
|
||||
}
|
||||
TimePickerButton(breakHms) { _, hour, minute ->
|
||||
breakTime = hour * 60 * 60 + minute * 60
|
||||
TimePickerCard(R.string.breakTime, breakTimerInfo.breakTime) { newTime ->
|
||||
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 = {})
|
||||
}
|
||||
}
|
Reference in a new issue