commit
						4bc6334c0a
					
				
					 8 changed files with 53 additions and 4 deletions
				
			
		|  | @ -18,6 +18,7 @@ import androidx.navigation.compose.composable | ||||||
| import androidx.navigation.compose.rememberNavController | import androidx.navigation.compose.rememberNavController | ||||||
| import be.ugent.sel.studeez.common.snackbar.SnackbarManager | import be.ugent.sel.studeez.common.snackbar.SnackbarManager | ||||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||||
|  | import be.ugent.sel.studeez.screens.home.HomeScreen | ||||||
| import be.ugent.sel.studeez.screens.sign_in.LoginScreen | import be.ugent.sel.studeez.screens.sign_in.LoginScreen | ||||||
| import be.ugent.sel.studeez.screens.sign_up.SignUpScreen | import be.ugent.sel.studeez.screens.sign_up.SignUpScreen | ||||||
| import be.ugent.sel.studeez.screens.splash.SplashScreen | import be.ugent.sel.studeez.screens.splash.SplashScreen | ||||||
|  | @ -86,4 +87,8 @@ fun NavGraphBuilder.studeezGraph(appState: StudeezAppstate) { | ||||||
|     composable(StudeezDestinations.SIGN_UP_SCREEN) { |     composable(StudeezDestinations.SIGN_UP_SCREEN) { | ||||||
|         SignUpScreen(openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) }) |         SignUpScreen(openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) }) | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     composable(StudeezDestinations.HOME_SCREEN) { | ||||||
|  |         HomeScreen(openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) }) | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | @ -14,7 +14,7 @@ import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||||
| // Contains floatingActionButton and bottom bar, used in the main four screens. | // Contains floatingActionButton and bottom bar, used in the main four screens. | ||||||
| fun PrimaryScreenToolbar( | fun PrimaryScreenToolbar( | ||||||
|     title: String, |     title: String, | ||||||
|     content: (PaddingValues) -> Unit |     content: @Composable (PaddingValues) -> Unit | ||||||
| ) { | ) { | ||||||
|     Scaffold( |     Scaffold( | ||||||
|         // Everything at the top of the screen |         // Everything at the top of the screen | ||||||
|  |  | ||||||
|  | @ -4,5 +4,6 @@ object StudeezDestinations { | ||||||
|     const val SPLASH_SCREEN = "splash" |     const val SPLASH_SCREEN = "splash" | ||||||
|     const val SIGN_UP_SCREEN = "signup" |     const val SIGN_UP_SCREEN = "signup" | ||||||
|     const val LOGIN_SCREEN = "login" |     const val LOGIN_SCREEN = "login" | ||||||
|  |     const val HOME_SCREEN = "home" | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -0,0 +1,25 @@ | ||||||
|  | package be.ugent.sel.studeez.screens.home | ||||||
|  | 
 | ||||||
|  | import androidx.compose.runtime.Composable | ||||||
|  | import androidx.compose.ui.Modifier | ||||||
|  | import androidx.hilt.navigation.compose.hiltViewModel | ||||||
|  | import be.ugent.sel.studeez.R | ||||||
|  | import be.ugent.sel.studeez.common.composable.BasicButton | ||||||
|  | import be.ugent.sel.studeez.common.composable.PrimaryScreenToolbar | ||||||
|  | import be.ugent.sel.studeez.common.composable.SecondaryScreenToolbar | ||||||
|  | import be.ugent.sel.studeez.common.ext.basicButton | ||||||
|  | import be.ugent.sel.studeez.resources | ||||||
|  | 
 | ||||||
|  | @Composable | ||||||
|  | fun HomeScreen( | ||||||
|  |     openAndPopUp: (String, String) -> Unit, | ||||||
|  |     viewModel: HomeViewModel = hiltViewModel() | ||||||
|  | ) { | ||||||
|  | 
 | ||||||
|  |     PrimaryScreenToolbar(title = resources().getString(R.string.home)) { | ||||||
|  |         // "Start session" button | ||||||
|  |         BasicButton(R.string.start_session, Modifier.basicButton()) { | ||||||
|  |             viewModel.onStartSessionClick(openAndPopUp) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,14 @@ | ||||||
|  | package be.ugent.sel.studeez.screens.home | ||||||
|  | 
 | ||||||
|  | import be.ugent.sel.studeez.domain.LogService | ||||||
|  | import be.ugent.sel.studeez.screens.StudeezViewModel | ||||||
|  | import dagger.hilt.android.lifecycle.HiltViewModel | ||||||
|  | import javax.inject.Inject | ||||||
|  | 
 | ||||||
|  | @HiltViewModel | ||||||
|  | class HomeViewModel @Inject constructor(logService: LogService) : StudeezViewModel(logService) { | ||||||
|  | 
 | ||||||
|  |     fun onStartSessionClick(openAndPopUp: (String, String) -> Unit) { | ||||||
|  |         // openAndPopUp(StudeezDestinations.xxx, StudeezDestinations.HOME_SCREEN) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -6,6 +6,7 @@ import be.ugent.sel.studeez.common.snackbar.SnackbarManager | ||||||
| import be.ugent.sel.studeez.domain.AccountDAO | import be.ugent.sel.studeez.domain.AccountDAO | ||||||
| import be.ugent.sel.studeez.domain.LogService | import be.ugent.sel.studeez.domain.LogService | ||||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||||
|  | import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN | ||||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.LOGIN_SCREEN | import be.ugent.sel.studeez.navigation.StudeezDestinations.LOGIN_SCREEN | ||||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.SIGN_UP_SCREEN | import be.ugent.sel.studeez.navigation.StudeezDestinations.SIGN_UP_SCREEN | ||||||
| import be.ugent.sel.studeez.screens.StudeezViewModel | import be.ugent.sel.studeez.screens.StudeezViewModel | ||||||
|  | @ -47,7 +48,7 @@ class LoginViewModel @Inject constructor( | ||||||
| 
 | 
 | ||||||
|         launchCatching { |         launchCatching { | ||||||
|             accountDAO.signInWithEmailAndPassword(email, password) |             accountDAO.signInWithEmailAndPassword(email, password) | ||||||
|             openAndPopUp(SIGN_UP_SCREEN, LOGIN_SCREEN) // Is not reached when error occurs. |             openAndPopUp(HOME_SCREEN, LOGIN_SCREEN) // Is not reached when error occurs. | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -19,8 +19,7 @@ class SplashViewModel @Inject constructor( | ||||||
| 
 | 
 | ||||||
|         showError.value = false |         showError.value = false | ||||||
|         if (accountDAO.hasUser) { |         if (accountDAO.hasUser) { | ||||||
|             // TODO this should go to the home page |             openAndPopUp(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SPLASH_SCREEN) | ||||||
|             openAndPopUp(StudeezDestinations.SIGN_UP_SCREEN, StudeezDestinations.SPLASH_SCREEN) |  | ||||||
|         } else{ |         } else{ | ||||||
|             openAndPopUp(StudeezDestinations.SIGN_UP_SCREEN, StudeezDestinations.SPLASH_SCREEN) |             openAndPopUp(StudeezDestinations.SIGN_UP_SCREEN, StudeezDestinations.SPLASH_SCREEN) | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -23,4 +23,8 @@ | ||||||
|     <string name="recovery_email_sent">Check your inbox for the recovery email.</string> |     <string name="recovery_email_sent">Check your inbox for the recovery email.</string> | ||||||
|     <string name="empty_password_error">Password cannot be empty.</string> |     <string name="empty_password_error">Password cannot be empty.</string> | ||||||
| 
 | 
 | ||||||
|  |     <!-- HomeScreen --> | ||||||
|  |     <string name="home">Home</string> | ||||||
|  |     <string name="start_session">Start session</string> | ||||||
|  | 
 | ||||||
| </resources> | </resources> | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 lbarraga
						lbarraga