diff --git a/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt b/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt index 46ac3fe..625ddec 100644 --- a/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt +++ b/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt @@ -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,36 +1497,49 @@ fun AccountScreen( modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp) ) { - Button( - onClick = onLogout, - enabled = (me != null), - 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 ut") - } + 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, + 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 ut") + } - OutlinedButton( - onClick = onDeleteAccount, - enabled = (me != null), - modifier = Modifier.fillMaxWidth(), - colors = ButtonDefaults.outlinedButtonColors( - contentColor = MaterialTheme.colorScheme.error - ), - border = BorderStroke(1.dp, MaterialTheme.colorScheme.error) - ) { - Icon( - Icons.Filled.Delete, - contentDescription = null, - tint = MaterialTheme.colorScheme.error - ) - Spacer(Modifier.width(8.dp)) - Text("Radera konto (ej implementerat)") + OutlinedButton( + onClick = onDeleteAccount, + modifier = Modifier.fillMaxWidth(), + colors = ButtonDefaults.outlinedButtonColors( + contentColor = MaterialTheme.colorScheme.error + ), + border = BorderStroke(1.dp, MaterialTheme.colorScheme.error) + ) { + Icon( + Icons.Filled.Delete, + contentDescription = null, + tint = MaterialTheme.colorScheme.error + ) + Spacer(Modifier.width(8.dp)) + Text("Radera konto (ej implementerat)") + } } } }