#14 Username working
This commit is contained in:
parent
b790b55ab2
commit
b60603d292
2 changed files with 6 additions and 19 deletions
|
@ -3,7 +3,6 @@ package be.ugent.sel.studeez.common.composable
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -18,8 +17,7 @@ fun Headline(
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
modifier = Modifier.size(34.dp)
|
modifier = Modifier.height(45.dp)
|
||||||
.height(45.dp)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,11 @@
|
||||||
package be.ugent.sel.studeez.screens.profile
|
package be.ugent.sel.studeez.screens.profile
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import be.ugent.sel.studeez.R
|
import be.ugent.sel.studeez.R
|
||||||
import be.ugent.sel.studeez.common.composable.Headline
|
import be.ugent.sel.studeez.common.composable.Headline
|
||||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
||||||
import be.ugent.sel.studeez.resources
|
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
|
import be.ugent.sel.studeez.R.string as AppText
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -19,10 +14,10 @@ fun ProfileScreen(
|
||||||
openAndPopUp: (String, String) -> Unit,
|
openAndPopUp: (String, String) -> Unit,
|
||||||
viewModel: ProfileViewModel = hiltViewModel()
|
viewModel: ProfileViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
val coroutineScope: CoroutineScope = rememberCoroutineScope()
|
var username: String? by remember { mutableStateOf("") }
|
||||||
|
LaunchedEffect(key1 = Unit) {
|
||||||
var username: String? = null
|
username = viewModel.getUsername()
|
||||||
|
}
|
||||||
|
|
||||||
PrimaryScreenTemplate(
|
PrimaryScreenTemplate(
|
||||||
title = resources().getString(AppText.profile),
|
title = resources().getString(AppText.profile),
|
||||||
|
@ -31,10 +26,4 @@ fun ProfileScreen(
|
||||||
) {
|
) {
|
||||||
Headline(text = (username ?: resources().getString(R.string.no_username)))
|
Headline(text = (username ?: resources().getString(R.string.no_username)))
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(true) {
|
|
||||||
coroutineScope.launch {
|
|
||||||
username = viewModel.getUsername()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in a new issue