#14 temporary update does not work
This commit is contained in:
		
							parent
							
								
									e4066dedd7
								
							
						
					
					
						commit
						b790b55ab2
					
				
					 9 changed files with 79 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -2,8 +2,8 @@ package be.ugent.sel.studeez.screens.drawer
 | 
			
		|||
 | 
			
		||||
import be.ugent.sel.studeez.domain.AccountDAO
 | 
			
		||||
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.LOGIN_SCREEN
 | 
			
		||||
import be.ugent.sel.studeez.screens.StudeezViewModel
 | 
			
		||||
import dagger.hilt.android.lifecycle.HiltViewModel
 | 
			
		||||
import javax.inject.Inject
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ class DrawerViewModel @Inject constructor(
 | 
			
		|||
    fun onLogoutClick(openAndPopUp: (String, String) -> Unit) {
 | 
			
		||||
        launchCatching {
 | 
			
		||||
            accountDAO.signOut()
 | 
			
		||||
            openAndPopUp(StudeezDestinations.LOGIN_SCREEN, StudeezDestinations.HOME_SCREEN)
 | 
			
		||||
            openAndPopUp(LOGIN_SCREEN, HOME_SCREEN)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,16 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.profile
 | 
			
		||||
 | 
			
		||||
import androidx.compose.material.Text
 | 
			
		||||
import androidx.compose.runtime.Composable
 | 
			
		||||
import androidx.compose.runtime.LaunchedEffect
 | 
			
		||||
import androidx.compose.runtime.rememberCoroutineScope
 | 
			
		||||
import androidx.hilt.navigation.compose.hiltViewModel
 | 
			
		||||
import be.ugent.sel.studeez.R
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.Headline
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
 | 
			
		||||
import be.ugent.sel.studeez.resources
 | 
			
		||||
import kotlinx.coroutines.CoroutineScope
 | 
			
		||||
import kotlinx.coroutines.coroutineScope
 | 
			
		||||
import kotlinx.coroutines.launch
 | 
			
		||||
import be.ugent.sel.studeez.R.string as AppText
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
| 
						 | 
				
			
			@ -13,11 +19,22 @@ fun ProfileScreen(
 | 
			
		|||
    openAndPopUp: (String, String) -> Unit,
 | 
			
		||||
    viewModel: ProfileViewModel = hiltViewModel()
 | 
			
		||||
) {
 | 
			
		||||
    val coroutineScope: CoroutineScope = rememberCoroutineScope()
 | 
			
		||||
 | 
			
		||||
    var username: String? = null
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    PrimaryScreenTemplate(
 | 
			
		||||
        title = resources().getString(AppText.profile),
 | 
			
		||||
        open = open,
 | 
			
		||||
        openAndPopUp = openAndPopUp
 | 
			
		||||
    ) {
 | 
			
		||||
        Text(text = "This is your profile!") // TODO
 | 
			
		||||
        Headline(text = (username ?: resources().getString(R.string.no_username)))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    LaunchedEffect(true) {
 | 
			
		||||
        coroutineScope.launch {
 | 
			
		||||
            username = viewModel.getUsername()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +1,30 @@
 | 
			
		|||
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.UserDAO
 | 
			
		||||
import be.ugent.sel.studeez.resources
 | 
			
		||||
import be.ugent.sel.studeez.screens.StudeezViewModel
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
@HiltViewModel
 | 
			
		||||
class ProfileViewModel @Inject constructor(
 | 
			
		||||
    private val userDAO: UserDAO,
 | 
			
		||||
    logService: LogService
 | 
			
		||||
) : StudeezViewModel(logService) {
 | 
			
		||||
 | 
			
		||||
    suspend fun getUsername(): String? {
 | 
			
		||||
        return userDAO.getUsername()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ import be.ugent.sel.studeez.common.ext.basicButton
 | 
			
		|||
import kotlinx.coroutines.delay
 | 
			
		||||
import be.ugent.sel.studeez.R.string as AppText
 | 
			
		||||
 | 
			
		||||
private const val SPLASH_TIMEOUT = 1000L
 | 
			
		||||
private const val SPLASH_TIMEOUT = 500L
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
fun SplashScreen(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timers
 | 
			
		||||
 | 
			
		||||
class TimerScreen {
 | 
			
		||||
}
 | 
			
		||||
		Reference in a new issue