mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-15 19:22:26 +08:00
perf: canQueryPkg icon
This commit is contained in:
parent
6edc402bd2
commit
3f7971b438
|
@ -13,7 +13,6 @@ import kotlinx.coroutines.flow.updateAndGet
|
|||
import li.songe.gkd.app
|
||||
import li.songe.gkd.appScope
|
||||
import li.songe.gkd.shizuku.shizukuIsSafeOK
|
||||
import li.songe.gkd.util.appInfoCacheFlow
|
||||
import li.songe.gkd.util.initOrResetAppInfoCache
|
||||
import li.songe.gkd.util.launchTry
|
||||
|
||||
|
@ -133,10 +132,7 @@ fun updatePermissionState() {
|
|||
shizukuOkState
|
||||
).forEach { it.updateAndGet() }
|
||||
|
||||
if (canQueryPkgState.stateFlow.value != canQueryPkgState.updateAndGet() ||
|
||||
// https://github.com/gkd-kit/gkd/issues/543
|
||||
appInfoCacheFlow.value.count { e -> !e.value.isSystem && !e.value.hidden } < 16
|
||||
) {
|
||||
if (canQueryPkgState.stateFlow.value != canQueryPkgState.updateAndGet()) {
|
||||
appScope.launchTry {
|
||||
initOrResetAppInfoCache()
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.automirrored.filled.Sort
|
||||
import androidx.compose.material.icons.filled.Android
|
||||
import androidx.compose.material.icons.filled.Apps
|
||||
import androidx.compose.material.icons.filled.AppsOutage
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.PriorityHigh
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
|
@ -79,6 +80,7 @@ import li.songe.gkd.util.storeFlow
|
|||
val appListNav = BottomNavItem(
|
||||
label = "应用", icon = Icons.Default.Apps
|
||||
)
|
||||
val appListOutageNav = appListNav.copy(icon = Icons.Default.AppsOutage)
|
||||
|
||||
@Composable
|
||||
fun useAppListPage(): ScaffoldExt {
|
||||
|
@ -124,7 +126,14 @@ fun useAppListPage(): ScaffoldExt {
|
|||
}
|
||||
})
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
|
||||
return ScaffoldExt(navItem = appListNav,
|
||||
val canQueryPkg by canQueryPkgState.stateFlow.collectAsState()
|
||||
val navItem = if (canQueryPkg) {
|
||||
appListNav
|
||||
} else {
|
||||
appListOutageNav
|
||||
}
|
||||
return ScaffoldExt(
|
||||
navItem = navItem,
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
DisposableEffect(null) {
|
||||
|
@ -169,7 +178,6 @@ fun useAppListPage(): ScaffoldExt {
|
|||
)
|
||||
}
|
||||
} else {
|
||||
val canQueryPkg by canQueryPkgState.stateFlow.collectAsState()
|
||||
if (!canQueryPkg) {
|
||||
IconButton(onClick = vm.viewModelScope.launchAsFn {
|
||||
checkOrRequestPermission(context, canQueryPkgState)
|
||||
|
|
Loading…
Reference in New Issue
Block a user