fix preference style

This commit is contained in:
MM20 2025-06-29 16:17:34 +02:00
parent 0b1d6d8b6b
commit 1852c3e3d6
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
4 changed files with 93 additions and 38 deletions

View File

@ -54,6 +54,7 @@ fun PreferenceScreen(
topBarActions: @Composable RowScope.() -> Unit = {},
helpUrl: String? = null,
lazyColumnState: LazyListState = rememberLazyListState(),
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(12.dp),
content: LazyListScope.() -> Unit,
) {
PreferenceScreen(
@ -69,6 +70,7 @@ fun PreferenceScreen(
topBarActions = topBarActions,
helpUrl = helpUrl,
lazyColumnState = lazyColumnState,
verticalArrangement = verticalArrangement,
content = content
)
}
@ -80,6 +82,7 @@ fun PreferenceScreen(
topBarActions: @Composable RowScope.() -> Unit = {},
helpUrl: String? = null,
lazyColumnState: LazyListState = rememberLazyListState(),
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(12.dp),
content: LazyListScope.() -> Unit,
) {
val navController = LocalNavController.current
@ -104,7 +107,7 @@ fun PreferenceScreen(
}
}
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val activity = LocalActivity.current
Scaffold(
@ -168,7 +171,7 @@ fun PreferenceScreen(
.padding(it),
state = lazyColumnState,
content = content,
verticalArrangement = Arrangement.spacedBy(12.dp),
verticalArrangement = verticalArrangement,
contentPadding = PaddingValues(
12.dp
)

View File

@ -2,11 +2,13 @@ package de.mm20.launcher2.ui.settings.breezyweather
import androidx.activity.compose.LocalActivity
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.OpenInNew
import androidx.compose.material.icons.rounded.Info
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -34,36 +36,36 @@ fun BreezyWeatherSettingsScreen() {
) {
if (isBreezyInstalled == false) {
item {
Banner(
text = stringResource(
R.string.preference_breezyweather_integration_description,
stringResource(R.string.app_name),
),
icon = Icons.Rounded.Info,
modifier = Modifier.padding(16.dp),
primaryAction = {
Button(onClick = {
viewModel.downloadBreezyApp(activity)
}) {
Text(stringResource(R.string.action_install))
PreferenceCategory {
Banner(
text = stringResource(
R.string.preference_breezyweather_integration_description,
stringResource(R.string.app_name),
),
icon = Icons.Rounded.Info,
modifier = Modifier.background(MaterialTheme.colorScheme.surface).padding(16.dp),
primaryAction = {
Button(onClick = {
viewModel.downloadBreezyApp(activity)
}) {
Text(stringResource(R.string.action_install))
}
}
}
)
)
}
}
}
if (isBreezyInstalled == true) {
item {
Banner(
text = stringResource(
R.string.preference_breezyweather_integration_instructions,
stringResource(R.string.app_name),
),
icon = Icons.Rounded.Info,
modifier = Modifier.padding(16.dp),
)
}
item {
PreferenceCategory {
Banner(
text = stringResource(
R.string.preference_breezyweather_integration_instructions,
stringResource(R.string.app_name),
),
icon = Icons.Rounded.Info,
modifier = Modifier.background(MaterialTheme.colorScheme.surface).padding(16.dp),
)
Preference(
title = stringResource(R.string.preference_breezyweather_integration),
summary = stringResource(

View File

@ -2,12 +2,14 @@ package de.mm20.launcher2.ui.settings.hiddenitems
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Visibility
import androidx.compose.material.icons.rounded.Check
@ -27,6 +29,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
@ -53,7 +56,10 @@ fun HiddenItemsSettingsScreen() {
val showButton by viewModel.hiddenItemsButton.collectAsState()
PreferenceScreen(title = stringResource(R.string.preference_hidden_items)) {
PreferenceScreen(
title = stringResource(R.string.preference_hidden_items),
verticalArrangement = Arrangement.spacedBy(2.dp)
) {
item {
PreferenceCategory {
SwitchPreference(
@ -64,7 +70,14 @@ fun HiddenItemsSettingsScreen() {
)
}
}
items(apps, key = { it.key }) { searchable ->
item {
Box(
modifier = Modifier
.fillMaxWidth()
.height(8.dp)
)
}
itemsIndexed(apps, key = { i, it -> it.key }) { i, searchable ->
val icon by remember(searchable.key) {
viewModel.getIcon(searchable, with(density) { 32.dp.roundToPx() })
}.collectAsState(null)
@ -75,7 +88,21 @@ fun HiddenItemsSettingsScreen() {
var showDropdown by remember { mutableStateOf(false) }
Box {
val xs = MaterialTheme.shapes.extraSmall
val md = MaterialTheme.shapes.medium
Box(
modifier = Modifier
.clip(
xs.copy(
topStart = if (i == 0) md.topStart else xs.topStart,
topEnd = if (i == 0) md.topEnd else xs.topEnd,
bottomStart = if (i == apps.lastIndex) md.bottomStart else xs.bottomStart,
bottomEnd = if (i == apps.lastIndex) md.bottomEnd else xs.bottomEnd
)
)
.background(MaterialTheme.colorScheme.surface)
) {
HiddenItem(
modifier = Modifier
.fillMaxWidth()
@ -111,14 +138,11 @@ fun HiddenItemsSettingsScreen() {
Box(
modifier = Modifier
.fillMaxWidth()
.height(0.5.dp)
.background(
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f)
)
.height(8.dp)
)
}
items(other, key = { it.key }) { searchable ->
itemsIndexed(other, key = { i, it -> it.key }) { i, searchable ->
val icon by remember(searchable.key) {
viewModel.getIcon(searchable, with(density) { 32.dp.roundToPx() })
}.collectAsState(null)
@ -129,7 +153,21 @@ fun HiddenItemsSettingsScreen() {
var showDropdown by remember { mutableStateOf(false) }
Box {
val xs = MaterialTheme.shapes.extraSmall
val md = MaterialTheme.shapes.medium
Box(
modifier = Modifier
.clip(
xs.copy(
topStart = if (i == 0) md.topStart else xs.topStart,
topEnd = if (i == 0) md.topEnd else xs.topEnd,
bottomStart = if (i == other.lastIndex) md.bottomStart else xs.bottomStart,
bottomEnd = if (i == other.lastIndex) md.bottomEnd else xs.bottomEnd
)
)
.background(MaterialTheme.colorScheme.surface)
) {
HiddenItem(
modifier = Modifier
.fillMaxWidth()

View File

@ -5,11 +5,13 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowDownward
@ -119,6 +121,7 @@ fun LogScreen() {
Icon(Icons.Rounded.Share, contentDescription = null)
}
},
verticalArrangement = Arrangement.spacedBy(2.dp),
floatingActionButton = {
AnimatedVisibility(
listState.canScrollForward,
@ -139,12 +142,21 @@ fun LogScreen() {
},
lazyColumnState = listState,
) {
items(lines) {
itemsIndexed(lines) { i, it ->
val xs = MaterialTheme.shapes.extraSmall
val md = MaterialTheme.shapes.medium
val shape = xs.copy(
topStart = if (i == 0) md.topStart else xs.topStart,
topEnd = if (i == 0) md.topEnd else xs.topEnd,
bottomStart = if (i == lines.lastIndex) md.bottomStart else xs.bottomStart,
bottomEnd = if (i == lines.lastIndex) md.bottomEnd else xs.bottomEnd,
)
if (it is RawLogcatLine) {
Text(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface, MaterialTheme.shapes.medium)
.background(MaterialTheme.colorScheme.surface, shape)
.padding(16.dp),
text = it.line,
style = MaterialTheme.typography.bodySmall
@ -159,7 +171,7 @@ fun LogScreen() {
Column(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface, MaterialTheme.shapes.medium)
.background(MaterialTheme.colorScheme.surface, shape)
.padding(16.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {