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.sign_up.SignUpRoute | ||||||
| import be.ugent.sel.studeez.screens.splash.SplashRoute | import be.ugent.sel.studeez.screens.splash.SplashRoute | ||||||
| import be.ugent.sel.studeez.screens.subjects.SubjectRoute | 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.SubjectCreateRoute | ||||||
| import be.ugent.sel.studeez.screens.subjects.form.SubjectEditRoute | 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.TaskCreateRoute | ||||||
| import be.ugent.sel.studeez.screens.tasks.form.TaskEditRoute | import be.ugent.sel.studeez.screens.tasks.form.TaskEditRoute | ||||||
| import be.ugent.sel.studeez.screens.timer_form.TimerAddRoute | import be.ugent.sel.studeez.screens.timer_form.TimerAddRoute | ||||||
|  | @ -51,6 +51,7 @@ fun StudeezNavGraph( | ||||||
|     val open: (String) -> Unit = { appState.navigate(it) } |     val open: (String) -> Unit = { appState.navigate(it) } | ||||||
|     val openAndPopUp: (String, String) -> Unit = |     val openAndPopUp: (String, String) -> Unit = | ||||||
|         { route, popUp -> appState.navigateAndPopUp(route, popUp) } |         { route, popUp -> appState.navigateAndPopUp(route, popUp) } | ||||||
|  |     val clearAndNavigate: (route: String) -> Unit = { route -> appState.clearAndNavigate(route) } | ||||||
| 
 | 
 | ||||||
|     val drawerActions: DrawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp) |     val drawerActions: DrawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp) | ||||||
|     val navigationBarActions: NavigationBarActions = |     val navigationBarActions: NavigationBarActions = | ||||||
|  | @ -200,7 +201,7 @@ fun StudeezNavGraph( | ||||||
| 
 | 
 | ||||||
|         composable(StudeezDestinations.SESSION_RECAP) { |         composable(StudeezDestinations.SESSION_RECAP) { | ||||||
|             SessionRecapRoute( |             SessionRecapRoute( | ||||||
|                 openAndPopUp = openAndPopUp, |                 clearAndNavigate = clearAndNavigate, | ||||||
|                 viewModel = hiltViewModel() |                 viewModel = hiltViewModel() | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -21,24 +21,24 @@ data class SessionRecapActions( | ||||||
| 
 | 
 | ||||||
| fun getSessionRecapActions( | fun getSessionRecapActions( | ||||||
|     viewModel: SessionRecapViewModel, |     viewModel: SessionRecapViewModel, | ||||||
|     openAndPopUp: (String, String) -> Unit, |     clearAndNavigate: (String) -> Unit, | ||||||
| ): SessionRecapActions { | ): SessionRecapActions { | ||||||
|     return SessionRecapActions( |     return SessionRecapActions( | ||||||
|         viewModel::getSessionReport, |         viewModel::getSessionReport, | ||||||
|         {viewModel.saveSession(openAndPopUp)}, |         { viewModel.saveSession(clearAndNavigate) }, | ||||||
|         {viewModel.discardSession(openAndPopUp)} |         { viewModel.discardSession(clearAndNavigate) } | ||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @Composable | @Composable | ||||||
| fun SessionRecapRoute( | fun SessionRecapRoute( | ||||||
|     openAndPopUp: (String, String) -> Unit, |     clearAndNavigate: (String) -> Unit, | ||||||
|     modifier: Modifier = Modifier, |     modifier: Modifier = Modifier, | ||||||
|     viewModel: SessionRecapViewModel, |     viewModel: SessionRecapViewModel, | ||||||
| ) { | ) { | ||||||
|     SessionRecapScreen( |     SessionRecapScreen( | ||||||
|         modifier = modifier, |         modifier = modifier, | ||||||
|         getSessionRecapActions(viewModel, openAndPopUp) |         getSessionRecapActions(viewModel, clearAndNavigate) | ||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -24,15 +24,15 @@ class SessionRecapViewModel @Inject constructor( | ||||||
|         return selectedSessionReport() |         return selectedSessionReport() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun saveSession(open: (String, String) -> Unit) { |     fun saveSession(open: (String) -> Unit) { | ||||||
|         sessionDAO.saveSession(getSessionReport()) |         sessionDAO.saveSession(getSessionReport()) | ||||||
|         val newTask = |         val newTask = | ||||||
|             selectedTask().copy(time = selectedTask().time + selectedSessionReport().studyTime) |             selectedTask().copy(time = selectedTask().time + selectedSessionReport().studyTime) | ||||||
|         taskDAO.updateTask(newTask) |         taskDAO.updateTask(newTask) | ||||||
|         open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP) |         open(StudeezDestinations.HOME_SCREEN) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun discardSession(open: (String, String) -> Unit) { |     fun discardSession(open: (String) -> Unit) { | ||||||
|         open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP) |         open(StudeezDestinations.HOME_SCREEN) | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in a new issue
	
	 brreynie
						brreynie