Skip to content

Commit

Permalink
perf: change text desc
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Aug 4, 2024
1 parent e86b323 commit 1dcc0b0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 61 deletions.
38 changes: 13 additions & 25 deletions app/src/main/kotlin/li/songe/gkd/ui/AppConfigPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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
Expand All @@ -32,7 +31,6 @@ 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
Expand All @@ -52,27 +50,29 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.viewModelScope
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.ramcosta.composedestinations.navigation.navigate
import kotlinx.coroutines.flow.update
import li.songe.gkd.data.ExcludeData
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.buildDialogOptions
import li.songe.gkd.ui.destinations.AppItemPageDestination
import li.songe.gkd.ui.destinations.GlobalRulePageDestination
import li.songe.gkd.ui.style.EmptyHeight
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.titleItemPadding
import li.songe.gkd.util.LOCAL_SUBS_ID
import li.songe.gkd.util.LocalMainViewModel
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.ResolvedGroup
import li.songe.gkd.util.RuleSortOption
import li.songe.gkd.util.appInfoCacheFlow
import li.songe.gkd.util.launchTry
import com.ramcosta.composedestinations.navigation.navigate
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.util.throttle

@RootNavGraph
Expand Down Expand Up @@ -186,7 +186,6 @@ fun AppConfigPage(appId: String) {
val checked = getChecked(excludeData, g.group, appId, appInfo)
TitleGroupCard(globalGroups, i) {
AppGroupCard(
vm = vm,
group = g.group,
checked = checked,
onClick = throttle {
Expand Down Expand Up @@ -226,7 +225,6 @@ fun AppConfigPage(appId: String) {
itemsIndexed(appGroups) { i, g ->
TitleGroupCard(appGroups, i) {
AppGroupCard(
vm = vm,
group = g.group,
checked = g.enable,
onClick = {
Expand Down Expand Up @@ -268,23 +266,6 @@ 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
Expand Down Expand Up @@ -313,12 +294,12 @@ private fun TitleGroupCard(groups: List<ResolvedGroup>, i: Int, content: @Compos

@Composable
private fun AppGroupCard(
vm: AppConfigVm,
group: RawSubscription.RawGroupProps,
checked: Boolean?,
onClick: () -> Unit,
onCheckedChange: ((Boolean) -> Unit)?,
) {
val mainVm = LocalMainViewModel.current
Row(
modifier = Modifier
.clickable(onClick = onClick)
Expand Down Expand Up @@ -380,7 +361,14 @@ private fun AppGroupCard(
interactionSource = remember { MutableInteractionSource() },
indication = null,
) {
vm.innerDisabledDlgFlow.value = true
mainVm.dialogFlow.value = buildDialogOptions(
title = "内置禁用",
text = "此规则组已经在其 apps 字段中配置对当前应用的禁用, 因此无法手动开启规则组\n\n提示: 这种情况一般在此全局规则无法适配/跳过适配/单独适配当前应用时出现",
confirmText = "我知道了",
confirmAction = {
mainVm.dialogFlow.value = null
},
)
}
)
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/kotlin/li/songe/gkd/ui/AppConfigVm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import javax.inject.Inject
class AppConfigVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
private val args = AppConfigPageDestination.argsFrom(stateHandle)

val innerDisabledDlgFlow = MutableStateFlow(false)

private val latestGlobalLogsFlow = DbSet.clickLogDao.queryAppLatest(
args.appId,
SubsConfig.GlobalGroupType
Expand Down
38 changes: 12 additions & 26 deletions app/src/main/kotlin/li/songe/gkd/ui/SlowGroupPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,33 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
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
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
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 com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.ramcosta.composedestinations.navigation.navigate
import li.songe.gkd.ui.component.buildDialogOptions
import li.songe.gkd.ui.destinations.AppItemPageDestination
import li.songe.gkd.ui.destinations.GlobalRulePageDestination
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding
import li.songe.gkd.util.LocalMainViewModel
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.appInfoCacheFlow
import com.ramcosta.composedestinations.navigation.navigate
import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.util.ruleSummaryFlow
import li.songe.gkd.util.throttle

Expand All @@ -53,11 +49,9 @@ import li.songe.gkd.util.throttle
@Composable
fun SlowGroupPage() {
val navController = LocalNavController.current
val mainVm = LocalMainViewModel.current
val ruleSummary by ruleSummaryFlow.collectAsState()
val appInfoCache by appInfoCacheFlow.collectAsState()
var showInfoDlg by remember {
mutableStateOf(false)
}

val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
Scaffold(
Expand All @@ -77,8 +71,13 @@ fun SlowGroupPage() {
},
title = { Text(text = if (ruleSummary.slowGroupCount > 0) "缓慢查询-${ruleSummary.slowGroupCount}" else "缓慢查询") },
actions = {
IconButton(onClick = {
showInfoDlg = true
IconButton(onClick = throttle {
mainVm.dialogFlow.value = buildDialogOptions(
title = "缓慢查询",
text = "任意单个规则同时满足以下 3 个条件即判定为缓慢查询\n\n1. 选择器右侧无法快速查询且不是主动查询, 或内部使用<<且无法快速查询\n2. preKeys 为空\n3. matchTime 为空或大于 10s",
confirmText = "我知道了",
confirmAction = { mainVm.dialogFlow.value = null }
)
}) {
Icon(Icons.Outlined.Info, contentDescription = null)
}
Expand Down Expand Up @@ -138,19 +137,6 @@ fun SlowGroupPage() {
}
}
}

if (showInfoDlg) {
AlertDialog(
onDismissRequest = { showInfoDlg = false },
title = { Text(text = "什么是缓慢查询") },
text = { Text(text = "任意单个规则同时满足以下 3 个条件即判定为缓慢查询\n\n1. 选择器右侧无法快速查询且不是主动查询, 或内部使用<<且无法快速查询\n2. preKeys 为空\n3. matchTime 为空或大于 10s") },
confirmButton = {
TextButton(onClick = { showInfoDlg = false }) {
Text(text = "确定")
}
},
)
}
}

@Composable
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/li/songe/gkd/ui/SnapshotPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fun SnapshotPage() {
)
HorizontalDivider()
Text(
text = "分享数据",
text = "分享到其他应用",
modifier = Modifier
.clickable(onClick = vm.viewModelScope.launchAsFn {
selectedSnapshot = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private fun SubsMenuItem(
}
DropdownMenuItem(
text = {
Text(text = "分享数据")
Text(text = "导出数据")
},
onClick = {
onExpandedChange(false)
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.Upload
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
Expand Down Expand Up @@ -150,7 +150,7 @@ fun useSettingsPage(): ScaffoldExt {
.fillMaxWidth()
.padding(16.dp)
Text(
text = "分享数据", modifier = Modifier
text = "分享到其他应用", modifier = Modifier
.clickable(onClick = throttle {
showShareLogDlg = false
vm.viewModelScope.launchTry(Dispatchers.IO) {
Expand Down Expand Up @@ -291,7 +291,7 @@ fun useSettingsPage(): ScaffoldExt {

TextSwitch(
name = "系统提示",
desc = "系统样式触发提示,频率较高时会被忽略",
desc = "系统样式触发提示,频率较高时不显示",
checked = store.useSystemToast,
onCheckedChange = {
storeFlow.value = store.copy(
Expand Down Expand Up @@ -402,7 +402,7 @@ fun useSettingsPage(): ScaffoldExt {
}
})

SettingItem(title = "分享日志", imageVector = Icons.Default.Share, onClick = {
SettingItem(title = "导出日志", imageVector = Icons.Default.Upload, onClick = {
showShareLogDlg = true
})

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/kotlin/li/songe/gkd/ui/home/SubsManagePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.Upgrade
import androidx.compose.material.icons.filled.Upload
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
Expand Down Expand Up @@ -233,7 +235,7 @@ fun useSubsManagePage(): ScaffoldExt {
vm.showShareDataIdsFlow.value = selectedIds
}) {
Icon(
imageVector = Icons.Default.Share,
imageVector = Icons.Default.Upload,
contentDescription = null,
)
}
Expand Down Expand Up @@ -450,7 +452,7 @@ private fun ShareDataDialog(vm: HomeVm) {
.fillMaxWidth()
.padding(16.dp)
Text(
text = "分享数据", modifier = Modifier
text = "分享到其他应用", modifier = Modifier
.clickable(onClick = throttle {
vm.showShareDataIdsFlow.value = null
vm.viewModelScope.launchTry(Dispatchers.IO) {
Expand Down

0 comments on commit 1dcc0b0

Please sign in to comment.