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"
|
||||
minSdk = 24
|
||||
targetSdk = 35
|
||||
versionCode = 557
|
||||
versionCode = 561
|
||||
versionName = "2.0.2"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,15 @@ fun SettingsAppearance(
|
|||
.padding(innerPadding)
|
||||
.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) })
|
||||
|
||||
PalettePicker(
|
||||
|
|
@ -51,15 +60,6 @@ fun SettingsAppearance(
|
|||
)
|
||||
|
||||
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.Column
|
||||
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.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
|
|
@ -27,8 +26,10 @@ import androidx.compose.ui.unit.sp
|
|||
|
||||
@Composable
|
||||
fun RowSettingsItem(
|
||||
leadingIcon: (@Composable () -> Unit)? = null,
|
||||
title: String,
|
||||
description: String? = null,
|
||||
trailingContent: (@Composable () -> Unit)? = null,
|
||||
shape: Shape = MaterialTheme.shapes.large,
|
||||
modifier: Modifier = Modifier,
|
||||
state: LazyListState = rememberLazyListState(),
|
||||
|
|
@ -42,8 +43,10 @@ fun RowSettingsItem(
|
|||
content: LazyListScope.() -> Unit
|
||||
) {
|
||||
MoreContentSettingsItem(
|
||||
leadingIcon = leadingIcon,
|
||||
title = title,
|
||||
description = description,
|
||||
trailingContent = trailingContent,
|
||||
shape = shape
|
||||
) {
|
||||
LazyRow(
|
||||
|
|
@ -62,8 +65,10 @@ fun RowSettingsItem(
|
|||
|
||||
@Composable
|
||||
fun MoreContentSettingsItem(
|
||||
leadingIcon: (@Composable () -> Unit)? = null,
|
||||
title: String,
|
||||
description: String? = null,
|
||||
trailingContent: (@Composable () -> Unit)? = null,
|
||||
shape: Shape = MaterialTheme.shapes.large,
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable () -> Unit
|
||||
|
|
@ -73,36 +78,39 @@ fun MoreContentSettingsItem(
|
|||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
.clip(shape)
|
||||
.padding(horizontal = 24.dp, vertical = 20.dp),
|
||||
.padding(horizontal = 24.dp, vertical = 20.dp)
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
)
|
||||
description?.let {
|
||||
Text(
|
||||
text = it,
|
||||
// maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
Row {
|
||||
leadingIcon?.let {
|
||||
it()
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = title,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
)
|
||||
)
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
@ -102,10 +102,7 @@ fun SettingsItem(
|
|||
it()
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = title,
|
||||
maxLines = 1,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ fun PalettePicker(
|
|||
RowSettingsItem(
|
||||
title = stringResource(R.string.pref_palette_style),
|
||||
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 ->
|
||||
PaletteItem(
|
||||
|
|
|
|||
Loading…
Reference in a new issue