perf: title padding

This commit is contained in:
lisonge 2024-06-17 21:32:54 +08:00
parent 317906f858
commit ed1f810e73
3 changed files with 22 additions and 9 deletions

View File

@ -74,6 +74,7 @@ import li.songe.gkd.ui.component.SettingItem
import li.songe.gkd.ui.component.TextSwitch import li.songe.gkd.ui.component.TextSwitch
import li.songe.gkd.ui.destinations.SnapshotPageDestination import li.songe.gkd.ui.destinations.SnapshotPageDestination
import li.songe.gkd.ui.style.itemPadding 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.LocalLauncher
import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
@ -125,7 +126,7 @@ fun AdvancedPage() {
) { ) {
Text( Text(
text = "Shizuku", text = "Shizuku",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -151,7 +152,7 @@ fun AdvancedPage() {
Text( Text(
text = "HTTP服务", text = "HTTP服务",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -246,7 +247,7 @@ fun AdvancedPage() {
Text( Text(
text = "快照", text = "快照",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -336,7 +337,7 @@ fun AdvancedPage() {
Text( Text(
text = "其它", text = "其它",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )

View File

@ -52,6 +52,7 @@ import li.songe.gkd.ui.component.TextSwitch
import li.songe.gkd.ui.destinations.AboutPageDestination import li.songe.gkd.ui.destinations.AboutPageDestination
import li.songe.gkd.ui.destinations.AdvancedPageDestination import li.songe.gkd.ui.destinations.AdvancedPageDestination
import li.songe.gkd.ui.style.itemPadding 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.ui.theme.supportDynamicColor
import li.songe.gkd.util.DarkThemeOption import li.songe.gkd.util.DarkThemeOption
import li.songe.gkd.util.LoadStatus import li.songe.gkd.util.LoadStatus
@ -259,7 +260,7 @@ fun useSettingsPage(): ScaffoldExt {
Text( Text(
text = "常规", text = "常规",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -311,7 +312,7 @@ fun useSettingsPage(): ScaffoldExt {
Text( Text(
text = "更新", text = "更新",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -358,7 +359,7 @@ fun useSettingsPage(): ScaffoldExt {
Text( Text(
text = "日志", text = "日志",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
@ -395,7 +396,7 @@ fun useSettingsPage(): ScaffoldExt {
Text( Text(
text = "其它", text = "其它",
modifier = Modifier.itemPadding(), modifier = Modifier.titleItemPadding(),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )

View File

@ -5,7 +5,18 @@ import androidx.compose.material3.MenuDefaults
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp 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) fun Modifier.appItemPadding() = this then padding(10.dp, 10.dp)