mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
feat: tow line text, inner disable explain,
This commit is contained in:
parent
6f2d47ea04
commit
eaa7ee0ee1
|
@ -1,6 +1,7 @@
|
|||
package li.songe.gkd.ui
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
@ -19,6 +20,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.Sort
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
|
@ -30,6 +32,7 @@ import androidx.compose.material3.RadioButton
|
|||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -177,6 +180,7 @@ fun AppConfigPage(appId: String) {
|
|||
}
|
||||
val checked = getChecked(excludeData, g.group, appId, appInfo)
|
||||
AppGroupCard(
|
||||
vm = vm,
|
||||
group = g.group,
|
||||
checked = checked,
|
||||
onClick = {
|
||||
|
@ -211,15 +215,20 @@ fun AppConfigPage(appId: String) {
|
|||
}
|
||||
}
|
||||
items(appGroups) { g ->
|
||||
AppGroupCard(g.group, g.enable, onClick = {
|
||||
navController.navigate(
|
||||
AppItemPageDestination(
|
||||
g.subsItem.id,
|
||||
appId,
|
||||
g.group.key,
|
||||
AppGroupCard(
|
||||
vm = vm,
|
||||
group = g.group,
|
||||
checked = g.enable,
|
||||
onClick = {
|
||||
navController.navigate(
|
||||
AppItemPageDestination(
|
||||
g.subsItem.id,
|
||||
appId,
|
||||
g.group.key,
|
||||
)
|
||||
)
|
||||
)
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
vm.viewModelScope.launchTry {
|
||||
DbSet.subsConfigDao.insert(
|
||||
g.config?.copy(enable = it) ?: SubsConfig(
|
||||
|
@ -248,10 +257,28 @@ fun AppConfigPage(appId: String) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val innerDisabledDlg by vm.innerDisabledDlgFlow.collectAsState()
|
||||
if (innerDisabledDlg) {
|
||||
AlertDialog(
|
||||
title = { Text(text = "内置禁用") },
|
||||
text = {
|
||||
Text(text = "此规则组已经在其 apps 字段中配置对当前应用的禁用, 因此无法手动开启规则组\n\n提示: 这种情况一般在此全局规则无法适配/跳过适配当前应用时出现")
|
||||
},
|
||||
onDismissRequest = { vm.innerDisabledDlgFlow.value = false },
|
||||
confirmButton = {
|
||||
TextButton(onClick = { vm.innerDisabledDlgFlow.value = false }) {
|
||||
Text(text = "我知道了")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppGroupCard(
|
||||
vm: AppConfigVm,
|
||||
group: RawSubscription.RawGroupProps,
|
||||
checked: Boolean?,
|
||||
onClick: () -> Unit,
|
||||
|
@ -313,7 +340,13 @@ private fun AppGroupCard(
|
|||
Switch(
|
||||
checked = false,
|
||||
enabled = false,
|
||||
onCheckedChange = onCheckedChange
|
||||
onCheckedChange = null,
|
||||
modifier = Modifier.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
) {
|
||||
vm.innerDisabledDlgFlow.value = true
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,5 +74,7 @@ class AppConfigVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel
|
|||
}
|
||||
}.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
||||
|
||||
val innerDisabledDlgFlow = MutableStateFlow(false)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ import li.songe.gkd.data.RawSubscription
|
|||
import li.songe.gkd.data.SubsConfig
|
||||
import li.songe.gkd.data.stringify
|
||||
import li.songe.gkd.db.DbSet
|
||||
import li.songe.gkd.ui.component.TowLineText
|
||||
import li.songe.gkd.ui.component.getDialogResult
|
||||
import li.songe.gkd.ui.destinations.GroupItemPageDestination
|
||||
import li.songe.gkd.ui.style.itemPadding
|
||||
|
@ -132,19 +133,10 @@ fun AppItemPage(
|
|||
)
|
||||
}
|
||||
}, title = {
|
||||
Column {
|
||||
Text(
|
||||
text = subsRaw?.name ?: subsItemId.toString(),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(
|
||||
text = appInfoCache[appId]?.name ?: appRaw.name ?: appId,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
TowLineText(
|
||||
title = subsRaw?.name ?: subsItemId.toString(),
|
||||
subTitle = appInfoCache[appId]?.name ?: appRaw.name ?: appId
|
||||
)
|
||||
}, actions = {})
|
||||
}, floatingActionButton = {
|
||||
if (editable) {
|
||||
|
|
|
@ -40,7 +40,6 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
|
@ -50,6 +49,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import li.songe.gkd.data.CategoryConfig
|
||||
import li.songe.gkd.data.RawSubscription
|
||||
import li.songe.gkd.db.DbSet
|
||||
import li.songe.gkd.ui.component.TowLineText
|
||||
import li.songe.gkd.ui.component.getDialogResult
|
||||
import li.songe.gkd.ui.style.itemPadding
|
||||
import li.songe.gkd.util.EnableGroupOption
|
||||
|
@ -94,14 +94,10 @@ fun CategoryPage(subsItemId: Long) {
|
|||
)
|
||||
}
|
||||
}, title = {
|
||||
Column {
|
||||
Text(
|
||||
text = subsRaw?.name ?: subsItemId.toString(),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(text = "规则类别", style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
TowLineText(
|
||||
title = subsRaw?.name ?: subsItemId.toString(),
|
||||
subTitle = "规则类别"
|
||||
)
|
||||
}, actions = {})
|
||||
}, floatingActionButton = {
|
||||
if (editable) {
|
||||
|
|
|
@ -69,6 +69,7 @@ import li.songe.gkd.data.stringify
|
|||
import li.songe.gkd.db.DbSet
|
||||
import li.songe.gkd.service.launcherAppId
|
||||
import li.songe.gkd.ui.component.AppBarTextField
|
||||
import li.songe.gkd.ui.component.TowLineText
|
||||
import li.songe.gkd.ui.style.appItemPadding
|
||||
import li.songe.gkd.ui.style.menuPadding
|
||||
import li.songe.gkd.util.LocalNavController
|
||||
|
@ -129,19 +130,10 @@ fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
|
|||
modifier = Modifier.focusRequester(focusRequester)
|
||||
)
|
||||
} else {
|
||||
Column {
|
||||
Text(
|
||||
text = rawSubs?.name ?: subsItemId.toString(),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(
|
||||
text = (group?.name ?: groupKey.toString()),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
TowLineText(
|
||||
title = rawSubs?.name ?: subsItemId.toString(),
|
||||
subTitle = (group?.name ?: groupKey.toString())
|
||||
)
|
||||
}
|
||||
}, actions = {
|
||||
if (showSearchBar) {
|
||||
|
|
|
@ -63,6 +63,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import li.songe.gkd.data.RawSubscription
|
||||
import li.songe.gkd.data.SubsConfig
|
||||
import li.songe.gkd.db.DbSet
|
||||
import li.songe.gkd.ui.component.TowLineText
|
||||
import li.songe.gkd.ui.component.getDialogResult
|
||||
import li.songe.gkd.ui.destinations.GlobalRuleExcludePageDestination
|
||||
import li.songe.gkd.ui.destinations.GroupItemPageDestination
|
||||
|
@ -116,14 +117,10 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
|||
)
|
||||
}
|
||||
}, title = {
|
||||
Column {
|
||||
Text(
|
||||
text = rawSubs?.name ?: subsItemId.toString(),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(text = "全局规则", style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
TowLineText(
|
||||
title = rawSubs?.name ?: subsItemId.toString(),
|
||||
subTitle = "全局规则"
|
||||
)
|
||||
})
|
||||
},
|
||||
floatingActionButton = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package li.songe.gkd.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
|
@ -46,7 +45,6 @@ import androidx.compose.ui.focus.FocusRequester
|
|||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
|
@ -58,6 +56,7 @@ import li.songe.gkd.data.SubsConfig
|
|||
import li.songe.gkd.db.DbSet
|
||||
import li.songe.gkd.ui.component.AppBarTextField
|
||||
import li.songe.gkd.ui.component.SubsAppCard
|
||||
import li.songe.gkd.ui.component.TowLineText
|
||||
import li.songe.gkd.ui.component.getDialogResult
|
||||
import li.songe.gkd.ui.destinations.AppItemPageDestination
|
||||
import li.songe.gkd.ui.style.menuPadding
|
||||
|
@ -150,14 +149,10 @@ fun SubsPage(
|
|||
modifier = Modifier.focusRequester(focusRequester)
|
||||
)
|
||||
} else {
|
||||
Column {
|
||||
Text(
|
||||
text = subsRaw?.name ?: subsItemId.toString(),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(text = "应用规则", style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
TowLineText(
|
||||
title = subsRaw?.name ?: subsItemId.toString(),
|
||||
subTitle = "应用规则",
|
||||
)
|
||||
}
|
||||
}, actions = {
|
||||
if (showSearchBar) {
|
||||
|
|
28
app/src/main/kotlin/li/songe/gkd/ui/component/TowLineText.kt
Normal file
28
app/src/main/kotlin/li/songe/gkd/ui/component/TowLineText.kt
Normal file
|
@ -0,0 +1,28 @@
|
|||
package li.songe.gkd.ui.component
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
||||
@Composable
|
||||
fun TowLineText(
|
||||
title: String,
|
||||
subTitle: String
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = title,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
Text(
|
||||
text = subTitle,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
}
|
|
@ -189,8 +189,8 @@ val ruleSummaryFlow by lazy {
|
|||
val subGlobalGroupToRules =
|
||||
mutableMapOf<RawSubscription.RawGlobalGroup, List<GlobalRule>>()
|
||||
rawSubs.globalGroups.filter { g ->
|
||||
g.valid && (subGlobalSubsConfigs.find { c -> c.groupKey == g.key }?.enable
|
||||
?: g.enable ?: true)
|
||||
(subGlobalSubsConfigs.find { c -> c.groupKey == g.key }?.enable
|
||||
?: g.enable ?: true) && g.valid
|
||||
}.forEach { groupRaw ->
|
||||
val config = subGlobalSubsConfigs.find { c -> c.groupKey == groupRaw.key }
|
||||
val g = ResolvedGlobalGroup(
|
||||
|
|
Loading…
Reference in New Issue
Block a user