clear navStack when ending session
This commit is contained in:
parent
5f0bdc948f
commit
0341fcf137
3 changed files with 12 additions and 11 deletions
|
@ -25,9 +25,9 @@ import be.ugent.sel.studeez.screens.settings.SettingsRoute
|
|||
import be.ugent.sel.studeez.screens.sign_up.SignUpRoute
|
||||
import be.ugent.sel.studeez.screens.splash.SplashRoute
|
||||
import be.ugent.sel.studeez.screens.subjects.SubjectRoute
|
||||
import be.ugent.sel.studeez.screens.tasks.TaskRoute
|
||||
import be.ugent.sel.studeez.screens.subjects.form.SubjectCreateRoute
|
||||
import be.ugent.sel.studeez.screens.subjects.form.SubjectEditRoute
|
||||
import be.ugent.sel.studeez.screens.tasks.TaskRoute
|
||||
import be.ugent.sel.studeez.screens.tasks.form.TaskCreateRoute
|
||||
import be.ugent.sel.studeez.screens.tasks.form.TaskEditRoute
|
||||
import be.ugent.sel.studeez.screens.timer_form.TimerAddRoute
|
||||
|
@ -51,6 +51,7 @@ fun StudeezNavGraph(
|
|||
val open: (String) -> Unit = { appState.navigate(it) }
|
||||
val openAndPopUp: (String, String) -> Unit =
|
||||
{ route, popUp -> appState.navigateAndPopUp(route, popUp) }
|
||||
val clearAndNavigate: (route: String) -> Unit = { route -> appState.clearAndNavigate(route) }
|
||||
|
||||
val drawerActions: DrawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp)
|
||||
val navigationBarActions: NavigationBarActions =
|
||||
|
@ -200,7 +201,7 @@ fun StudeezNavGraph(
|
|||
|
||||
composable(StudeezDestinations.SESSION_RECAP) {
|
||||
SessionRecapRoute(
|
||||
openAndPopUp = openAndPopUp,
|
||||
clearAndNavigate = clearAndNavigate,
|
||||
viewModel = hiltViewModel()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -21,24 +21,24 @@ data class SessionRecapActions(
|
|||
|
||||
fun getSessionRecapActions(
|
||||
viewModel: SessionRecapViewModel,
|
||||
openAndPopUp: (String, String) -> Unit,
|
||||
clearAndNavigate: (String) -> Unit,
|
||||
): SessionRecapActions {
|
||||
return SessionRecapActions(
|
||||
viewModel::getSessionReport,
|
||||
{viewModel.saveSession(openAndPopUp)},
|
||||
{viewModel.discardSession(openAndPopUp)}
|
||||
{ viewModel.saveSession(clearAndNavigate) },
|
||||
{ viewModel.discardSession(clearAndNavigate) }
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SessionRecapRoute(
|
||||
openAndPopUp: (String, String) -> Unit,
|
||||
clearAndNavigate: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: SessionRecapViewModel,
|
||||
) {
|
||||
SessionRecapScreen(
|
||||
modifier = modifier,
|
||||
getSessionRecapActions(viewModel, openAndPopUp)
|
||||
getSessionRecapActions(viewModel, clearAndNavigate)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,15 @@ class SessionRecapViewModel @Inject constructor(
|
|||
return selectedSessionReport()
|
||||
}
|
||||
|
||||
fun saveSession(open: (String, String) -> Unit) {
|
||||
fun saveSession(open: (String) -> Unit) {
|
||||
sessionDAO.saveSession(getSessionReport())
|
||||
val newTask =
|
||||
selectedTask().copy(time = selectedTask().time + selectedSessionReport().studyTime)
|
||||
taskDAO.updateTask(newTask)
|
||||
open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP)
|
||||
open(StudeezDestinations.HOME_SCREEN)
|
||||
}
|
||||
|
||||
fun discardSession(open: (String, String) -> Unit) {
|
||||
open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP)
|
||||
fun discardSession(open: (String) -> Unit) {
|
||||
open(StudeezDestinations.HOME_SCREEN)
|
||||
}
|
||||
}
|
Reference in a new issue