feat: improve settings page
This commit is contained in:
parent
4e5f97f082
commit
cdaec764cb
2 changed files with 53 additions and 16 deletions
|
|
@ -9,13 +9,15 @@ import androidx.compose.animation.*
|
||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.NavigateBefore
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.filled.Style
|
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.aliucord.manager.R
|
import com.aliucord.manager.R
|
||||||
|
|
@ -29,9 +31,14 @@ fun SettingsScreen(
|
||||||
viewModel: SettingsViewModel = getViewModel(),
|
viewModel: SettingsViewModel = getViewModel(),
|
||||||
onClickBack: () -> Unit
|
onClickBack: () -> Unit
|
||||||
) {
|
) {
|
||||||
|
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
|
||||||
|
decayAnimationSpec = rememberSplineBasedDecay(),
|
||||||
|
state = rememberTopAppBarState()
|
||||||
|
)
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||||
topBar = {
|
topBar = {
|
||||||
MediumTopAppBar(
|
LargeTopAppBar(
|
||||||
title = { Text(stringResource(R.string.settings)) },
|
title = { Text(stringResource(R.string.settings)) },
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onClickBack) {
|
IconButton(onClick = onClickBack) {
|
||||||
|
|
@ -40,7 +47,8 @@ fun SettingsScreen(
|
||||||
contentDescription = stringResource(R.string.back)
|
contentDescription = stringResource(R.string.back)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
scrollBehavior = scrollBehavior
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
|
|
@ -61,10 +69,13 @@ fun SettingsScreen(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupHeader(stringResource(R.string.appearance))
|
||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier.clickable(onClick = viewModel::showThemeDialog),
|
modifier = Modifier.clickable(onClick = viewModel::showThemeDialog),
|
||||||
headlineText = { Text(stringResource(R.string.theme)) },
|
headlineText = { Text(stringResource(R.string.theme)) },
|
||||||
supportingText = { Text(stringResource(R.string.theme_setting_description)) },
|
supportingText = { Text(stringResource(R.string.theme_setting_description)) },
|
||||||
|
leadingContent = { Icon(Icons.Default.Style, null) },
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
FilledTonalButton(onClick = viewModel::showThemeDialog) {
|
FilledTonalButton(onClick = viewModel::showThemeDialog) {
|
||||||
Text(preferences.theme.displayName)
|
Text(preferences.theme.displayName)
|
||||||
|
|
@ -75,10 +86,18 @@ fun SettingsScreen(
|
||||||
SwitchSetting(
|
SwitchSetting(
|
||||||
checked = preferences.dynamicColor,
|
checked = preferences.dynamicColor,
|
||||||
title = { Text(stringResource(R.string.dynamic_color)) },
|
title = { Text(stringResource(R.string.dynamic_color)) },
|
||||||
onCheckedChange = { preferences.dynamicColor = it }
|
onCheckedChange = { preferences.dynamicColor = it },
|
||||||
|
icon = { Icon(Icons.Default.Palette, null) }
|
||||||
)
|
)
|
||||||
|
|
||||||
Divider()
|
GroupHeader(stringResource(R.string.advanced))
|
||||||
|
|
||||||
|
SwitchSetting(
|
||||||
|
checked = preferences.replaceBg,
|
||||||
|
title = { Text(stringResource(R.string.replace_bg)) },
|
||||||
|
onCheckedChange = { preferences.replaceBg = it },
|
||||||
|
icon = { Icon(Icons.Default.AppShortcut, null) }
|
||||||
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -91,16 +110,11 @@ fun SettingsScreen(
|
||||||
singleLine = true
|
singleLine = true
|
||||||
)
|
)
|
||||||
|
|
||||||
SwitchSetting(
|
|
||||||
checked = preferences.replaceBg,
|
|
||||||
title = { Text(stringResource(R.string.replace_bg)) },
|
|
||||||
onCheckedChange = { preferences.replaceBg = it }
|
|
||||||
)
|
|
||||||
|
|
||||||
SwitchSetting(
|
SwitchSetting(
|
||||||
checked = preferences.devMode,
|
checked = preferences.devMode,
|
||||||
title = { Text(stringResource(R.string.advanced_options)) },
|
title = { Text(stringResource(R.string.developer_options)) },
|
||||||
onCheckedChange = { preferences.devMode = it }
|
onCheckedChange = { preferences.devMode = it },
|
||||||
|
icon = { Icon(Icons.Default.Code, null) }
|
||||||
)
|
)
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
|
|
@ -136,7 +150,8 @@ fun SettingsScreen(
|
||||||
checked = preferences.debuggable,
|
checked = preferences.debuggable,
|
||||||
title = { Text(stringResource(R.string.debuggable)) },
|
title = { Text(stringResource(R.string.debuggable)) },
|
||||||
description = { Text(stringResource(R.string.debuggable_description)) },
|
description = { Text(stringResource(R.string.debuggable_description)) },
|
||||||
onCheckedChange = { preferences.debuggable = it }
|
onCheckedChange = { preferences.debuggable = it },
|
||||||
|
icon = { Icon(Icons.Default.BugReport, null) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,3 +247,23 @@ fun ThemeDialog(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun GroupHeader(
|
||||||
|
title: String,
|
||||||
|
color: Color = MaterialTheme.colorScheme.primary
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.padding(start = 12.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
contentAlignment = Alignment.CenterStart
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
color = color,
|
||||||
|
fontSize = LocalTextStyle.current.fontSize.times(0.95f),
|
||||||
|
fontWeight = FontWeight.SemiBold
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
<string name="reinstall">Reinstall</string>
|
<string name="reinstall">Reinstall</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="advanced_options">Show advanced options</string>
|
<string name="developer_options">Developer options</string>
|
||||||
<string name="debuggable">Debuggable</string>
|
<string name="debuggable">Debuggable</string>
|
||||||
<string name="debuggable_description">Enable debuggable flag</string>
|
<string name="debuggable_description">Enable debuggable flag</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
|
@ -49,4 +49,6 @@
|
||||||
<string name="uninstall">Uninstall</string>
|
<string name="uninstall">Uninstall</string>
|
||||||
<string name="version">Version</string>
|
<string name="version">Version</string>
|
||||||
<string name="dynamic_color">Dynamic color</string>
|
<string name="dynamic_color">Dynamic color</string>
|
||||||
|
<string name="appearance">Appearance</string>
|
||||||
|
<string name="advanced">Advanced</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue