#30 geef timerinfo door naar edit scherm en open editscherm bij onEditClick
This commit is contained in:
parent
a218f5fcf5
commit
d9c281330f
1 changed files with 7 additions and 1 deletions
|
@ -1,9 +1,11 @@
|
||||||
package be.ugent.sel.studeez.screens.timer_overview
|
package be.ugent.sel.studeez.screens.timer_overview
|
||||||
|
|
||||||
|
import be.ugent.sel.studeez.data.EditTimerState
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo
|
import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo
|
||||||
import be.ugent.sel.studeez.domain.ConfigurationService
|
import be.ugent.sel.studeez.domain.ConfigurationService
|
||||||
import be.ugent.sel.studeez.domain.LogService
|
import be.ugent.sel.studeez.domain.LogService
|
||||||
import be.ugent.sel.studeez.domain.TimerDAO
|
import be.ugent.sel.studeez.domain.TimerDAO
|
||||||
|
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
@ -13,6 +15,7 @@ import javax.inject.Inject
|
||||||
class TimerOverviewViewModel @Inject constructor(
|
class TimerOverviewViewModel @Inject constructor(
|
||||||
private val configurationService: ConfigurationService,
|
private val configurationService: ConfigurationService,
|
||||||
private val timerDAO: TimerDAO,
|
private val timerDAO: TimerDAO,
|
||||||
|
private val editTimerState: EditTimerState,
|
||||||
logService: LogService
|
logService: LogService
|
||||||
) : StudeezViewModel(logService) {
|
) : StudeezViewModel(logService) {
|
||||||
|
|
||||||
|
@ -24,7 +27,10 @@ class TimerOverviewViewModel @Inject constructor(
|
||||||
return configurationService.getDefaultTimers()
|
return configurationService.getDefaultTimers()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(timerInfo: TimerInfo) = timerDAO.updateTimer(timerInfo)
|
fun update(timerInfo: TimerInfo, open: (String) -> Unit) {
|
||||||
|
editTimerState.timerInfo = timerInfo
|
||||||
|
open(StudeezDestinations.TIMER_EDIT_SCREEN)
|
||||||
|
}
|
||||||
|
|
||||||
fun delete(timerInfo: TimerInfo) =timerDAO.deleteTimer(timerInfo)
|
fun delete(timerInfo: TimerInfo) =timerDAO.deleteTimer(timerInfo)
|
||||||
|
|
||||||
|
|
Reference in a new issue