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.StartEllipsisText
import li.songe.gkd.ui.component.waitResult import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow import li.songe.gkd.util.appInfoCacheFlow
@ -94,7 +95,7 @@ fun ActivityLogPage() {
}) })
}) { contentPadding -> }) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(contentPadding), modifier = Modifier.scaffoldPadding(contentPadding),
) { ) {
items( items(
count = list.itemCount, 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.itemPadding
import li.songe.gkd.ui.style.itemVerticalPadding import li.songe.gkd.ui.style.itemVerticalPadding
import li.songe.gkd.ui.style.menuPadding 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.ui.style.titleItemPadding
import li.songe.gkd.util.LOCAL_SUBS_ID import li.songe.gkd.util.LOCAL_SUBS_ID
import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.LocalNavController
@ -178,7 +179,7 @@ fun AppConfigPage(appId: String) {
}, },
) { contentPadding -> ) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(contentPadding), modifier = Modifier.scaffoldPadding(contentPadding),
state = listState, state = listState,
) { ) {
itemsIndexed(globalGroups) { i, g -> 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.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn 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.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow import li.songe.gkd.util.appInfoCacheFlow
@ -150,9 +149,7 @@ fun AppItemPage(
} }
}) { contentPadding -> }) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier modifier = Modifier.scaffoldPadding(contentPadding)
.fillMaxSize()
.padding(contentPadding)
) { ) {
item { item {
Spacer(modifier = Modifier.height(10.dp)) Spacer(modifier = Modifier.height(10.dp))
@ -285,7 +282,7 @@ fun AppItemPage(
}, },
) )
} }
if (editable && subsRaw != null && subsItem != null) { if (editable && subsRaw != null) {
DropdownMenuItem( DropdownMenuItem(
text = { text = {
Text(text = "删除", color = MaterialTheme.colorScheme.error) 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.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn 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.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding 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.EnableGroupOption
import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
@ -126,7 +126,7 @@ fun CategoryPage(subsItemId: Long) {
} }
}) { contentPadding -> }) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(contentPadding) modifier = Modifier.scaffoldPadding(contentPadding)
) { ) {
items(categories, { it.key }) { category -> items(categories, { it.key }) { category ->
var selectedExpanded by remember { mutableStateOf(false) } 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.StartEllipsisText
import li.songe.gkd.ui.component.waitResult import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow import li.songe.gkd.util.appInfoCacheFlow
@ -139,7 +140,7 @@ fun ClickLogPage() {
}) })
}, content = { contentPadding -> }, content = { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(contentPadding), modifier = Modifier.scaffoldPadding(contentPadding),
) { ) {
items( items(
count = clickDataItems.itemCount, 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.EmptyHeight
import li.songe.gkd.ui.style.appItemPadding import li.songe.gkd.ui.style.appItemPadding
import li.songe.gkd.ui.style.menuPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.SortTypeOption import li.songe.gkd.util.SortTypeOption
@ -249,8 +250,11 @@ fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
} }
} }
}) })
}, content = { paddingValues -> }, content = { contentPadding ->
LazyColumn(modifier = Modifier.padding(paddingValues), state = listState) { LazyColumn(
modifier = Modifier.scaffoldPadding(contentPadding),
state = listState
) {
items(showAppInfos, { it.id }) { appInfo -> items(showAppInfos, { it.id }) { appInfo ->
Row( Row(
modifier = Modifier 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.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.json import li.songe.gkd.util.json
@ -137,7 +138,9 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
} }
}, },
) { paddingValues -> ) { paddingValues ->
LazyColumn(modifier = Modifier.padding(paddingValues)) { LazyColumn(
modifier = Modifier.scaffoldPadding(paddingValues)
) {
items(globalGroups, { g -> g.key }) { group -> items(globalGroups, { g -> g.key }) { group ->
Row( Row(
modifier = Modifier modifier = Modifier
@ -246,7 +249,7 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
) )
} }
) )
if (editable && rawSubs != null) { if (editable) {
DropdownMenuItem( DropdownMenuItem(
text = { text = {
Text(text = "删除", color = MaterialTheme.colorScheme.error) 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.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons 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.component.updateDialogOptions
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow import li.songe.gkd.util.appInfoCacheFlow
@ -81,8 +81,10 @@ fun SlowGroupPage() {
} }
) )
} }
) { padding -> ) { contentPadding ->
LazyColumn(modifier = Modifier.padding(padding)) { LazyColumn(
modifier = Modifier.scaffoldPadding(contentPadding)
) {
items( items(
ruleSummary.slowGlobalGroups, ruleSummary.slowGlobalGroups,
{ (_, r) -> "${r.subsItem.id}-${r.group.key}" } { (_, r) -> "${r.subsItem.id}-${r.group.key}" }
@ -90,12 +92,14 @@ fun SlowGroupPage() {
SlowGroupCard( SlowGroupCard(
modifier = Modifier modifier = Modifier
.clickable(onClick = throttle { .clickable(onClick = throttle {
navController.toDestinationsNavigator().navigate( navController
GlobalRulePageDestination( .toDestinationsNavigator()
rule.subsItem.id, .navigate(
group.key GlobalRulePageDestination(
rule.subsItem.id,
group.key
)
) )
)
}) })
.itemPadding(), .itemPadding(),
title = group.name, title = group.name,
@ -109,13 +113,15 @@ fun SlowGroupPage() {
SlowGroupCard( SlowGroupCard(
modifier = Modifier modifier = Modifier
.clickable(onClick = throttle { .clickable(onClick = throttle {
navController.toDestinationsNavigator().navigate( navController
AppItemPageDestination( .toDestinationsNavigator()
rule.subsItem.id, .navigate(
rule.app.id, AppItemPageDestination(
group.key rule.subsItem.id,
rule.app.id,
group.key
)
) )
)
}) })
.itemPadding(), .itemPadding(),
title = group.name, 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.StartEllipsisText
import li.songe.gkd.ui.component.waitResult import li.songe.gkd.ui.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight 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.IMPORT_SHORT_URL
import li.songe.gkd.util.LocalNavController import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
@ -119,7 +120,7 @@ fun SnapshotPage() {
}) })
}, content = { contentPadding -> }, content = { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(contentPadding), modifier = Modifier.scaffoldPadding(contentPadding),
) { ) {
items(snapshots, { it.id }) { snapshot -> items(snapshots, { it.id }) { snapshot ->
if (snapshot.id != snapshots.firstOrNull()?.id) { 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.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed 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.component.waitResult
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.menuPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.SortTypeOption import li.songe.gkd.util.SortTypeOption
@ -241,9 +241,10 @@ fun SubsPage(
} }
} }
}, },
) { padding -> ) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(padding), state = listState modifier = Modifier.scaffoldPadding(contentPadding),
state = listState
) { ) {
itemsIndexed(appAndConfigs, { i, a -> i.toString() + a.t0.id }) { _, a -> itemsIndexed(appAndConfigs, { i, a -> i.toString() + a.t0.id }) { _, a ->
val (appRaw, subsConfig, enableSize) = 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.EmptyHeight
import li.songe.gkd.ui.style.appItemPadding import li.songe.gkd.ui.style.appItemPadding
import li.songe.gkd.ui.style.menuPadding 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.LocalNavController
import li.songe.gkd.util.SortTypeOption import li.songe.gkd.util.SortTypeOption
import li.songe.gkd.util.mapHashCode import li.songe.gkd.util.mapHashCode
@ -259,9 +260,9 @@ fun useAppListPage(): ScaffoldExt {
} }
}) })
} }
) { padding -> ) { contentPadding ->
LazyColumn( LazyColumn(
modifier = Modifier.padding(padding), modifier = Modifier.scaffoldPadding(contentPadding),
state = listState state = listState
) { ) {
items(orderedAppInfos, { it.id }) { appInfo -> items(orderedAppInfos, { it.id }) { appInfo ->

View File

@ -1,5 +1,6 @@
package li.songe.gkd.ui.style package li.songe.gkd.ui.style
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MenuDefaults import androidx.compose.material3.MenuDefaults
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -23,3 +24,10 @@ fun Modifier.appItemPadding() = this.padding(10.dp, 10.dp)
fun Modifier.menuPadding() = this fun Modifier.menuPadding() = this
.padding(MenuDefaults.DropdownMenuItemContentPadding) .padding(MenuDefaults.DropdownMenuItemContentPadding)
.padding(vertical = 8.dp) .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> <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"> <style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon"> <item name="windowSplashScreenAnimatedIcon">

View File

@ -1,6 +1,8 @@
<resources> <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"> <style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon"> <item name="windowSplashScreenAnimatedIcon">