improved menu layout

This commit is contained in:
Odweta
2024-11-30 11:23:04 +01:00
parent f67e28b8f6
commit 5200e3ba07
+88 -144
View File
@@ -36,153 +36,97 @@ fun MenuScreen(modifier: Modifier = Modifier) {
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// Button to trigger the dialog
Button(
onClick = { showDialog = true },
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
MenuButton({ showDialog = true }, "Odhlásit se")
Spacer(modifier = Modifier.height(80.dp))
MenuButton({ screenToShow.value = Screen.SignIn }, "Změnit přihlášení")
Spacer(modifier = Modifier.height(80.dp))
MenuButton({ isShowing.value = IsShowing.About }, "O aplikaci")
Spacer(modifier = Modifier.height(80.dp))
MenuButton({ isShowing.value = IsShowing.Settings }, "Nastavení")
}
// Dialog implementation
if (showDialog) {
AlertDialog(
onDismissRequest = { showDialog = false }, // Close the dialog on dismiss
title = {
Text(text = "Odhlásit se", color = Color.White)
},
text = {
Text("Opravdu se chcete odhlásit? Tato akce zavře aplikaci.", color = Color.White)
},
containerColor = Color.Black,
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(230.dp)
.height(80.dp)
) {
Text(
text = "Odhlásit se",
fontSize = 23.sp
)
}
Spacer(modifier = Modifier.height(100.dp))
// Dialog implementation
if (showDialog) {
AlertDialog(
onDismissRequest = { showDialog = false }, // Close the dialog on dismiss
title = {
Text(text = "Odhlásit se", color = Color.White)
},
text = {
Text("Opravdu se chcete odhlásit? Tato akce zavře aplikaci.", color = Color.White)
},
containerColor = Color.Black,
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)), // Yellow border
confirmButton = {
Button(
onClick = {
showDialog = false
Util.deleteFile(userDataFilePath)
Util.deleteFile(timeTableFilePath)
Util.deleteFile(marksFilePath)
Util.deleteFile(accountDataFilePath)
exitProcess(0)
},
colors = ButtonDefaults.buttonColors(
containerColor = Color.Black, // Black background for the button
contentColor = Color.White // Yellow text for the button
),
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)) // Yellow border
) {
Text("Ano")
}
},
dismissButton = {
Button(
onClick = {
showDialog = false
},
colors = ButtonDefaults.buttonColors(
containerColor = Color.Black, // Black background for the button
contentColor = Color.White,
// Yellow text for the button
),
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)) // Yellow border
) {
Text("Ne")
}
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)), // Yellow border
confirmButton = {
Button(
onClick = {
showDialog = false
Util.deleteFile(userDataFilePath)
Util.deleteFile(timeTableFilePath)
Util.deleteFile(marksFilePath)
Util.deleteFile(accountDataFilePath)
exitProcess(0)
},
colors = ButtonDefaults.buttonColors(
containerColor = Color.Black, // Black background for the button
contentColor = Color.White // Yellow text for the button
),
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)) // Yellow border
) {
Text("Ano")
}
)
}
Button(onClick = {
screenToShow.value = Screen.SignIn
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(230.dp)
.height(80.dp)
) {
Text(
text = "Změnit přihlášení",
fontSize = 23.sp
dismissButton = {
Button(
onClick = {
showDialog = false
},
colors = ButtonDefaults.buttonColors(
containerColor = Color.Black, // Black background for the button
contentColor = Color.White,
// Yellow text for the button
),
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen)) // Yellow border
) {
Text("Ne")
}
}
)
}
}
@Composable
fun MenuButton(onClick: () -> Unit, text: String) {
Button(
onClick = onClick,
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
}
Spacer(modifier = Modifier.height(100.dp))
Button(onClick = {
isShowing.value = IsShowing.About
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(230.dp)
.height(80.dp)
) {
Text(
text = "O aplikaci",
fontSize = 23.sp
)
}
Spacer(modifier = Modifier.height(100.dp))
Button(onClick = {
isShowing.value = IsShowing.Settings
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(230.dp)
.height(80.dp)
) {
Text(
text = "Nastavení",
fontSize = 23.sp
)
}
.width(230.dp)
.height(80.dp)
) {
Text(
text = text,
fontSize = 23.sp
)
}
}