#18 Move to edit screen on click
This commit is contained in:
		
							parent
							
								
									3900e3c18a
								
							
						
					
					
						commit
						3ff4f82298
					
				
					 7 changed files with 58 additions and 18 deletions
				
			
		|  | @ -20,6 +20,7 @@ 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.home.HomeScreen | ||||||
| import be.ugent.sel.studeez.screens.log_in.LoginScreen | import be.ugent.sel.studeez.screens.log_in.LoginScreen | ||||||
|  | import be.ugent.sel.studeez.screens.profile.EditProfileScreen | ||||||
| import be.ugent.sel.studeez.screens.profile.ProfileScreen | import be.ugent.sel.studeez.screens.profile.ProfileScreen | ||||||
| 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 | ||||||
|  | @ -77,12 +78,16 @@ fun resources(): Resources { | ||||||
| 
 | 
 | ||||||
| fun NavGraphBuilder.studeezGraph(appState: StudeezAppstate) { | fun NavGraphBuilder.studeezGraph(appState: StudeezAppstate) { | ||||||
| 
 | 
 | ||||||
|     val openAndPopUp: (String, String) -> Unit = { |     val goBack: () -> Unit = { | ||||||
|             route, popUp -> appState.navigateAndPopUp(route, popUp) |         appState.popUp() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     val open: (String) -> Unit = { |     val open: (String) -> Unit = { | ||||||
|         route -> appState.navigate(route) |             route -> appState.navigate(route) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     val openAndPopUp: (String, String) -> Unit = { | ||||||
|  |             route, popUp -> appState.navigateAndPopUp(route, popUp) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     composable(StudeezDestinations.SPLASH_SCREEN) { |     composable(StudeezDestinations.SPLASH_SCREEN) { | ||||||
|  | @ -110,4 +115,9 @@ fun NavGraphBuilder.studeezGraph(appState: StudeezAppstate) { | ||||||
| 
 | 
 | ||||||
|     // TODO Timers screen |     // TODO Timers screen | ||||||
|     // TODO Settings screen |     // TODO Settings screen | ||||||
|  | 
 | ||||||
|  |     // Edit screens | ||||||
|  |     composable(StudeezDestinations.EDIT_PROFILE_SCREEN) { | ||||||
|  |         EditProfileScreen(goBack) | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | @ -12,4 +12,7 @@ object StudeezDestinations { | ||||||
| 
 | 
 | ||||||
| //    const val TIMERS_SCREEN = "timers" | //    const val TIMERS_SCREEN = "timers" | ||||||
| //    const val SETTINGS_SCREEN = "settings" | //    const val SETTINGS_SCREEN = "settings" | ||||||
|  | 
 | ||||||
|  |     // Edit screens | ||||||
|  |     const val EDIT_PROFILE_SCREEN = "edit_profile" | ||||||
| } | } | ||||||
|  | @ -2,7 +2,6 @@ package be.ugent.sel.studeez.screens.navbar | ||||||
| 
 | 
 | ||||||
| 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.HOME_SCREEN | import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN | ||||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN | import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN | ||||||
| import be.ugent.sel.studeez.screens.StudeezViewModel | import be.ugent.sel.studeez.screens.StudeezViewModel | ||||||
|  |  | ||||||
|  | @ -0,0 +1,31 @@ | ||||||
|  | package be.ugent.sel.studeez.screens.profile | ||||||
|  | 
 | ||||||
|  | import androidx.compose.material.Text | ||||||
|  | import androidx.compose.runtime.Composable | ||||||
|  | import androidx.compose.ui.tooling.preview.Preview | ||||||
|  | import be.ugent.sel.studeez.R | ||||||
|  | import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate | ||||||
|  | import be.ugent.sel.studeez.resources | ||||||
|  | import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||||
|  | 
 | ||||||
|  | @Composable | ||||||
|  | fun EditProfileScreen( | ||||||
|  |     goBack: () -> Unit | ||||||
|  | ) { | ||||||
|  |     SecondaryScreenTemplate( | ||||||
|  |         title = resources().getString(R.string.editing_profile), | ||||||
|  |         popUp = goBack | ||||||
|  |     ) { | ||||||
|  |         Text(text = "TODO") | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | @Preview | ||||||
|  | @Composable | ||||||
|  | fun EditProfileScreenComposable() { | ||||||
|  |     StudeezTheme { | ||||||
|  |         EditProfileScreen { | ||||||
|  |             {} | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -27,15 +27,17 @@ fun ProfileScreen( | ||||||
|         title = resources().getString(AppText.profile), |         title = resources().getString(AppText.profile), | ||||||
|         open = open, |         open = open, | ||||||
|         openAndPopUp = openAndPopUp, |         openAndPopUp = openAndPopUp, | ||||||
|         action = { EditAction() } |         action = { EditAction { viewModel.onEditProfileClick(open) } } | ||||||
|     ) { |     ) { | ||||||
|         Headline(text = (username ?: resources().getString(R.string.no_username))) |         Headline(text = (username ?: resources().getString(R.string.no_username))) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @Composable | @Composable | ||||||
| fun EditAction() { | fun EditAction( | ||||||
|     IconButton(onClick = { /*TODO*/ }) { |     onClick: () -> Unit | ||||||
|  | ) { | ||||||
|  |     IconButton(onClick = onClick) { | ||||||
|         Icon( |         Icon( | ||||||
|             imageVector = Icons.Default.Edit, |             imageVector = Icons.Default.Edit, | ||||||
|             contentDescription = resources().getString(AppText.edit_profile) |             contentDescription = resources().getString(AppText.edit_profile) | ||||||
|  |  | ||||||
|  | @ -1,20 +1,10 @@ | ||||||
| package be.ugent.sel.studeez.screens.profile | package be.ugent.sel.studeez.screens.profile | ||||||
| 
 | 
 | ||||||
| import androidx.compose.runtime.rememberCoroutineScope |  | ||||||
| import androidx.lifecycle.viewModelScope |  | ||||||
| import be.ugent.sel.studeez.R |  | ||||||
| import be.ugent.sel.studeez.domain.LogService | import be.ugent.sel.studeez.domain.LogService | ||||||
| import be.ugent.sel.studeez.domain.UserDAO | import be.ugent.sel.studeez.domain.UserDAO | ||||||
| import be.ugent.sel.studeez.resources | 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.CoroutineScope |  | ||||||
| import kotlinx.coroutines.coroutineScope |  | ||||||
| import kotlinx.coroutines.flow.SharingStarted |  | ||||||
| import kotlinx.coroutines.flow.StateFlow |  | ||||||
| import kotlinx.coroutines.flow.map |  | ||||||
| import kotlinx.coroutines.flow.stateIn |  | ||||||
| 
 |  | ||||||
| import javax.inject.Inject | import javax.inject.Inject | ||||||
| 
 | 
 | ||||||
| @HiltViewModel | @HiltViewModel | ||||||
|  | @ -27,4 +17,8 @@ class ProfileViewModel @Inject constructor( | ||||||
|         return userDAO.getUsername() |         return userDAO.getUsername() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     fun onEditProfileClick(open: (String) -> Unit) { | ||||||
|  |         open(StudeezDestinations.EDIT_PROFILE_SCREEN) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | @ -40,6 +40,7 @@ | ||||||
|     <string name="profile">Profile</string> |     <string name="profile">Profile</string> | ||||||
|     <string name="no_username">Unknown username</string> |     <string name="no_username">Unknown username</string> | ||||||
|     <string name="edit_profile">Edit profile</string> |     <string name="edit_profile">Edit profile</string> | ||||||
|  |     <string name="editing_profile">Editing profile</string> | ||||||
| 
 | 
 | ||||||
|     <!-- Friends --> |     <!-- Friends --> | ||||||
|     <string name="friends">Friends</string> |     <string name="friends">Friends</string> | ||||||
|  |  | ||||||
		Reference in a new issue