mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
feat: app config page show subsItem title
Some checks failed
Build-Apk / build (push) Has been cancelled
Some checks failed
Build-Apk / build (push) Has been cancelled
This commit is contained in:
parent
ed1f810e73
commit
1cec4f0c2c
|
@ -14,7 +14,7 @@ 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
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
@ -61,10 +61,13 @@ import li.songe.gkd.db.DbSet
|
||||||
import li.songe.gkd.ui.destinations.AppItemPageDestination
|
import li.songe.gkd.ui.destinations.AppItemPageDestination
|
||||||
import li.songe.gkd.ui.destinations.GlobalRulePageDestination
|
import li.songe.gkd.ui.destinations.GlobalRulePageDestination
|
||||||
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.menuPadding
|
import li.songe.gkd.ui.style.menuPadding
|
||||||
|
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
|
||||||
import li.songe.gkd.util.ProfileTransitions
|
import li.songe.gkd.util.ProfileTransitions
|
||||||
|
import li.songe.gkd.util.ResolvedGroup
|
||||||
import li.songe.gkd.util.RuleSortOption
|
import li.songe.gkd.util.RuleSortOption
|
||||||
import li.songe.gkd.util.appInfoCacheFlow
|
import li.songe.gkd.util.appInfoCacheFlow
|
||||||
import li.songe.gkd.util.launchTry
|
import li.songe.gkd.util.launchTry
|
||||||
|
@ -174,71 +177,77 @@ fun AppConfigPage(appId: String) {
|
||||||
modifier = Modifier.padding(contentPadding),
|
modifier = Modifier.padding(contentPadding),
|
||||||
state = listState,
|
state = listState,
|
||||||
) {
|
) {
|
||||||
items(globalGroups) { g ->
|
itemsIndexed(globalGroups) { i, g ->
|
||||||
val excludeData = remember(g.config?.exclude) {
|
val excludeData = remember(g.config?.exclude) {
|
||||||
ExcludeData.parse(g.config?.exclude)
|
ExcludeData.parse(g.config?.exclude)
|
||||||
}
|
}
|
||||||
val checked = getChecked(excludeData, g.group, appId, appInfo)
|
val checked = getChecked(excludeData, g.group, appId, appInfo)
|
||||||
AppGroupCard(
|
TitleGroupCard(globalGroups, i) {
|
||||||
vm = vm,
|
AppGroupCard(
|
||||||
group = g.group,
|
vm = vm,
|
||||||
checked = checked,
|
group = g.group,
|
||||||
onClick = {
|
checked = checked,
|
||||||
navController.navigate(
|
onClick = {
|
||||||
GlobalRulePageDestination(
|
navController.navigate(
|
||||||
g.subsItem.id,
|
GlobalRulePageDestination(
|
||||||
g.group.key
|
g.subsItem.id,
|
||||||
|
g.group.key
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
) { newChecked ->
|
||||||
) { newChecked ->
|
vm.viewModelScope.launchTry {
|
||||||
vm.viewModelScope.launchTry {
|
DbSet.subsConfigDao.insert(
|
||||||
DbSet.subsConfigDao.insert(
|
(g.config ?: SubsConfig(
|
||||||
(g.config ?: SubsConfig(
|
type = SubsConfig.GlobalGroupType,
|
||||||
type = SubsConfig.GlobalGroupType,
|
subsItemId = g.subsItem.id,
|
||||||
subsItemId = g.subsItem.id,
|
groupKey = g.group.key,
|
||||||
groupKey = g.group.key,
|
)).copy(
|
||||||
)).copy(
|
exclude = excludeData.copy(
|
||||||
exclude = excludeData.copy(
|
appIds = excludeData.appIds.toMutableMap().apply {
|
||||||
appIds = excludeData.appIds.toMutableMap().apply {
|
set(appId, !newChecked)
|
||||||
set(appId, !newChecked)
|
}
|
||||||
}
|
).stringify()
|
||||||
).stringify()
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
if (globalGroups.isNotEmpty() && appGroups.isNotEmpty()) {
|
if (globalGroups.isNotEmpty() && appGroups.isNotEmpty()) {
|
||||||
HorizontalDivider()
|
HorizontalDivider(
|
||||||
|
modifier = Modifier.padding(0.dp, itemVerticalPadding),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items(appGroups) { g ->
|
itemsIndexed(appGroups) { i, g ->
|
||||||
AppGroupCard(
|
TitleGroupCard(appGroups, i) {
|
||||||
vm = vm,
|
AppGroupCard(
|
||||||
group = g.group,
|
vm = vm,
|
||||||
checked = g.enable,
|
group = g.group,
|
||||||
onClick = {
|
checked = g.enable,
|
||||||
navController.navigate(
|
onClick = {
|
||||||
AppItemPageDestination(
|
navController.navigate(
|
||||||
g.subsItem.id,
|
AppItemPageDestination(
|
||||||
appId,
|
g.subsItem.id,
|
||||||
g.group.key,
|
appId,
|
||||||
|
g.group.key,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
) {
|
||||||
) {
|
vm.viewModelScope.launchTry {
|
||||||
vm.viewModelScope.launchTry {
|
DbSet.subsConfigDao.insert(
|
||||||
DbSet.subsConfigDao.insert(
|
g.config?.copy(enable = it) ?: SubsConfig(
|
||||||
g.config?.copy(enable = it) ?: SubsConfig(
|
type = SubsConfig.AppGroupType,
|
||||||
type = SubsConfig.AppGroupType,
|
subsItemId = g.subsItem.id,
|
||||||
subsItemId = g.subsItem.id,
|
appId = appId,
|
||||||
appId = appId,
|
groupKey = g.group.key,
|
||||||
groupKey = g.group.key,
|
enable = it
|
||||||
enable = it
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,6 +285,30 @@ fun AppConfigPage(appId: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun TitleGroupCard(groups: List<ResolvedGroup>, i: Int, content: @Composable () -> Unit) {
|
||||||
|
val lastGroup = groups.getOrNull(i - 1)
|
||||||
|
val g = groups[i]
|
||||||
|
if (g.subsItem !== lastGroup?.subsItem) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = g.subscription.name,
|
||||||
|
modifier = Modifier.titleItemPadding(),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
maxLines = 1,
|
||||||
|
softWrap = false,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AppGroupCard(
|
private fun AppGroupCard(
|
||||||
vm: AppConfigVm,
|
vm: AppConfigVm,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user