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