Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import com.github.kr328.clash.main.ui.openLink
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.theme.MihomoTheme
import com.github.kr328.clash.ui.theme.PreviewMihomo
import me.zhanghai.compose.preference.Preference
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.preference
import me.zhanghai.compose.preference.preferenceCategory

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -26,26 +26,24 @@ fun ApkBrokenScreen() {
ProvidePreferenceLocals {
val context = LocalContext.current
LazyColumn(modifier = Modifier.fillMaxSize(), contentPadding = innerPadding) {
item(key = "tips_application_broken") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.application_broken)) },
summary = { Text(stringResource(R.string.application_broken_tips)) },
enabled = false,
)
}
preference(
key = "tips_application_broken",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.application_broken)) },
summary = { Text(stringResource(R.string.application_broken_tips)) },
enabled = false,
)
preferenceCategory(
key = "cat_reinstall",
title = { Text(stringResource(R.string.reinstall)) },
)
item(key = "github_releases") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.github_releases)) },
summary = { Text(CMFA_GITHUB) },
onClick = { context.openLink(CMFA_GITHUB) },
)
}
preference(
key = "github_releases",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.github_releases)) },
summary = { Text(CMFA_GITHUB) },
onClick = { context.openLink(CMFA_GITHUB) },
)
}
}
}
Expand Down
77 changes: 36 additions & 41 deletions app/src/main/kotlin/com/github/kr328/clash/main/ui/HelpScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import com.github.kr328.clash.R
import com.github.kr328.clash.ui.component.MihomoScaffold
import com.github.kr328.clash.ui.theme.MihomoTheme
import com.github.kr328.clash.ui.theme.PreviewMihomo
import me.zhanghai.compose.preference.Preference
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.preference
import me.zhanghai.compose.preference.preferenceCategory

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -29,51 +29,46 @@ fun HelpScreen(modifier: Modifier = Modifier) {
ProvidePreferenceLocals {
val context = LocalContext.current
LazyColumn(modifier = Modifier.fillMaxSize(), contentPadding = innerPadding) {
item(key = "tips_help") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.help)) },
summary = { Text(AnnotatedString.fromHtml(stringResource(R.string.tips_help))) },
enabled = false,
)
}
preference(
key = "tips_help",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.help)) },
summary = { Text(AnnotatedString.fromHtml(stringResource(R.string.tips_help))) },
enabled = false,
)
preferenceCategory(
key = "cat_document",
title = { Text(stringResource(R.string.document)) },
)
item(key = "clash_wiki") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_wiki)) },
summary = { Text(CLASH_WIKI) },
onClick = { context.openLink(CLASH_WIKI) },
)
}
item(key = "clash_meta_wiki") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_wiki)) },
summary = { Text(CLASH_META_WIKI) },
onClick = { context.openLink(CLASH_META_WIKI) },
)
}
preference(
key = "clash_wiki",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_wiki)) },
summary = { Text(CLASH_WIKI) },
onClick = { context.openLink(CLASH_WIKI) },
)
preference(
key = "clash_meta_wiki",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_wiki)) },
summary = { Text(CLASH_META_WIKI) },
onClick = { context.openLink(CLASH_META_WIKI) },
)
preferenceCategory(key = "cat_sources", title = { Text(stringResource(R.string.sources)) })
item(key = "clash_meta_core") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_core)) },
summary = { Text(CLASH_META_CORE) },
onClick = { context.openLink(CLASH_META_CORE) },
)
}
item(key = "clash_meta_for_android") {
Preference(
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_for_android)) },
summary = { Text(CMFA_GITHUB) },
onClick = { context.openLink(CMFA_GITHUB) },
)
}
preference(
key = "clash_meta_core",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_core)) },
summary = { Text(CLASH_META_CORE) },
onClick = { context.openLink(CLASH_META_CORE) },
)
preference(
key = "clash_meta_for_android",
modifier = Modifier.fillMaxWidth(),
title = { Text(stringResource(R.string.clash_meta_for_android)) },
summary = { Text(CMFA_GITHUB) },
onClick = { context.openLink(CMFA_GITHUB) },
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import com.github.kr328.clash.ui.icon.BaselineStack
import com.github.kr328.clash.ui.icon.MihomoIcons
import com.github.kr328.clash.ui.theme.MihomoTheme
import com.github.kr328.clash.ui.theme.PreviewMihomo
import me.zhanghai.compose.preference.ListPreference
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.SwitchPreference
import me.zhanghai.compose.preference.listPreference
import me.zhanghai.compose.preference.preferenceCategory
import me.zhanghai.compose.preference.switchPreference

@Composable
fun AppSettingsScreen(
Expand Down Expand Up @@ -69,65 +69,56 @@ private fun AppSettingsContent(
key = "cat_behavior",
title = { Text(stringResource(R.string.behavior)) },
)
item(key = "auto_restart") {
SwitchPreference(
value = uiState.autoRestart,
onValueChange = onAutoRestartChange,
icon = { Icon(imageVector = MihomoIcons.BaselineRestore, contentDescription = null) },
title = { Text(stringResource(R.string.auto_restart)) },
summary = { Text(stringResource(R.string.allow_clash_auto_restart)) },
)
}
switchPreference(
key = "auto_restart",
value = uiState.autoRestart,
onValueChange = onAutoRestartChange,
icon = { Icon(imageVector = MihomoIcons.BaselineRestore, contentDescription = null) },
title = { Text(stringResource(R.string.auto_restart)) },
summary = { Text(stringResource(R.string.allow_clash_auto_restart)) },
)

preferenceCategory(
key = "cat_interface",
title = { Text(stringResource(R.string.interface_)) },
)
item(key = "dark_mode") {
ListPreference(
value = uiState.darkMode,
onValueChange = onDarkModeChange,
values = listOf(DarkMode.Auto, DarkMode.ForceLight, DarkMode.ForceDark),
icon = {
Icon(imageVector = MihomoIcons.BaselineBrightness4, contentDescription = null)
},
title = { Text(stringResource(R.string.dark_mode)) },
summary = { Text(stringResource(uiState.darkMode.summaryRes)) },
valueToText = {
androidx.compose.ui.text.AnnotatedString(stringResource(it.summaryRes))
},
)
}
item(key = "hide_app_icon") {
SwitchPreference(
value = uiState.hideAppIcon,
onValueChange = onHideAppIconChange,
icon = { Icon(imageVector = MihomoIcons.BaselineHide, contentDescription = null) },
title = { Text(stringResource(R.string.hide_app_icon_title)) },
summary = { Text(stringResource(R.string.hide_app_icon_desc)) },
)
}
item(key = "hide_from_recents") {
SwitchPreference(
value = uiState.hideFromRecents,
onValueChange = onHideFromRecentsChange,
icon = { Icon(imageVector = MihomoIcons.BaselineStack, contentDescription = null) },
title = { Text(stringResource(R.string.hide_from_recents_title)) },
summary = { Text(stringResource(R.string.hide_from_recents_desc)) },
)
}
listPreference(
key = "dark_mode",
value = uiState.darkMode,
onValueChange = onDarkModeChange,
values = listOf(DarkMode.Auto, DarkMode.ForceLight, DarkMode.ForceDark),
icon = { Icon(imageVector = MihomoIcons.BaselineBrightness4, contentDescription = null) },
title = { Text(stringResource(R.string.dark_mode)) },
summary = { Text(stringResource(uiState.darkMode.summaryRes)) },
valueToText = { androidx.compose.ui.text.AnnotatedString(stringResource(it.summaryRes)) },
)
switchPreference(
key = "hide_app_icon",
value = uiState.hideAppIcon,
onValueChange = onHideAppIconChange,
icon = { Icon(imageVector = MihomoIcons.BaselineHide, contentDescription = null) },
title = { Text(stringResource(R.string.hide_app_icon_title)) },
summary = { Text(stringResource(R.string.hide_app_icon_desc)) },
)
switchPreference(
key = "hide_from_recents",
value = uiState.hideFromRecents,
onValueChange = onHideFromRecentsChange,
icon = { Icon(imageVector = MihomoIcons.BaselineStack, contentDescription = null) },
title = { Text(stringResource(R.string.hide_from_recents_title)) },
summary = { Text(stringResource(R.string.hide_from_recents_desc)) },
)

preferenceCategory(key = "cat_service", title = { Text(stringResource(R.string.service)) })
item(key = "show_traffic") {
SwitchPreference(
value = uiState.dynamicNotification,
onValueChange = onDynamicNotificationChange,
enabled = !clashRunning,
icon = { Icon(imageVector = MihomoIcons.BaselineDomain, contentDescription = null) },
title = { Text(stringResource(R.string.show_traffic)) },
summary = { Text(stringResource(R.string.show_traffic_summary)) },
)
}
switchPreference(
key = "show_traffic",
value = uiState.dynamicNotification,
onValueChange = onDynamicNotificationChange,
enabled = !clashRunning,
icon = { Icon(imageVector = MihomoIcons.BaselineDomain, contentDescription = null) },
title = { Text(stringResource(R.string.show_traffic)) },
summary = { Text(stringResource(R.string.show_traffic_summary)) },
)
}
}
}
Expand Down
Loading