fix(ui): Improve consistency of borders

This commit is contained in:
SuperDragonXD
2025-11-07 13:39:38 +08:00
committed by Pun Butrach
parent 2533b57504
commit 32b3daff5b
8 changed files with 32 additions and 49 deletions
@@ -196,9 +196,9 @@ fun About(
}
preferenceGroupItems(
items = uiState.coreTeam,
key = { _, it -> it.name },
isFirstChild = false,
heading = { stringResource(id = R.string.product) },
key = { _, it -> it.name },
) { _, it ->
ContributorRow(
member = it,
@@ -206,9 +206,9 @@ fun About(
}
preferenceGroupItems(
items = uiState.supportAndPr,
key = { _, it -> it.name },
isFirstChild = false,
heading = { stringResource(id = R.string.support_and_pr) },
key = { _, it -> it.name },
) { _, it ->
ContributorRow(
member = it,
@@ -216,9 +216,9 @@ fun About(
}
preferenceGroupItems(
items = uiState.bottomLinks,
key = { _, it -> it.labelResId },
isFirstChild = false,
heading = { stringResource(id = R.string.community) },
key = { _, it -> it.labelResId },
) { _, it ->
HorizontalLawnchairLink(
iconResId = it.iconResId,
@@ -242,12 +242,14 @@ fun About(
)
}
}
item {
Spacer(Modifier.height(3.dp))
}
item {
PreferenceGroupItem(
cutTop = true,
cutBottom = true,
cutBottom = false,
) {
PreferenceDivider()
ClickablePreference(
label = stringResource(id = R.string.privacy_policy),
onClick = {
@@ -22,11 +22,12 @@ import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.lawnchair.ui.theme.preferenceGroupColor
@@ -34,12 +35,14 @@ fun LazyListScope.preferenceGroupItems(
count: Int,
isFirstChild: Boolean,
showDividers: Boolean = true,
dividerStartIndent: Dp = 0.dp,
dividerEndIndent: Dp = 0.dp,
heading: (@Composable () -> String)? = null,
heading:
@Composable()
(() -> String)? = null,
key: ((index: Int) -> Any)? = null,
contentType: (index: Int) -> Any? = { null },
itemContent: @Composable LazyItemScope.(index: Int) -> Unit,
itemContent:
@Composable()
(LazyItemScope.(index: Int) -> Unit),
) {
item {
if (!isFirstChild) {
@@ -50,7 +53,12 @@ fun LazyListScope.preferenceGroupItems(
items(count, key, contentType) {
PreferenceGroupItem(cutTop = it > 0, cutBottom = it < count - 1) {
if (showDividers && it > 0) {
PreferenceDivider(startIndent = dividerStartIndent, endIndent = dividerEndIndent)
HorizontalDivider(
modifier = Modifier,
// .padding(start = dividerStartIndent + 16.dp, end = dividerEndIndent + 16.dp)
thickness = 3.dp,
color = MaterialTheme.colorScheme.surface,
)
}
itemContent(it)
}
@@ -61,19 +69,19 @@ inline fun <T> LazyListScope.preferenceGroupItems(
items: List<T>,
isFirstChild: Boolean,
showDividers: Boolean = true,
dividerStartIndent: Dp = 0.dp,
dividerEndIndent: Dp = 0.dp,
noinline heading: (@Composable () -> String)? = null,
noinline heading:
@Composable()
(() -> String)? = null,
noinline key: ((index: Int, item: T) -> Any)? = null,
noinline contentType: (index: Int) -> Any? = { null },
crossinline itemContent: @Composable LazyItemScope.(index: Int, item: T) -> Unit,
crossinline itemContent:
@Composable()
(LazyItemScope.(index: Int, item: T) -> Unit),
) {
preferenceGroupItems(
items.size,
isFirstChild,
showDividers = showDividers,
dividerStartIndent = dividerStartIndent,
dividerEndIndent = dividerEndIndent,
heading,
key = if (key != null) { index: Int -> key(index, items[index]) } else null,
contentType = contentType,
@@ -90,8 +98,8 @@ fun PreferenceGroupItem(
content: @Composable () -> Unit,
) {
val shape = remember(cutTop, cutBottom) {
val top = if (cutTop) 0.dp else 12.dp
val bottom = if (cutBottom) 0.dp else 12.dp
val top = if (cutTop) 0.dp else 28.dp
val bottom = if (cutBottom) 0.dp else 28.dp
RoundedCornerShape(top, top, bottom, bottom)
}
Surface(
@@ -193,7 +193,6 @@ fun FontSelection(
isFirstChild = false,
key = { _, family -> family.toString() },
contentType = { ContentType.FONT },
dividerStartIndent = 40.dp,
) { _, family ->
FontSelectionItem(
adapter = adapter,
@@ -92,7 +92,6 @@ fun HiddenAppsPreferences(
preferenceGroupItems(
items = apps,
isFirstChild = true,
dividerStartIndent = 40.dp,
) { _, app ->
AppItem(
app = app,
@@ -110,7 +109,6 @@ fun HiddenAppsPreferences(
preferenceGroupItems(
count = 20,
isFirstChild = true,
dividerStartIndent = 40.dp,
) {
AppItemPlaceholder {
Spacer(Modifier.width(24.dp))
@@ -20,7 +20,6 @@ import app.lawnchair.util.App
import app.lawnchair.util.appsState
import app.lawnchair.util.kotlinxJson
import com.android.launcher3.R
import kotlinx.serialization.encodeToString
@Composable
fun PickAppForGesture() {
@@ -51,6 +51,7 @@ import app.lawnchair.ui.preferences.components.controls.WarningPreference
import app.lawnchair.ui.preferences.components.layout.ClickableIcon
import app.lawnchair.ui.preferences.components.layout.DividerColumn
import app.lawnchair.ui.preferences.components.layout.PreferenceDivider
import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
import app.lawnchair.ui.preferences.components.layout.PreferenceLayout
import app.lawnchair.ui.preferences.components.layout.PreferenceTemplate
import app.lawnchair.ui.preferences.data.liveinfo.SyncLiveInformation
@@ -112,7 +113,7 @@ fun PreferencesDashboard(
Spacer(modifier = Modifier.height(8.dp))
}
PreferenceCategoryGroup {
PreferenceGroup {
PreferenceCategory(
label = stringResource(R.string.general_label),
description = stringResource(R.string.general_description),
@@ -201,28 +202,6 @@ fun PreferencesDashboard(
}
}
@Composable
fun PreferenceCategoryGroup(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
val color = preferenceGroupColor()
Surface(
modifier = modifier.padding(horizontal = 16.dp),
shape = MaterialTheme.shapes.extraLarge,
color = color,
tonalElevation = if (isSelectedThemeDark) 1.dp else 0.dp,
) {
DividerColumn(
content = content,
startIndent = (-16).dp,
endIndent = (-16).dp,
color = MaterialTheme.colorScheme.surface,
)
}
}
@Composable
fun RowScope.PreferencesOverflowMenu(
currentRoute: PreferenceRootRoute,
@@ -122,7 +122,6 @@ fun SelectAppsForDrawerFolder(
preferenceGroupItems(
count = 20,
isFirstChild = true,
dividerStartIndent = 40.dp,
) {
AppItemPlaceholder {
Spacer(Modifier.width(24.dp))
@@ -134,7 +133,6 @@ fun SelectAppsForDrawerFolder(
preferenceGroupItems(
filteredApps,
isFirstChild = true,
dividerStartIndent = 40.dp,
) { _, app ->
key(app.toString()) {
AppItem(
@@ -78,9 +78,9 @@ fun SelectIconPreference(componentKey: ComponentKey) {
}
}
preferenceGroupItems(
heading = { stringResource(id = R.string.pick_icon_from_label) },
items = iconPacks,
isFirstChild = !hasOverride,
heading = { stringResource(id = R.string.pick_icon_from_label) },
) { _, iconPack ->
AppItem(
label = iconPack.name,