Beautify settings page.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package me.zobrist.tichucounter.ui.settings
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -9,7 +10,11 @@ import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||
import androidx.compose.material.icons.outlined.Check
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Alignment.Companion.End
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.InspectableModifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -79,21 +84,22 @@ fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit)
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)) {
|
||||
TextField(
|
||||
value = name,
|
||||
onValueChange = { },
|
||||
trailingIcon = {
|
||||
Switch(
|
||||
checked = value,
|
||||
modifier = Modifier.padding(end = 10.dp),
|
||||
onCheckedChange = { updateValue(it) })
|
||||
},
|
||||
singleLine = true,
|
||||
readOnly = true,
|
||||
modifier = Modifier
|
||||
.padding(20.dp)) {
|
||||
Column() {
|
||||
Text(name, style = MaterialTheme.typography.bodyLarge)
|
||||
Text(value.toString(), style = MaterialTheme.typography.labelLarge)
|
||||
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
)
|
||||
{
|
||||
Switch(
|
||||
checked = value,
|
||||
modifier = Modifier.align(End),
|
||||
onCheckedChange = { updateValue(it)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,44 +109,42 @@ fun <T> StringSetting(name: String, map: Map<T, Int>, selected: T, onSelected: (
|
||||
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
val source = remember { MutableInteractionSource() }
|
||||
|
||||
if (source.collectIsPressedAsState().value) {
|
||||
expanded = true
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)) {
|
||||
TextField(
|
||||
value = stringResource(map[selected]!!),
|
||||
onValueChange = { },
|
||||
trailingIcon = { Icon(Icons.Outlined.ArrowDropDown, contentDescription = null) },
|
||||
singleLine = true,
|
||||
label = { Text(name) },
|
||||
readOnly = true,
|
||||
interactionSource = source,
|
||||
modifier = Modifier
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
)
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
map.forEach {
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onSelected(it.key)
|
||||
expanded = false
|
||||
},
|
||||
text = { Text(stringResource(it.value)) },
|
||||
trailingIcon = {
|
||||
if (it.key == selected) {
|
||||
Icon(Icons.Outlined.Check, contentDescription = null)
|
||||
}
|
||||
})
|
||||
.padding(20.dp)
|
||||
.clickable { expanded = true }) {
|
||||
Column() {
|
||||
Text(name, style = MaterialTheme.typography.bodyLarge)
|
||||
Text(stringResource(map[selected]!!), style = MaterialTheme.typography.labelLarge)
|
||||
}
|
||||
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()) {
|
||||
Icon(
|
||||
Icons.Outlined.ArrowDropDown,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.align(End),)
|
||||
}
|
||||
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
map.forEach {
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onSelected(it.key)
|
||||
expanded = false
|
||||
},
|
||||
text = { Text(stringResource(it.value)) },
|
||||
trailingIcon = {
|
||||
if (it.key == selected) {
|
||||
Icon(Icons.Outlined.Check, contentDescription = null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user