#14 temporary update does not work
This commit is contained in:
parent
e4066dedd7
commit
b790b55ab2
9 changed files with 79 additions and 10 deletions
|
@ -0,0 +1,25 @@
|
|||
package be.ugent.sel.studeez.common.composable
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun Headline(
|
||||
text: String
|
||||
) {
|
||||
Row (
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
modifier = Modifier.size(34.dp)
|
||||
.height(45.dp)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
package be.ugent.sel.studeez.domain
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface UserDAO {
|
||||
|
||||
suspend fun getUserName(): String?
|
||||
|
||||
suspend fun getUsername(): String?
|
||||
suspend fun save(newUsername: String)
|
||||
}
|
|
@ -1,18 +1,26 @@
|
|||
package be.ugent.sel.studeez.domain.implementation
|
||||
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import be.ugent.sel.studeez.domain.AccountDAO
|
||||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import com.google.firebase.firestore.DocumentReference
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.tasks.await
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
class FirebaseUserDAO @Inject constructor(
|
||||
private val firestore: FirebaseFirestore,
|
||||
private val auth: AccountDAO
|
||||
) : UserDAO {
|
||||
|
||||
override suspend fun getUserName(): String? {
|
||||
override suspend fun getUsername(): String? {
|
||||
return currentUserDocument().get().await().getString("username")
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
<!-- Profile -->
|
||||
<string name="profile">Profile</string>
|
||||
<string name="no_username">Unknown username</string>
|
||||
|
||||
<!-- Drawer / SideMenu -->
|
||||
<string name="log_out">Log out</string>
|
||||
|
|
Reference in a new issue