Add first login info and dynamic login/logout button to AccountScreen
This commit is contained in:
@@ -654,12 +654,12 @@ fun KlottrAppShell(
|
||||
) {
|
||||
AccountScreen(
|
||||
me = me,
|
||||
onLogin = { onLogin() },
|
||||
onLogout = {
|
||||
onLogout()
|
||||
selectedTab = "menu" // gå tillbaka till menyn efter logout
|
||||
selectedTab = "menu"
|
||||
},
|
||||
onDeleteAccount = {
|
||||
// Ej implementerat ännu
|
||||
selectedTab = "menu"
|
||||
},
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
@@ -1445,6 +1445,7 @@ private fun MenuTile(icon: ImageVector, label: String, onClick: () -> Unit) {
|
||||
@Composable
|
||||
fun AccountScreen(
|
||||
me: app.klottr.net.MeShared?,
|
||||
onLogin: () -> Unit,
|
||||
onLogout: () -> Unit,
|
||||
onDeleteAccount: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
@@ -1477,12 +1478,17 @@ fun AccountScreen(
|
||||
|
||||
Text("Användarnamn", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
|
||||
Text(me.username ?: "-", style = MaterialTheme.typography.bodyLarge)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text("Första inloggningen", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
|
||||
Text(me.firstLogin ?: "-", style = MaterialTheme.typography.bodyLarge)
|
||||
|
||||
} else {
|
||||
Text("Ingen användare inloggad.", style = MaterialTheme.typography.bodyLarge)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Kort för knappar
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
@@ -1491,9 +1497,22 @@ fun AccountScreen(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
if (me == null) {
|
||||
Button(
|
||||
onClick = onLogin,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary
|
||||
)
|
||||
) {
|
||||
Icon(Icons.Filled.Login, contentDescription = null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Logga in")
|
||||
}
|
||||
} else {
|
||||
Button(
|
||||
onClick = onLogout,
|
||||
enabled = (me != null),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
@@ -1507,7 +1526,6 @@ fun AccountScreen(
|
||||
|
||||
OutlinedButton(
|
||||
onClick = onDeleteAccount,
|
||||
enabled = (me != null),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
contentColor = MaterialTheme.colorScheme.error
|
||||
@@ -1525,4 +1543,5 @@ fun AccountScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user