From 32b3daff5b7222dbc6603b916b5d142d82dcefef Mon Sep 17 00:00:00 2001 From: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:39:38 +0800 Subject: [PATCH] fix(ui): Improve consistency of borders --- .../lawnchair/ui/preferences/about/About.kt | 12 ++++--- .../layout/LazyColumnPreferenceGroup.kt | 36 +++++++++++-------- .../destinations/FontSelectionPreference.kt | 1 - .../destinations/HiddenAppsPreferences.kt | 2 -- .../destinations/PickAppForGesture.kt | 1 - .../destinations/PreferencesDashboard.kt | 25 ++----------- .../destinations/SelectAppsForDrawerFolder.kt | 2 -- .../destinations/SelectIconPreference.kt | 2 +- 8 files changed, 32 insertions(+), 49 deletions(-) diff --git a/lawnchair/src/app/lawnchair/ui/preferences/about/About.kt b/lawnchair/src/app/lawnchair/ui/preferences/about/About.kt index 785161c709..217dba237c 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/about/About.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/about/About.kt @@ -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 = { diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/LazyColumnPreferenceGroup.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/LazyColumnPreferenceGroup.kt index 757a214730..b286654550 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/LazyColumnPreferenceGroup.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/LazyColumnPreferenceGroup.kt @@ -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 LazyListScope.preferenceGroupItems( items: List, 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( diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt index b7889b779d..41e4240980 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt @@ -193,7 +193,6 @@ fun FontSelection( isFirstChild = false, key = { _, family -> family.toString() }, contentType = { ContentType.FONT }, - dividerStartIndent = 40.dp, ) { _, family -> FontSelectionItem( adapter = adapter, diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/HiddenAppsPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/HiddenAppsPreferences.kt index 50693ed511..73059dbd97 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/HiddenAppsPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/HiddenAppsPreferences.kt @@ -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)) diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PickAppForGesture.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PickAppForGesture.kt index f5987e3661..f7890e8b93 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PickAppForGesture.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PickAppForGesture.kt @@ -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() { diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt index 572a774a59..8b94acc12e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt @@ -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, diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectAppsForDrawerFolder.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectAppsForDrawerFolder.kt index 7d91f7c947..393b783c0c 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectAppsForDrawerFolder.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectAppsForDrawerFolder.kt @@ -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( diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectIconPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectIconPreference.kt index 0810d845c5..9ef5cbcdb3 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectIconPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SelectIconPreference.kt @@ -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,