buttons now have icons and text instead of just text

This commit is contained in:
Odweta
2025-01-03 10:21:33 +01:00
parent e9a422eda0
commit bea50f7fe7
@@ -10,12 +10,21 @@ import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.border import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ExitToApp
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material.icons.filled.ArrowBackIosNew
import androidx.compose.material.icons.filled.ExitToApp
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@@ -26,8 +35,11 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.odweta.solon.ui.theme.PastelYellow import com.odweta.solon.ui.theme.PastelYellow
@@ -35,7 +47,7 @@ import kotlin.system.exitProcess
@Composable @Composable
fun MenuScreen() { fun MenuScreen() {
var showDialog by remember { mutableStateOf(false) } val menuSeparatorDimen = 40.dp
Column( Column(
modifier = Modifier modifier = Modifier
@@ -43,27 +55,50 @@ fun MenuScreen() {
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center verticalArrangement = Arrangement.Center
) { ) {
MenuButton({ global.currentScreenElement = ScreenElement.SignOut }, "Odhlásit se") Row {
MenuButton(
{ global.currentScreenElement = ScreenElement.SignOut },
Icons.AutoMirrored.Filled.ExitToApp,
"Odhlásit se"
)
Spacer(modifier = Modifier.height(80.dp)) Spacer(modifier = Modifier.width(menuSeparatorDimen))
MenuButton({ MenuButton(
{
global.noSignInBackHandle = false global.noSignInBackHandle = false
global.currentScreen = Screen.SignIn global.currentScreen = Screen.SignIn
}, "Změnit přihlášení") },
Icons.Default.AccountBox,
"Změnit přihlášení"
)
}
Spacer(modifier = Modifier.height(80.dp)) Spacer(modifier = Modifier.height(menuSeparatorDimen))
MenuButton({ global.currentScreenElement = ScreenElement.About }, "O aplikaci") Row {
MenuButton(
{ global.currentScreenElement = ScreenElement.About },
Icons.Default.Info,
"O aplikaci"
)
Spacer(modifier = Modifier.height(80.dp)) Spacer(modifier = Modifier.width(menuSeparatorDimen))
MenuButton({ global.currentScreenElement = ScreenElement.Settings }, "Nastavení") MenuButton(
{ global.currentScreenElement = ScreenElement.Settings },
Icons.Default.Settings,
"Nastavení"
)
}
} }
} }
@Composable @Composable
fun MenuButton(onClick: () -> Unit, text: String) { fun MenuButton(onClick: () -> Unit, icon: ImageVector, altText: String) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Button( Button(
onClick = onClick, onClick = onClick,
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
@@ -76,12 +111,21 @@ fun MenuButton(onClick: () -> Unit, text: String) {
shape = RoundedCornerShape(global.dimens.roundedCorner), shape = RoundedCornerShape(global.dimens.roundedCorner),
color = PastelYellow color = PastelYellow
) )
.width(230.dp) .size(80.dp)
.height(80.dp)
) { ) {
Icon(
imageVector = icon,
contentDescription = altText,
modifier = Modifier.size(40.dp)
)
}
Text( Text(
text = text, text = altText,
fontSize = 23.sp modifier = Modifier.padding(5.dp).width(80.dp),
color = Color.White,
fontSize = 17.sp,
textAlign = TextAlign.Center
) )
} }
} }