perf: store showSystemApp/showHiddenApp

This commit is contained in:
lisonge 2024-03-03 00:13:53 +08:00
parent 6206b8635c
commit caa328aead
3 changed files with 8 additions and 8 deletions

View File

@ -181,14 +181,13 @@ fun useAppListPage(): ScaffoldExt {
Checkbox(
checked = showSystemApp,
onCheckedChange = {
vm.showSystemAppFlow.value =
!vm.showSystemAppFlow.value
storeFlow.update { s -> s.copy(showSystemApp = !showSystemApp) }
})
Text("显示系统应用")
}
},
onClick = {
vm.showSystemAppFlow.value = !vm.showSystemAppFlow.value
storeFlow.update { s -> s.copy(showSystemApp = !showSystemApp) }
},
)
DropdownMenuItem(
@ -199,14 +198,13 @@ fun useAppListPage(): ScaffoldExt {
Checkbox(
checked = showHiddenApp,
onCheckedChange = {
vm.showHiddenAppFlow.value =
!vm.showHiddenAppFlow.value
storeFlow.update { s -> s.copy(showHiddenApp = !s.showHiddenApp) }
})
Text("显示隐藏应用")
}
},
onClick = {
vm.showHiddenAppFlow.value = !vm.showHiddenAppFlow.value
storeFlow.update { s -> s.copy(showHiddenApp = !showHiddenApp) }
},
)
}

View File

@ -234,8 +234,8 @@ class HomeVm @Inject constructor() : ViewModel() {
val sortTypeFlow = storeFlow.map(viewModelScope) { s ->
SortTypeOption.allSubObject.find { o -> o.value == s.sortType } ?: SortTypeOption.SortByName
}
val showSystemAppFlow = MutableStateFlow(true)
val showHiddenAppFlow = MutableStateFlow(false)
val showSystemAppFlow = storeFlow.map(viewModelScope) { s -> s.showSystemApp }
val showHiddenAppFlow = storeFlow.map(viewModelScope) { s -> s.showHiddenApp }
val searchStrFlow = MutableStateFlow("")
private val debounceSearchStrFlow = searchStrFlow.debounce(200)
.stateIn(viewModelScope, SharingStarted.Eagerly, searchStrFlow.value)

View File

@ -57,6 +57,8 @@ data class Store(
val enableDarkTheme: Boolean? = null,
val enableAbFloatWindow: Boolean = true,
val sortType: Int = SortTypeOption.SortByName.value,
val showSystemApp: Boolean = true,
val showHiddenApp: Boolean = false,
)
val storeFlow by lazy {