fix: adjust control grid height and card padding

This commit is contained in:
Cutiful 2025-06-12 11:39:51 +07:00
parent 39224f66c4
commit c6108fc807
2 changed files with 5 additions and 5 deletions

View File

@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -39,13 +40,14 @@ fun ControlCard(
isOn: Boolean, isOn: Boolean,
onToggle: (Boolean) -> Unit onToggle: (Boolean) -> Unit
) { ) {
val backgroundColor = if (isOn) DarkGreen else if (isSystemInDarkTheme()) Color.Black else Color.White val backgroundColor = if (isOn) DarkGreen else MaterialTheme.colorScheme.surfaceContainer
val iconTint = if (isOn) Color(0xFFB2FF59) else Color(0xFF4CAF50) val iconTint = if (isOn) Color(0xFFB2FF59) else Color(0xFF4CAF50)
val textColor = if (isSystemInDarkTheme()) Color.White else Color.Black val textColor = if (isSystemInDarkTheme()) Color.White else Color.Black
val trackColor = if (isSystemInDarkTheme()) DarkGrey else DividerColor val trackColor = if (isSystemInDarkTheme()) DarkGrey else DividerColor
Column( Column(
modifier = Modifier modifier = Modifier
.padding(vertical = 8.dp)
.clip(RoundedCornerShape(12.dp)) .clip(RoundedCornerShape(12.dp))
.border(1.dp, MainGreen.copy(alpha = 0.4f), RoundedCornerShape(12.dp)) .border(1.dp, MainGreen.copy(alpha = 0.4f), RoundedCornerShape(12.dp))
.background(backgroundColor) .background(backgroundColor)

View File

@ -40,7 +40,6 @@ fun ControlActuatorScreen() {
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxWidth()) { Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxWidth()) {
Text("Control Actuator", style = MaterialTheme.typography.titleMedium) Text("Control Actuator", style = MaterialTheme.typography.titleMedium)
} }
}, },
navigationIcon = { navigationIcon = {
IconButton(onClick = { }) { IconButton(onClick = { }) {
@ -87,12 +86,11 @@ fun ControlActuatorScreen() {
@Composable @Composable
fun ControlGrid(iconRes: Int, items: List<String>) { fun ControlGrid(iconRes: Int, items: List<String>) {
val states = remember { items.map { mutableStateOf(false) } } val states = remember { items.map { mutableStateOf(false) } }
val gridHeight = (items.size / 2.0).coerceAtLeast(1.0) * 170
LazyVerticalGrid( LazyVerticalGrid(
columns = GridCells.Fixed(2), columns = GridCells.Fixed(2),
modifier = Modifier modifier = Modifier.fillMaxWidth().height(gridHeight.dp),
.fillMaxWidth()
.height(300.dp),
verticalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp) horizontalArrangement = Arrangement.spacedBy(12.dp)
) { ) {