From ed1f810e73f4cc9a2bd605ef41afe3f14e1b333b Mon Sep 17 00:00:00 2001 From: lisonge Date: Mon, 17 Jun 2024 21:32:54 +0800 Subject: [PATCH] perf: title padding --- app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt | 9 +++++---- .../kotlin/li/songe/gkd/ui/home/SettingsPage.kt | 9 +++++---- .../main/kotlin/li/songe/gkd/ui/style/Padding.kt | 13 ++++++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt index a6d247e..70aceb3 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/AdvancedPage.kt @@ -74,6 +74,7 @@ import li.songe.gkd.ui.component.SettingItem import li.songe.gkd.ui.component.TextSwitch import li.songe.gkd.ui.destinations.SnapshotPageDestination import li.songe.gkd.ui.style.itemPadding +import li.songe.gkd.ui.style.titleItemPadding import li.songe.gkd.util.LocalLauncher import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.ProfileTransitions @@ -125,7 +126,7 @@ fun AdvancedPage() { ) { Text( text = "Shizuku", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -151,7 +152,7 @@ fun AdvancedPage() { Text( text = "HTTP服务", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -246,7 +247,7 @@ fun AdvancedPage() { Text( text = "快照", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -336,7 +337,7 @@ fun AdvancedPage() { Text( text = "其它", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt index 5931087..c6d7a3f 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt @@ -52,6 +52,7 @@ import li.songe.gkd.ui.component.TextSwitch import li.songe.gkd.ui.destinations.AboutPageDestination import li.songe.gkd.ui.destinations.AdvancedPageDestination import li.songe.gkd.ui.style.itemPadding +import li.songe.gkd.ui.style.titleItemPadding import li.songe.gkd.ui.theme.supportDynamicColor import li.songe.gkd.util.DarkThemeOption import li.songe.gkd.util.LoadStatus @@ -259,7 +260,7 @@ fun useSettingsPage(): ScaffoldExt { Text( text = "常规", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -311,7 +312,7 @@ fun useSettingsPage(): ScaffoldExt { Text( text = "更新", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -358,7 +359,7 @@ fun useSettingsPage(): ScaffoldExt { Text( text = "日志", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) @@ -395,7 +396,7 @@ fun useSettingsPage(): ScaffoldExt { Text( text = "其它", - modifier = Modifier.itemPadding(), + modifier = Modifier.titleItemPadding(), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, ) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/style/Padding.kt b/app/src/main/kotlin/li/songe/gkd/ui/style/Padding.kt index effde4c..27df96d 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/style/Padding.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/style/Padding.kt @@ -5,7 +5,18 @@ import androidx.compose.material3.MenuDefaults import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -fun Modifier.itemPadding() = this then padding(16.dp, 12.dp) +val itemHorizontalPadding = 16.dp +val itemVerticalPadding = 12.dp + +fun Modifier.itemPadding() = this then padding(itemHorizontalPadding, itemVerticalPadding) + +fun Modifier.titleItemPadding() = + this then padding( + itemHorizontalPadding, + itemVerticalPadding + itemVerticalPadding / 2, + itemHorizontalPadding, + itemVerticalPadding - itemVerticalPadding / 2 + ) fun Modifier.appItemPadding() = this then padding(10.dp, 10.dp)