perf: translucent navigation (#774)
Some checks failed
Build-Apk / build (push) Has been cancelled

This commit is contained in:
二刺螈 2024-11-14 17:24:45 +08:00
parent 84710bf7d1
commit dff1c5a15b
14 changed files with 65 additions and 37 deletions

View File

@ -40,6 +40,7 @@ import li.songe.gkd.ui.component.EmptyText
import li.songe.gkd.ui.component.StartEllipsisText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow
@ -94,7 +95,7 @@ fun ActivityLogPage() {
})
}) { contentPadding ->
LazyColumn(
modifier = Modifier.padding(contentPadding),
modifier = Modifier.scaffoldPadding(contentPadding),
) {
items(
count = list.itemCount,

View File

@ -67,6 +67,7 @@ import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.ui.style.itemVerticalPadding
import li.songe.gkd.ui.style.menuPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.ui.style.titleItemPadding
import li.songe.gkd.util.LOCAL_SUBS_ID
import li.songe.gkd.util.LocalNavController
@ -178,7 +179,7 @@ fun AppConfigPage(appId: String) {
},
) { contentPadding ->
LazyColumn(
modifier = Modifier.padding(contentPadding),
modifier = Modifier.scaffoldPadding(contentPadding),
state = listState,
) {
itemsIndexed(globalGroups) { i, g ->

View File

@ -8,10 +8,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
@ -73,6 +71,7 @@ import li.songe.gkd.ui.component.TowLineText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow
@ -150,9 +149,7 @@ fun AppItemPage(
}
}) { contentPadding ->
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(contentPadding)
modifier = Modifier.scaffoldPadding(contentPadding)
) {
item {
Spacer(modifier = Modifier.height(10.dp))
@ -285,7 +282,7 @@ fun AppItemPage(
},
)
}
if (editable && subsRaw != null && subsItem != null) {
if (editable && subsRaw != null) {
DropdownMenuItem(
text = {
Text(text = "删除", color = MaterialTheme.colorScheme.error)

View File

@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
@ -57,6 +56,7 @@ import li.songe.gkd.ui.component.updateDialogOptions
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.EnableGroupOption
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
@ -126,7 +126,7 @@ fun CategoryPage(subsItemId: Long) {
}
}) { contentPadding ->
LazyColumn(
modifier = Modifier.padding(contentPadding)
modifier = Modifier.scaffoldPadding(contentPadding)
) {
items(categories, { it.key }) { category ->
var selectedExpanded by remember { mutableStateOf(false) }

View File

@ -63,6 +63,7 @@ import li.songe.gkd.ui.component.EmptyText
import li.songe.gkd.ui.component.StartEllipsisText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow
@ -139,7 +140,7 @@ fun ClickLogPage() {
})
}, content = { contentPadding ->
LazyColumn(
modifier = Modifier.padding(contentPadding),
modifier = Modifier.scaffoldPadding(contentPadding),
) {
items(
count = clickDataItems.itemCount,

View File

@ -76,6 +76,7 @@ import li.songe.gkd.ui.component.TowLineText
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.appItemPadding
import li.songe.gkd.ui.style.menuPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.SortTypeOption
@ -249,8 +250,11 @@ fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
}
}
})
}, content = { paddingValues ->
LazyColumn(modifier = Modifier.padding(paddingValues), state = listState) {
}, content = { contentPadding ->
LazyColumn(
modifier = Modifier.scaffoldPadding(contentPadding),
state = listState
) {
items(showAppInfos, { it.id }) { appInfo ->
Row(
modifier = Modifier

View File

@ -71,6 +71,7 @@ import li.songe.gkd.ui.component.TowLineText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.json
@ -137,7 +138,9 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
}
},
) { paddingValues ->
LazyColumn(modifier = Modifier.padding(paddingValues)) {
LazyColumn(
modifier = Modifier.scaffoldPadding(paddingValues)
) {
items(globalGroups, { g -> g.key }) { group ->
Row(
modifier = Modifier
@ -246,7 +249,7 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
)
}
)
if (editable && rawSubs != null) {
if (editable) {
DropdownMenuItem(
text = {
Text(text = "删除", color = MaterialTheme.colorScheme.error)

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
@ -38,6 +37,7 @@ import li.songe.gkd.ui.component.EmptyText
import li.songe.gkd.ui.component.updateDialogOptions
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow
@ -81,8 +81,10 @@ fun SlowGroupPage() {
}
)
}
) { padding ->
LazyColumn(modifier = Modifier.padding(padding)) {
) { contentPadding ->
LazyColumn(
modifier = Modifier.scaffoldPadding(contentPadding)
) {
items(
ruleSummary.slowGlobalGroups,
{ (_, r) -> "${r.subsItem.id}-${r.group.key}" }
@ -90,12 +92,14 @@ fun SlowGroupPage() {
SlowGroupCard(
modifier = Modifier
.clickable(onClick = throttle {
navController.toDestinationsNavigator().navigate(
GlobalRulePageDestination(
rule.subsItem.id,
group.key
navController
.toDestinationsNavigator()
.navigate(
GlobalRulePageDestination(
rule.subsItem.id,
group.key
)
)
)
})
.itemPadding(),
title = group.name,
@ -109,13 +113,15 @@ fun SlowGroupPage() {
SlowGroupCard(
modifier = Modifier
.clickable(onClick = throttle {
navController.toDestinationsNavigator().navigate(
AppItemPageDestination(
rule.subsItem.id,
rule.app.id,
group.key
navController
.toDestinationsNavigator()
.navigate(
AppItemPageDestination(
rule.subsItem.id,
rule.app.id,
group.key
)
)
)
})
.itemPadding(),
title = group.name,

View File

@ -59,6 +59,7 @@ import li.songe.gkd.ui.component.EmptyText
import li.songe.gkd.ui.component.StartEllipsisText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.IMPORT_SHORT_URL
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
@ -119,7 +120,7 @@ fun SnapshotPage() {
})
}, content = { contentPadding ->
LazyColumn(
modifier = Modifier.padding(contentPadding),
modifier = Modifier.scaffoldPadding(contentPadding),
) {
items(snapshots, { it.id }) { snapshot ->
if (snapshot.id != snapshots.firstOrNull()?.id) {

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
@ -64,6 +63,7 @@ import li.songe.gkd.ui.component.TowLineText
import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.menuPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.SortTypeOption
@ -241,9 +241,10 @@ fun SubsPage(
}
}
},
) { padding ->
) { contentPadding ->
LazyColumn(
modifier = Modifier.padding(padding), state = listState
modifier = Modifier.scaffoldPadding(contentPadding),
state = listState
) {
itemsIndexed(appAndConfigs, { i, a -> i.toString() + a.t0.id }) { _, a ->
val (appRaw, subsConfig, enableSize) = a

View File

@ -67,6 +67,7 @@ import li.songe.gkd.ui.component.QueryPkgAuthCard
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.appItemPadding
import li.songe.gkd.ui.style.menuPadding
import li.songe.gkd.ui.style.scaffoldPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.SortTypeOption
import li.songe.gkd.util.mapHashCode
@ -259,9 +260,9 @@ fun useAppListPage(): ScaffoldExt {
}
})
}
) { padding ->
) { contentPadding ->
LazyColumn(
modifier = Modifier.padding(padding),
modifier = Modifier.scaffoldPadding(contentPadding),
state = listState
) {
items(orderedAppInfos, { it.id }) { appInfo ->

View File

@ -1,5 +1,6 @@
package li.songe.gkd.ui.style
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MenuDefaults
import androidx.compose.ui.Modifier
@ -23,3 +24,10 @@ fun Modifier.appItemPadding() = this.padding(10.dp, 10.dp)
fun Modifier.menuPadding() = this
.padding(MenuDefaults.DropdownMenuItemContentPadding)
.padding(vertical = 8.dp)
fun Modifier.scaffoldPadding(values: PaddingValues): Modifier {
return this.padding(
top = values.calculateTopPadding(),
// 被 LazyColumn( 使用时, 移除 bottom padding, 否则 底部导航栏 无法实现透明背景
)
}

View File

@ -1,6 +1,8 @@
<resources>
<style name="AppTheme" parent="android:Theme.Material.NoActionBar"></style>
<style name="AppTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">

View File

@ -1,6 +1,8 @@
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar"></style>
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">