Appearance settings: density, buttons and reduce motion (#118, #157)

This commit is contained in:
makiolaj committed 2026-11-27 12:16:34 +01:00
1 parent c4a313fe69
commit c103ea0548
2 files changed
+111 -3

No files matched your search

@@ -2,8 +2,25 @@ package de.jeanlucmakiola.agendula.ui.settings
import android.os.Build
import android.text.format.DateFormat
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.Badge
import androidx.compose.material.icons.rounded.Bolt
import androidx.compose.material.icons.rounded.CalendarViewWeek
import androidx.compose.material.icons.rounded.DarkMode
import androidx.compose.material.icons.rounded.Palette
import androidx.compose.material.icons.rounded.Schedule
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -14,28 +31,40 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.graphics.shapes.RoundedPolygon
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import de.jeanlucmakiola.agendula.R
import de.jeanlucmakiola.agendula.data.appname.LauncherName
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
import de.jeanlucmakiola.agendula.data.prefs.TimeFormatPref
import de.jeanlucmakiola.agendula.data.prefs.is24Hour
import de.jeanlucmakiola.agendula.ui.common.ActionShapes
import de.jeanlucmakiola.agendula.ui.common.formatMinuteOfDay
import de.jeanlucmakiola.agendula.ui.common.localeFirstDayOfWeek
import de.jeanlucmakiola.floret.components.ActionStylePreview
import de.jeanlucmakiola.floret.components.CollapsingScaffold
import de.jeanlucmakiola.floret.components.ConnectedChoiceRow
import de.jeanlucmakiola.floret.components.FullScreenPicker
import de.jeanlucmakiola.floret.components.GroupedHint
import de.jeanlucmakiola.floret.components.GroupedListInset
import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSectionHeader
import de.jeanlucmakiola.floret.components.GroupedSwitchRow
import de.jeanlucmakiola.floret.components.LauncherMark
import de.jeanlucmakiola.floret.components.LauncherNameChooser
import de.jeanlucmakiola.floret.components.OptionPicker
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.PreviewOptionCard
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.prefs.ActionStyle
import de.jeanlucmakiola.floret.prefs.LayoutDensity
import java.time.DayOfWeek
import java.time.format.TextStyle
/** How the app looks: the theme, wallpaper colours, and how times and weeks are written. */
/** How the app looks: the theme, wallpaper colours, density, buttons, motion, and how times and weeks are written. */
@Composable
internal fun AppearanceScreen(
state: SettingsUiState,
@@ -58,10 +87,12 @@ internal fun AppearanceScreen(
predictiveBack = true,
visible = visible,
) {
GroupedSectionHeader(stringResource(R.string.settings_theme))
GroupedRow(
title = stringResource(R.string.settings_theme),
summary = stringResource(themeLabel(state.settings.themeMode)),
position = Position.Top,
leading = { Icon(Icons.Rounded.DarkMode, contentDescription = null) },
onClick = { showTheme = true },
)
GroupedRow(
@@ -72,6 +103,7 @@ internal fun AppearanceScreen(
stringResource(R.string.settings_dynamic_color_unavailable)
},
position = Position.Bottom,
leading = { Icon(Icons.Rounded.Palette, contentDescription = null) },
trailing = {
Switch(
checked = state.settings.dynamicColor && dynamicColorAvailable,
@@ -86,25 +118,71 @@ internal fun AppearanceScreen(
},
)
Spacer(Modifier.height(24.dp))
Spacer(Modifier.height(8.dp))
GroupedSectionHeader(stringResource(R.string.settings_density))
ConnectedChoiceRow(
options = LayoutDensity.entries,
selected = state.settings.density,
label = { stringResource(densityLabel(it)) },
onSelect = viewModel::setDensity,
)
GroupedHint(
text = stringResource(R.string.settings_density_hint),
style = MaterialTheme.typography.bodySmall,
)
Spacer(Modifier.height(8.dp))
GroupedSectionHeader(stringResource(R.string.settings_buttons))
Row(
modifier = Modifier.fillMaxWidth().padding(horizontal = GroupedListInset).selectableGroup(),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
ActionStyle.entries.forEach { style ->
PreviewOptionCard(
label = stringResource(actionStyleLabel(style)),
selected = state.settings.actionStyle == style,
onClick = { viewModel.setActionStyle(style) },
preview = { ActionStylePreview(PreviewActions, shaped = style == ActionStyle.SHAPES) },
modifier = Modifier.weight(1f),
)
}
}
Spacer(Modifier.height(8.dp))
GroupedSectionHeader(stringResource(R.string.settings_motion))
GroupedSwitchRow(
title = stringResource(R.string.settings_reduce_motion),
summary = stringResource(R.string.settings_reduce_motion_hint),
checked = state.settings.reduceMotion,
onCheckedChange = viewModel::setReduceMotion,
position = Position.Alone,
leading = { Icon(Icons.Rounded.Bolt, contentDescription = null) },
)
Spacer(Modifier.height(8.dp))
GroupedSectionHeader(stringResource(R.string.settings_group_date_time))
GroupedRow(
title = stringResource(R.string.settings_time_format),
summary = timeFormatLabel(state.settings.timeFormat),
position = Position.Top,
leading = { Icon(Icons.Rounded.Schedule, contentDescription = null) },
onClick = { showTimeFormat = true },
)
GroupedRow(
title = stringResource(R.string.settings_week_start),
summary = weekStartLabel(state.settings.weekStart),
position = Position.Bottom,
leading = { Icon(Icons.Rounded.CalendarViewWeek, contentDescription = null) },
onClick = { showWeekStart = true },
)
Spacer(Modifier.height(24.dp))
Spacer(Modifier.height(8.dp))
GroupedSectionHeader(stringResource(R.string.settings_group_launcher))
GroupedRow(
title = stringResource(R.string.settings_app_name),
summary = launcherNameLabel(launcherName),
position = Position.Alone,
leading = { Icon(Icons.Rounded.Badge, contentDescription = null) },
onClick = { showAppName = true },
)
}
@@ -211,6 +289,24 @@ private fun launcherNameLabel(name: LauncherName): String = stringResource(
},
)
private fun densityLabel(density: LayoutDensity): Int = when (density) {
LayoutDensity.COMFORTABLE -> R.string.settings_density_comfortable
LayoutDensity.COMPACT -> R.string.settings_density_compact
}
private fun actionStyleLabel(style: ActionStyle): Int = when (style) {
ActionStyle.ICONS -> R.string.settings_buttons_icons
ActionStyle.SHAPES -> R.string.settings_buttons_shapes
}
/** The home top bar's own actions, as the Buttons choice previews them. */
private val PreviewActions: List<Pair<ImageVector, RoundedPolygon>>
get() = listOf(
Icons.Rounded.Search to ActionShapes.Search,
Icons.Rounded.Settings to ActionShapes.Settings,
Icons.Rounded.Add to ActionShapes.AddList,
)
private fun themeLabel(mode: ThemeMode): Int = when (mode) {
ThemeMode.SYSTEM -> R.string.settings_theme_system
ThemeMode.LIGHT -> R.string.settings_theme_light
+12
View File
@@ -525,6 +525,18 @@
<string name="settings_app_name_hint">Show Agendula as “Tasks” in your launcher. Only the launcher name changes; the icon may move to a new spot. Agendula closes when you switch, so reopen it from the launcher.</string>
<string name="settings_dynamic_color">Dynamic colour</string>
<string name="settings_dynamic_color_hint">Use colours from your wallpaper</string>
<string name="settings_density">Density</string>
<string name="settings_density_comfortable">Comfortable</string>
<string name="settings_density_compact">Compact</string>
<string name="settings_density_hint">Compact uses shorter rows, so more fits on the screen.</string>
<string name="settings_buttons">Buttons</string>
<string name="settings_buttons_icons">Icons only</string>
<string name="settings_buttons_shapes">Expressive shapes</string>
<string name="settings_motion">Motion</string>
<string name="settings_reduce_motion">Reduce motion</string>
<string name="settings_reduce_motion_hint">Stops looping animations like the progress wave. The system “Remove animations” setting always wins.</string>
<string name="settings_group_date_time">Date &amp; time</string>
<string name="settings_group_launcher">Launcher</string>
<string name="settings_section_reminders">Notifications</string>
<string name="settings_reminders">Task reminders</string>
<string name="settings_reminders_hint">Notify me when a task is due</string>