fix: 调整设置项顺序
顺便为没有添加 Modifier 的 Composable 添加 Modifier;为横向滑动设置项添加更多选项
This commit is contained in:
parent
6f829d1825
commit
90f8ee6936
5 changed files with 50 additions and 44 deletions
|
|
@ -34,7 +34,7 @@ android {
|
||||||
applicationId = "cn.super12138.todo"
|
applicationId = "cn.super12138.todo"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 557
|
versionCode = 561
|
||||||
versionName = "2.0.2"
|
versionName = "2.0.2"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,15 @@ fun SettingsAppearance(
|
||||||
.padding(innerPadding)
|
.padding(innerPadding)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
|
SwitchSettingsItem(
|
||||||
|
key = Constants.PREF_DYNAMIC_COLOR,
|
||||||
|
default = Constants.PREF_DYNAMIC_COLOR_DEFAULT,
|
||||||
|
leadingIcon = Icons.Outlined.ColorLens,
|
||||||
|
title = stringResource(R.string.pref_appearance_dynamic_color),
|
||||||
|
description = stringResource(R.string.pref_appearance_dynamic_color_desc),
|
||||||
|
onCheckedChange = { viewModel.setDynamicColor(it) },
|
||||||
|
)
|
||||||
|
|
||||||
DarkModePicker(onDarkModeChange = { viewModel.setDarkMode(it) })
|
DarkModePicker(onDarkModeChange = { viewModel.setDarkMode(it) })
|
||||||
|
|
||||||
PalettePicker(
|
PalettePicker(
|
||||||
|
|
@ -51,15 +60,6 @@ fun SettingsAppearance(
|
||||||
)
|
)
|
||||||
|
|
||||||
ContrastPicker(onContrastChange = { viewModel.setContrastLevel(it) })
|
ContrastPicker(onContrastChange = { viewModel.setContrastLevel(it) })
|
||||||
|
|
||||||
SwitchSettingsItem(
|
|
||||||
key = Constants.PREF_DYNAMIC_COLOR,
|
|
||||||
default = Constants.PREF_DYNAMIC_COLOR_DEFAULT,
|
|
||||||
leadingIcon = Icons.Outlined.ColorLens,
|
|
||||||
title = stringResource(R.string.pref_appearance_dynamic_color),
|
|
||||||
description = stringResource(R.string.pref_appearance_dynamic_color_desc),
|
|
||||||
onCheckedChange = { viewModel.setDynamicColor(it) },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,10 +5,9 @@ import androidx.compose.foundation.gestures.ScrollableDefaults
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.wrapContentHeight
|
import androidx.compose.foundation.layout.wrapContentHeight
|
||||||
import androidx.compose.foundation.lazy.LazyListScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
|
|
@ -27,8 +26,10 @@ import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RowSettingsItem(
|
fun RowSettingsItem(
|
||||||
|
leadingIcon: (@Composable () -> Unit)? = null,
|
||||||
title: String,
|
title: String,
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
|
trailingContent: (@Composable () -> Unit)? = null,
|
||||||
shape: Shape = MaterialTheme.shapes.large,
|
shape: Shape = MaterialTheme.shapes.large,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
state: LazyListState = rememberLazyListState(),
|
state: LazyListState = rememberLazyListState(),
|
||||||
|
|
@ -42,8 +43,10 @@ fun RowSettingsItem(
|
||||||
content: LazyListScope.() -> Unit
|
content: LazyListScope.() -> Unit
|
||||||
) {
|
) {
|
||||||
MoreContentSettingsItem(
|
MoreContentSettingsItem(
|
||||||
|
leadingIcon = leadingIcon,
|
||||||
title = title,
|
title = title,
|
||||||
description = description,
|
description = description,
|
||||||
|
trailingContent = trailingContent,
|
||||||
shape = shape
|
shape = shape
|
||||||
) {
|
) {
|
||||||
LazyRow(
|
LazyRow(
|
||||||
|
|
@ -62,8 +65,10 @@ fun RowSettingsItem(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MoreContentSettingsItem(
|
fun MoreContentSettingsItem(
|
||||||
|
leadingIcon: (@Composable () -> Unit)? = null,
|
||||||
title: String,
|
title: String,
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
|
trailingContent: (@Composable () -> Unit)? = null,
|
||||||
shape: Shape = MaterialTheme.shapes.large,
|
shape: Shape = MaterialTheme.shapes.large,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
|
|
@ -73,36 +78,39 @@ fun MoreContentSettingsItem(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.wrapContentHeight()
|
.wrapContentHeight()
|
||||||
.clip(shape)
|
.clip(shape)
|
||||||
.padding(horizontal = 24.dp, vertical = 20.dp),
|
.padding(horizontal = 24.dp, vertical = 20.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Row {
|
||||||
text = title,
|
leadingIcon?.let {
|
||||||
maxLines = 1,
|
it()
|
||||||
overflow = TextOverflow.Ellipsis,
|
}
|
||||||
style = MaterialTheme.typography.titleLarge.copy(
|
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
fontSize = 20.sp
|
Text(
|
||||||
)
|
text = title,
|
||||||
)
|
maxLines = 1,
|
||||||
description?.let {
|
overflow = TextOverflow.Ellipsis,
|
||||||
Text(
|
style = MaterialTheme.typography.titleLarge.copy(
|
||||||
text = it,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
// maxLines = 2,
|
fontSize = 20.sp
|
||||||
overflow = TextOverflow.Ellipsis,
|
)
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
)
|
||||||
)
|
description?.let {
|
||||||
|
Text(
|
||||||
|
text = it,
|
||||||
|
// maxLines = 2,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trailingContent?.let {
|
||||||
|
it()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.size(8.dp))
|
|
||||||
|
|
||||||
/*Box(
|
|
||||||
Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.clip(MaterialTheme.shapes.large)
|
|
||||||
.background(MaterialTheme.colorScheme.surfaceContainer)
|
|
||||||
) {*/
|
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,10 +102,7 @@ fun SettingsItem(
|
||||||
it()
|
it()
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
) {
|
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ fun PalettePicker(
|
||||||
RowSettingsItem(
|
RowSettingsItem(
|
||||||
title = stringResource(R.string.pref_palette_style),
|
title = stringResource(R.string.pref_palette_style),
|
||||||
description = stringResource(R.string.pref_palette_style_desc),
|
description = stringResource(R.string.pref_palette_style_desc),
|
||||||
horizontalArrangement = Arrangement.spacedBy(5.dp)
|
horizontalArrangement = Arrangement.spacedBy(5.dp),
|
||||||
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
items(items = paletteOptions, key = { it.id }) { paletteStyle ->
|
items(items = paletteOptions, key = { it.id }) { paletteStyle ->
|
||||||
PaletteItem(
|
PaletteItem(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue