#30 added timepicker card to custom timer edit screen
This commit is contained in:
parent
48a1a50a5f
commit
ea2c91d59a
1 changed files with 15 additions and 12 deletions
|
@ -2,21 +2,22 @@ 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.common.composable.TimePickerButton
|
||||
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.common.composable.TimePickerCard
|
||||
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
|
||||
override fun ExtraFields() {
|
||||
// If the user presses the OK button on the timepicker, the time in the button should change
|
||||
var studyTime by remember { mutableStateOf(customTimerInfo.studyTime) }
|
||||
|
||||
val hms: HoursMinutesSeconds = Time(studyTime).getAsHMS()
|
||||
TimePickerButton(hms) { _, hour, minute ->
|
||||
studyTime = hour * 60 * 60 + minute * 60
|
||||
TimePickerCard(
|
||||
text = AppText.studyTime,
|
||||
initialSeconds = customTimerInfo.studyTime
|
||||
) { newTime ->
|
||||
customTimerInfo.studyTime = newTime
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +26,9 @@ class CustomTimerEditScreen(private val customTimerInfo: CustomTimerInfo): Abstr
|
|||
|
||||
@Preview
|
||||
@Composable
|
||||
fun TimePickerPreview() {
|
||||
fun CustomEditScreenPreview() {
|
||||
val customTimerInfo = CustomTimerInfo("custom", "my description", 25)
|
||||
CustomTimerEditScreen(customTimerInfo).ExtraFields()
|
||||
StudeezTheme {
|
||||
CustomTimerEditScreen(customTimerInfo).invoke(onSaveClick = {})
|
||||
}
|
||||
}
|
Reference in a new issue