Merge feat/118-appearance into the views branch
This commit is contained in:
commit
c96a7783dd
28 files changed
+521
-357
No files matched your search
@@ -24,6 +24,20 @@ All notable changes to this project are documented here. The format follows
|
||||
last used view, another view, a list or a saved filter. A list or filter
|
||||
opens over Home, so back leads there (#141).
|
||||
- Every view is also a launcher shortcut (#59).
|
||||
- A compact density under Settings → Appearance: shorter rows in the lists,
|
||||
the task lists and settings, so more fits on the screen.
|
||||
- A "Reduce motion" switch under Settings → Appearance takes the movement out
|
||||
of the app, as the system's "Remove animations" does: screens and sections
|
||||
fade instead of sliding, buttons don't spin or bounce, and looping animations
|
||||
such as the wave on the Today progress ring and the pull-to-sync indicator
|
||||
stay still. The system setting does the same whatever the switch says (#157).
|
||||
|
||||
### Changed
|
||||
- The home screen's search, settings and new-list buttons are plain icons now,
|
||||
for everyone. The expressive shapes they sat on are still there, and now
|
||||
reach every top-bar and header button (lists, filters, a list's search and
|
||||
view options, a task's edit, delete and menu): pick "Expressive shapes" under
|
||||
Settings → Appearance → Buttons (#118).
|
||||
|
||||
## [1.4.0] - 2026-11-25
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ dependencies {
|
||||
implementation(libs.floret.core.reminders)
|
||||
implementation(libs.floret.core.locale)
|
||||
implementation(libs.floret.core.crash)
|
||||
implementation(libs.floret.core.prefs)
|
||||
implementation(libs.floret.identity)
|
||||
implementation(libs.floret.components)
|
||||
implementation(libs.floret.glance)
|
||||
|
||||
@@ -3,24 +3,28 @@ package de.jeanlucmakiola.agendula
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.text.format.DateFormat
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.core.net.toUri
|
||||
import de.jeanlucmakiola.agendula.data.prefs.Settings
|
||||
import de.jeanlucmakiola.agendula.data.prefs.SettingsPrefs
|
||||
import de.jeanlucmakiola.agendula.data.prefs.is24Hour
|
||||
import de.jeanlucmakiola.agendula.ui.common.LocalFirstDayOfWeek
|
||||
import de.jeanlucmakiola.agendula.ui.common.LocalUse24HourFormat
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -33,7 +37,6 @@ import de.jeanlucmakiola.agendula.ui.navigation.AppShortcuts
|
||||
import de.jeanlucmakiola.agendula.ui.RootScreen
|
||||
import de.jeanlucmakiola.agendula.ui.crash.CrashReportActivity
|
||||
import de.jeanlucmakiola.agendula.ui.navigation.NavRequest
|
||||
import de.jeanlucmakiola.agendula.ui.settings.SettingsViewModel
|
||||
import de.jeanlucmakiola.agendula.ui.theme.AgendulaTheme
|
||||
import de.jeanlucmakiola.agendula.ui.theme.SystemTheme
|
||||
import de.jeanlucmakiola.agendula.ui.views.ViewSession
|
||||
@@ -49,7 +52,7 @@ import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Single activity. The theme follows [SettingsViewModel]; [RootScreen] is the
|
||||
* Single activity. The theme follows the stored [Settings]; [RootScreen] is the
|
||||
* (replaceable) functional scaffold over the real data layer. Notification taps
|
||||
* arrive as a [NavRequest] (see [navRequestOf]).
|
||||
*/
|
||||
@@ -73,6 +76,9 @@ class MainActivity : ComponentActivity() {
|
||||
// A request arrived after launch, so the start destination mustn't land on top of it.
|
||||
private var navigatedSinceLaunch = false
|
||||
|
||||
// Set once the stored settings reach the composition; see [holdFirstFrameForAppearance].
|
||||
private var appearanceReady = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -135,18 +141,17 @@ class MainActivity : ComponentActivity() {
|
||||
if (savedInstanceState == null) {
|
||||
launchHooks.forEach { hook -> lifecycleScope.launch { runCatching { hook.onLaunch(intent) } } }
|
||||
}
|
||||
holdFirstFrameForAppearance()
|
||||
setContent {
|
||||
val settingsViewModel: SettingsViewModel = hiltViewModel()
|
||||
val ui by settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val darkTheme = ui.settings.themeMode.isDark(isSystemInDarkTheme())
|
||||
// The stored settings, not a placeholder: until they're read the first
|
||||
// frame is held, so a compact or shaped layout never opens on the defaults.
|
||||
val stored by remember { settingsPrefs.settings }.collectAsStateWithLifecycle(initialValue = null)
|
||||
if (stored != null) SideEffect { appearanceReady = true }
|
||||
val settings = stored ?: Settings()
|
||||
val context = LocalContext.current
|
||||
val use24Hour = ui.settings.timeFormat.is24Hour(DateFormat.is24HourFormat(context))
|
||||
val firstDayOfWeek = ui.settings.effectiveWeekStart
|
||||
AgendulaTheme(
|
||||
darkTheme = darkTheme,
|
||||
dynamicColor = ui.settings.dynamicColor,
|
||||
pureBlack = ui.settings.themeMode.isPureBlack,
|
||||
) {
|
||||
val use24Hour = settings.timeFormat.is24Hour(DateFormat.is24HourFormat(context))
|
||||
val firstDayOfWeek = settings.effectiveWeekStart
|
||||
AgendulaTheme(settings) {
|
||||
CompositionLocalProvider(
|
||||
LocalUse24HourFormat provides use24Hour,
|
||||
LocalFirstDayOfWeek provides firstDayOfWeek,
|
||||
@@ -176,6 +181,24 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps the launch window up until the stored appearance is in the first
|
||||
* composition, at most [APPEARANCE_WAIT_MS], so a slow read can't hold the launch.
|
||||
*/
|
||||
private fun holdFirstFrameForAppearance() {
|
||||
val content = findViewById<View>(android.R.id.content)
|
||||
val since = SystemClock.uptimeMillis()
|
||||
content.viewTreeObserver.addOnPreDrawListener(
|
||||
object : ViewTreeObserver.OnPreDrawListener {
|
||||
override fun onPreDraw(): Boolean {
|
||||
val draw = appearanceReady || SystemClock.uptimeMillis() - since > APPEARANCE_WAIT_MS
|
||||
if (draw) content.viewTreeObserver.removeOnPreDrawListener(this)
|
||||
return draw
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent)
|
||||
@@ -344,3 +367,6 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The longest the first frame waits for the stored appearance. */
|
||||
private const val APPEARANCE_WAIT_MS = 600L
|
||||
@@ -37,6 +37,12 @@ import de.jeanlucmakiola.agendula.domain.StartDestination
|
||||
import de.jeanlucmakiola.agendula.domain.View
|
||||
import de.jeanlucmakiola.agendula.domain.withHomeFirst
|
||||
import de.jeanlucmakiola.agendula.domain.withinUpcoming
|
||||
import de.jeanlucmakiola.floret.prefs.ActionStyle
|
||||
import de.jeanlucmakiola.floret.prefs.AppearancePrefs
|
||||
import de.jeanlucmakiola.floret.prefs.LayoutDensity
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.get
|
||||
import de.jeanlucmakiola.floret.prefs.set
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderLead
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderOverride
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderOverrideCodec
|
||||
@@ -60,19 +66,6 @@ import javax.inject.Singleton
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
|
||||
/** [BLACK] is dark with pure-black surfaces, for AMOLED screens. */
|
||||
enum class ThemeMode {
|
||||
SYSTEM, LIGHT, DARK, BLACK;
|
||||
|
||||
fun isDark(systemDark: Boolean): Boolean = when (this) {
|
||||
SYSTEM -> systemDark
|
||||
LIGHT -> false
|
||||
DARK, BLACK -> true
|
||||
}
|
||||
|
||||
val isPureBlack: Boolean get() = this == BLACK
|
||||
}
|
||||
|
||||
/** Clock convention: AUTO follows the device's 24-hour switch. */
|
||||
enum class TimeFormatPref { AUTO, TWELVE_HOUR, TWENTY_FOUR_HOUR }
|
||||
|
||||
@@ -110,6 +103,12 @@ const val DEFAULT_ALL_DAY_REMINDER_MINUTE = 9 * 60
|
||||
data class Settings(
|
||||
val themeMode: ThemeMode = ThemeMode.SYSTEM,
|
||||
val dynamicColor: Boolean = true,
|
||||
/** How tightly rows and tiles pack. */
|
||||
val density: LayoutDensity = LayoutDensity.COMFORTABLE,
|
||||
/** Plain icons or expressive shapes for header and top-bar actions (#118). */
|
||||
val actionStyle: ActionStyle = ActionStyle.ICONS,
|
||||
/** Stops looping animations; the system "Remove animations" does so regardless (#157). */
|
||||
val reduceMotion: Boolean = false,
|
||||
/** The list a new task defaults to; `null` = first available. */
|
||||
val defaultListId: Long? = null,
|
||||
/** Default reminders (0 before due = at due time); empty = none. */
|
||||
@@ -290,9 +289,11 @@ class SettingsPrefs @Inject constructor(
|
||||
val settings: Flow<Settings> = dataStore.data.map { p ->
|
||||
val scope = scopeOf(p)
|
||||
Settings(
|
||||
themeMode = p[THEME_MODE]?.let { runCatching { ThemeMode.valueOf(it) }.getOrNull() }
|
||||
?: ThemeMode.SYSTEM,
|
||||
dynamicColor = p[DYNAMIC_COLOR] ?: true,
|
||||
themeMode = p[AppearancePrefs.themeMode],
|
||||
dynamicColor = p[AppearancePrefs.dynamicColor],
|
||||
density = p[AppearancePrefs.density],
|
||||
actionStyle = p[AppearancePrefs.actionStyle],
|
||||
reduceMotion = p[AppearancePrefs.reduceMotion],
|
||||
defaultListId = p[DEFAULT_LIST_ID]?.takeIf { it > 0 },
|
||||
// The single lead of earlier versions carries over until a list is saved.
|
||||
defaultReminders = p[DEFAULT_REMINDERS]?.let(::parseLeads)
|
||||
@@ -467,8 +468,11 @@ class SettingsPrefs @Inject constructor(
|
||||
if (day == null) it.remove(WEEK_START) else it[WEEK_START] = day.name
|
||||
}
|
||||
|
||||
suspend fun setThemeMode(mode: ThemeMode) = dataStore.edit { it[THEME_MODE] = mode.name }
|
||||
suspend fun setDynamicColor(enabled: Boolean) = dataStore.edit { it[DYNAMIC_COLOR] = enabled }
|
||||
suspend fun setThemeMode(mode: ThemeMode) = dataStore.edit { it[AppearancePrefs.themeMode] = mode }
|
||||
suspend fun setDynamicColor(enabled: Boolean) = dataStore.edit { it[AppearancePrefs.dynamicColor] = enabled }
|
||||
suspend fun setDensity(density: LayoutDensity) = dataStore.edit { it[AppearancePrefs.density] = density }
|
||||
suspend fun setActionStyle(style: ActionStyle) = dataStore.edit { it[AppearancePrefs.actionStyle] = style }
|
||||
suspend fun setReduceMotion(enabled: Boolean) = dataStore.edit { it[AppearancePrefs.reduceMotion] = enabled }
|
||||
suspend fun setDefaultListId(id: Long?) = dataStore.edit {
|
||||
if (id == null) it.remove(DEFAULT_LIST_ID) else it[DEFAULT_LIST_ID] = id
|
||||
}
|
||||
@@ -731,8 +735,6 @@ class SettingsPrefs @Inject constructor(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val THEME_MODE = stringPreferencesKey("theme_mode")
|
||||
val DYNAMIC_COLOR = booleanPreferencesKey("dynamic_color")
|
||||
val DEFAULT_LIST_ID = longPreferencesKey("default_list_id")
|
||||
val REMINDER_LEAD = intPreferencesKey("reminder_lead_minutes")
|
||||
val DEFAULT_REMINDERS = stringPreferencesKey("default_reminder_minutes")
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.jeanlucmakiola.agendula.ui.common
|
||||
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.MaterialShapes
|
||||
import androidx.graphics.shapes.RoundedPolygon
|
||||
|
||||
/**
|
||||
* Named shapes for the app's top-bar actions, so each action is recognisably
|
||||
* "its own" when the expressive button style is on, and new actions just pick
|
||||
* the next unused shape. Expose the expressive [MaterialShapes] through a
|
||||
* single opt-in site.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
object ActionShapes {
|
||||
/** Settings — a 4-sided cookie (rounded, scalloped square). */
|
||||
val Settings: RoundedPolygon get() = MaterialShapes.Cookie4Sided
|
||||
|
||||
/** Search — a 6-sided cookie, the same family as [Settings] but distinct. */
|
||||
val Search: RoundedPolygon get() = MaterialShapes.Cookie6Sided
|
||||
|
||||
/** New list — a sunny burst beside the Lists header. */
|
||||
val AddList: RoundedPolygon get() = MaterialShapes.Sunny
|
||||
|
||||
/** What [AddList] and [AddFilter] morph into on press. */
|
||||
val AddListPressed: RoundedPolygon get() = MaterialShapes.Circle
|
||||
|
||||
/** New filter — the same burst as [AddList], so both "add" actions read alike. */
|
||||
val AddFilter: RoundedPolygon get() = MaterialShapes.Sunny
|
||||
|
||||
/** Reorder the lists — a four-leaf clover. */
|
||||
val Reorder: RoundedPolygon get() = MaterialShapes.Clover4Leaf
|
||||
|
||||
/** A list's view options (sort, group, filter) — a 9-sided cookie. */
|
||||
val ViewOptions: RoundedPolygon get() = MaterialShapes.Cookie9Sided
|
||||
|
||||
/** Edit a task, list or filter — a flower. */
|
||||
val Edit: RoundedPolygon get() = MaterialShapes.Flower
|
||||
|
||||
/** Delete — a pentagon, set apart from the softer shapes. */
|
||||
val Delete: RoundedPolygon get() = MaterialShapes.Pentagon
|
||||
|
||||
/** The overflow menu — a puffy cloud. */
|
||||
val More: RoundedPolygon get() = MaterialShapes.Puffy
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
package de.jeanlucmakiola.agendula.ui.common
|
||||
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialShapes
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.toPath
|
||||
import androidx.compose.material3.toShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Matrix
|
||||
import androidx.compose.ui.graphics.Outline
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.graphics.shapes.Morph
|
||||
import androidx.graphics.shapes.RoundedPolygon
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* A top-bar action whose icon sits in a tonal container clipped to one of the
|
||||
* M3 Expressive [MaterialShapes] (cookie, clover, sunny, …) — Agendula's playful
|
||||
* take on a plain [androidx.compose.material3.IconButton]. Each action passes
|
||||
* its own [shape] and [containerColor], so a row of them reads as a set of
|
||||
* distinct little tokens rather than identical grey glyphs.
|
||||
*
|
||||
* Pressing springs the whole shape down and gives it a turn — the scalloped
|
||||
* container is what dips and spins, while the glyph inside stays upright (a
|
||||
* spinning magnifier or list icon would just read as wrong). [spinIcon] opts a
|
||||
* glyph into turning too, for icons that read well mid-spin like the gear.
|
||||
*
|
||||
* With [morphTo] set the press is a different gesture altogether: no turn and no
|
||||
* dip — the container morphs into [morphTo] and pops slightly larger on a bouncy
|
||||
* spring, for an action that should not feel like its neighbours. A tap holds
|
||||
* the popped state for a beat before [onClick] fires, so the gesture is seen.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
fun ShapedActionButton(
|
||||
shape: RoundedPolygon,
|
||||
icon: ImageVector,
|
||||
contentDescription: String?,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
containerColor: Color = MaterialTheme.colorScheme.tertiaryContainer,
|
||||
contentColor: Color = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||
size: Dp = 40.dp,
|
||||
iconSize: Dp = 22.dp,
|
||||
spinIcon: Boolean = false,
|
||||
morphTo: RoundedPolygon? = null,
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val pressed by interaction.collectIsPressedAsState()
|
||||
if (morphTo != null) {
|
||||
MorphPopButton(shape, morphTo, icon, contentDescription, onClick, modifier, containerColor, contentColor, size, iconSize, interaction, pressed)
|
||||
return
|
||||
}
|
||||
// The shape (the scalloped cookie) turns and dips on press.
|
||||
val shapeRotation by animateFloatAsState(if (pressed) 40f else 0f, label = "shapeRotation")
|
||||
val scale by animateFloatAsState(if (pressed) 0.82f else 1f, label = "shapeScale")
|
||||
// The glyph's *net* turn: 0 keeps it upright, spinIcon gives it a quarter turn.
|
||||
val iconRotation by animateFloatAsState(
|
||||
if (pressed && spinIcon) 90f else 0f,
|
||||
label = "iconRotation",
|
||||
)
|
||||
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.size(size)
|
||||
.scale(scale)
|
||||
.rotate(shapeRotation),
|
||||
shape = shape.toShape(),
|
||||
color = containerColor,
|
||||
contentColor = contentColor,
|
||||
interactionSource = interaction,
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = contentDescription,
|
||||
// Counter the container's turn so the glyph's net rotation is just
|
||||
// [iconRotation] — upright by default, a quarter turn for the gear.
|
||||
modifier = Modifier
|
||||
.size(iconSize)
|
||||
.rotate(iconRotation - shapeRotation),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MorphPopButton(
|
||||
shape: RoundedPolygon,
|
||||
morphTo: RoundedPolygon,
|
||||
icon: ImageVector,
|
||||
contentDescription: String?,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier,
|
||||
containerColor: Color,
|
||||
contentColor: Color,
|
||||
size: Dp,
|
||||
iconSize: Dp,
|
||||
interaction: MutableInteractionSource,
|
||||
pressed: Boolean,
|
||||
) {
|
||||
val morph = remember(shape, morphTo) { Morph(shape, morphTo) }
|
||||
val scope = rememberCoroutineScope()
|
||||
var firing by remember { mutableStateOf(false) }
|
||||
val popped = pressed || firing
|
||||
val bouncy = spring<Float>(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessMedium)
|
||||
val progress by animateFloatAsState(if (popped) 1f else 0f, bouncy, label = "morphProgress")
|
||||
val scale by animateFloatAsState(if (popped) 1.12f else 1f, bouncy, label = "popScale")
|
||||
val iconScale by animateFloatAsState(if (popped) 1.2f else 1f, bouncy, label = "iconScale")
|
||||
|
||||
Surface(
|
||||
onClick = {
|
||||
if (!firing) {
|
||||
firing = true
|
||||
scope.launch {
|
||||
delay(MorphClickDelayMs)
|
||||
onClick()
|
||||
firing = false
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = modifier.size(size).scale(scale),
|
||||
shape = remember(morph, progress) { MorphShape(morph, progress) },
|
||||
color = containerColor,
|
||||
contentColor = contentColor,
|
||||
interactionSource = interaction,
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = contentDescription,
|
||||
modifier = Modifier.size(iconSize).scale(iconScale),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val MorphClickDelayMs = 160L
|
||||
|
||||
/** [morph] at [progress], scaled from the shapes' unit square to the component. */
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
private class MorphShape(private val morph: Morph, private val progress: Float) : Shape {
|
||||
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
||||
val path = morph.toPath(progress.coerceIn(0f, 1f), Path())
|
||||
path.transform(Matrix().apply { scale(size.width, size.height) })
|
||||
return Outline.Generic(path)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Named shapes for the app's top-bar actions, so each action is recognisably
|
||||
* "its own" and new actions just pick the next unused shape. Expose the
|
||||
* expressive [MaterialShapes] through a single opt-in site.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
object ActionShapes {
|
||||
/** Settings — a 4-sided cookie (rounded, scalloped square). */
|
||||
val Settings: RoundedPolygon get() = MaterialShapes.Cookie4Sided
|
||||
|
||||
/** Search — a 6-sided cookie, the same family as [Settings] but distinct. */
|
||||
val Search: RoundedPolygon get() = MaterialShapes.Cookie6Sided
|
||||
|
||||
/** New list — a sunny burst beside the Lists header. */
|
||||
val AddList: RoundedPolygon get() = MaterialShapes.Sunny
|
||||
|
||||
/** What [AddList] morphs into on press. */
|
||||
val AddListPressed: RoundedPolygon get() = MaterialShapes.Circle
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package de.jeanlucmakiola.agendula.ui.common
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
||||
@@ -13,11 +15,16 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import de.jeanlucmakiola.floret.identity.rememberLoopingMotion
|
||||
import androidx.compose.ui.semantics.ProgressBarRangeInfo
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.progressBarRangeInfo
|
||||
|
||||
/**
|
||||
* Pull down to sync every account (#73). Without an account there is nothing
|
||||
* to sync, so the gesture is off. [topPadding] keeps the indicator below a top
|
||||
* bar the content scrolls under.
|
||||
* bar the content scrolls under. Under reduced motion the indicator is a still
|
||||
* ring rather than the morphing loading shape (#157).
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
@@ -34,17 +41,33 @@ fun SyncPullBox(
|
||||
return
|
||||
}
|
||||
val state = rememberPullToRefreshState()
|
||||
val looping = rememberLoopingMotion()
|
||||
PullToRefreshBox(
|
||||
isRefreshing = syncing,
|
||||
onRefresh = onSync,
|
||||
modifier = modifier,
|
||||
state = state,
|
||||
indicator = {
|
||||
PullToRefreshDefaults.LoadingIndicator(
|
||||
state = state,
|
||||
isRefreshing = syncing,
|
||||
modifier = Modifier.align(Alignment.TopCenter).padding(top = topPadding),
|
||||
)
|
||||
val placement = Modifier.align(Alignment.TopCenter).padding(top = topPadding)
|
||||
if (looping) {
|
||||
PullToRefreshDefaults.LoadingIndicator(state = state, isRefreshing = syncing, modifier = placement)
|
||||
} else {
|
||||
// Reduced motion: a still ring that fills with the pull and stays full while syncing.
|
||||
PullToRefreshDefaults.IndicatorBox(
|
||||
state = state,
|
||||
isRefreshing = syncing,
|
||||
modifier = placement,
|
||||
containerColor = PullToRefreshDefaults.loadingIndicatorContainerColor,
|
||||
) {
|
||||
CircularProgressIndicator(
|
||||
progress = { if (syncing) 1f else state.distanceFraction.coerceIn(0f, 1f) },
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clearAndSetSemantics { progressBarRangeInfo = ProgressBarRangeInfo.Indeterminate },
|
||||
strokeWidth = 2.5.dp,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
content = content,
|
||||
)
|
||||
|
||||
@@ -111,6 +111,10 @@ import de.jeanlucmakiola.floret.time.formatTime
|
||||
import de.jeanlucmakiola.floret.components.pastelize
|
||||
import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.agendula.ui.tasklist.priorityLabel
|
||||
import androidx.compose.animation.core.spring
|
||||
import de.jeanlucmakiola.agendula.ui.common.ActionShapes
|
||||
import de.jeanlucmakiola.floret.components.ActionButton
|
||||
import de.jeanlucmakiola.floret.identity.reducibleSpec
|
||||
|
||||
/**
|
||||
* One task's detail. Each fact is its own tonal card with a leading icon (the
|
||||
@@ -148,23 +152,31 @@ fun TaskDetailScreen(
|
||||
val content = state as? TaskDetailUiState.Content
|
||||
// A read-only share: an edit would never reach the server.
|
||||
val writable = content != null && !content.detail.task.isReadOnly
|
||||
IconButton(onClick = { content?.let { onEdit(it.detail.task) } }, enabled = writable) {
|
||||
Icon(Icons.Rounded.Edit, contentDescription = stringResource(R.string.edit))
|
||||
}
|
||||
IconButton(
|
||||
ActionButton(
|
||||
shape = ActionShapes.Edit,
|
||||
icon = Icons.Rounded.Edit,
|
||||
contentDescription = stringResource(R.string.edit),
|
||||
onClick = { content?.let { onEdit(it.detail.task) } },
|
||||
enabled = writable,
|
||||
)
|
||||
ActionButton(
|
||||
shape = ActionShapes.Delete,
|
||||
icon = Icons.Rounded.Delete,
|
||||
contentDescription = stringResource(R.string.delete),
|
||||
onClick = { confirmDelete = true },
|
||||
enabled = writable,
|
||||
) {
|
||||
Icon(Icons.Rounded.Delete, contentDescription = stringResource(R.string.delete))
|
||||
}
|
||||
)
|
||||
// On an occurrence of a series, cancelling reaches only that occurrence.
|
||||
val task = content?.detail?.task
|
||||
if (task != null) {
|
||||
var menuOpen by remember { mutableStateOf(false) }
|
||||
Box {
|
||||
IconButton(onClick = { menuOpen = true }) {
|
||||
Icon(Icons.Rounded.MoreVert, contentDescription = stringResource(R.string.more_options))
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.More,
|
||||
icon = Icons.Rounded.MoreVert,
|
||||
contentDescription = stringResource(R.string.more_options),
|
||||
onClick = { menuOpen = true },
|
||||
)
|
||||
DropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {
|
||||
val cancelled = task.status == TaskStatus.CANCELLED
|
||||
DropdownMenuItem(
|
||||
@@ -546,7 +558,7 @@ private fun SubtasksGroup(
|
||||
val done = subtasks.count { it.isCompleted }
|
||||
// Completed subtasks sink to the bottom; stable, so order is otherwise kept.
|
||||
val ordered = remember(subtasks) { subtasks.sortedBy { it.isCompleted } }
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, label = "subtasksChevron")
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, reducibleSpec(spring()), label = "subtasksChevron")
|
||||
// Segments when expanded: header + the always-present add row + each subtask.
|
||||
val addRow = if (readOnly) 0 else 1
|
||||
val count = if (expanded) subtasks.size + 1 + addRow else 1
|
||||
|
||||
@@ -141,6 +141,7 @@ import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
import de.jeanlucmakiola.floret.identity.rememberReduceMotion
|
||||
|
||||
/**
|
||||
* Create / edit form, in the family's tonal-card language (mirrors Calendula's
|
||||
@@ -173,6 +174,7 @@ fun TaskEditScreen(
|
||||
val scroll = rememberScrollState()
|
||||
var titleBottom by remember { mutableIntStateOf(Int.MAX_VALUE) }
|
||||
val titleInBar by remember { derivedStateOf { scroll.value > titleBottom } }
|
||||
val reduceMotion = rememberReduceMotion()
|
||||
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
@@ -181,8 +183,8 @@ fun TaskEditScreen(
|
||||
title = {
|
||||
AnimatedVisibility(
|
||||
visible = titleInBar && state.title.isNotBlank(),
|
||||
enter = fadeIn() + slideInVertically { it / 2 },
|
||||
exit = fadeOut() + slideOutVertically { it / 2 },
|
||||
enter = if (reduceMotion) fadeIn() else fadeIn() + slideInVertically { it / 2 },
|
||||
exit = if (reduceMotion) fadeOut() else fadeOut() + slideOutVertically { it / 2 },
|
||||
) {
|
||||
Text(state.title, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ButtonGroup
|
||||
import androidx.compose.material3.ButtonGroupScope
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -57,6 +56,7 @@ import de.jeanlucmakiola.floret.components.SelectedCheck
|
||||
import de.jeanlucmakiola.floret.components.Position
|
||||
import de.jeanlucmakiola.floret.components.pastelize
|
||||
import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.floret.components.BusyIndicator
|
||||
|
||||
private const val ZIP_MIME = "application/zip"
|
||||
private const val ZIP_NAME = "agendula-tasks.zip"
|
||||
@@ -238,7 +238,7 @@ private fun ExportStatus(state: ExportUiState) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
CircularProgressIndicator(Modifier.size(18.dp))
|
||||
BusyIndicator(Modifier.size(18.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.export_running),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
|
||||
@@ -28,7 +28,6 @@ import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ButtonGroup
|
||||
import androidx.compose.material3.ButtonGroupScope
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -60,6 +59,7 @@ import de.jeanlucmakiola.floret.components.GroupedRow
|
||||
import de.jeanlucmakiola.floret.components.OptionPicker
|
||||
import de.jeanlucmakiola.floret.components.Position
|
||||
import de.jeanlucmakiola.floret.components.pastelize
|
||||
import de.jeanlucmakiola.floret.components.BusyIndicator
|
||||
|
||||
private val PICK_TYPES = arrayOf("text/calendar", "text/x-vcalendar", "application/zip", "*/*")
|
||||
|
||||
@@ -312,7 +312,7 @@ private fun Progress(label: String) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
CircularProgressIndicator(Modifier.size(18.dp))
|
||||
BusyIndicator(Modifier.size(18.dp))
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
|
||||
@@ -9,6 +9,8 @@ import androidx.compose.material.icons.rounded.SwapVert
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.VisibilityThreshold
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.expandHorizontally
|
||||
import androidx.compose.animation.fadeIn
|
||||
@@ -56,12 +58,12 @@ import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.ExtendedFloatingActionButton
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.WavyProgressIndicatorDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -78,6 +80,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
@@ -108,6 +111,7 @@ import de.jeanlucmakiola.agendula.ui.views.viewName
|
||||
import de.jeanlucmakiola.floret.components.IconInfoCard
|
||||
import androidx.compose.material3.TextButton
|
||||
import de.jeanlucmakiola.agendula.ui.common.ActionShapes
|
||||
import de.jeanlucmakiola.floret.components.ActionButton
|
||||
import de.jeanlucmakiola.floret.components.GroupedRow
|
||||
import de.jeanlucmakiola.floret.components.Position
|
||||
import de.jeanlucmakiola.floret.components.SnackChip
|
||||
@@ -117,11 +121,14 @@ import kotlinx.coroutines.delay
|
||||
import de.jeanlucmakiola.agendula.ui.common.ListColorChip
|
||||
import de.jeanlucmakiola.agendula.ui.common.LocalUse24HourFormat
|
||||
import de.jeanlucmakiola.agendula.ui.common.SearchPill
|
||||
import de.jeanlucmakiola.agendula.ui.common.ShapedActionButton
|
||||
import de.jeanlucmakiola.agendula.ui.common.SyncPullBox
|
||||
import de.jeanlucmakiola.agendula.ui.common.priorityAccent
|
||||
import de.jeanlucmakiola.agendula.ui.tasklist.priorityLabel
|
||||
import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.floret.identity.FloretDensity
|
||||
import de.jeanlucmakiola.floret.identity.reducibleSpec
|
||||
import de.jeanlucmakiola.floret.identity.rememberLoopingMotion
|
||||
import de.jeanlucmakiola.floret.identity.rememberReduceMotion
|
||||
import de.jeanlucmakiola.floret.time.formatDateTimeCompact
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
@@ -624,15 +631,15 @@ private fun LazyListScope.listsSection(
|
||||
SectionHeader(
|
||||
text = stringResource(R.string.lists_header),
|
||||
action = {
|
||||
IconButton(onClick = onToggleReorder) {
|
||||
Icon(
|
||||
if (reordering) Icons.Rounded.Check else Icons.Rounded.SwapVert,
|
||||
contentDescription = stringResource(
|
||||
if (reordering) R.string.lists_reorder_done else R.string.lists_reorder,
|
||||
),
|
||||
)
|
||||
}
|
||||
ShapedActionButton(
|
||||
ActionButton(
|
||||
shape = ActionShapes.Reorder,
|
||||
icon = if (reordering) Icons.Rounded.Check else Icons.Rounded.SwapVert,
|
||||
contentDescription = stringResource(
|
||||
if (reordering) R.string.lists_reorder_done else R.string.lists_reorder,
|
||||
),
|
||||
onClick = onToggleReorder,
|
||||
)
|
||||
ActionButton(
|
||||
shape = ActionShapes.AddList,
|
||||
morphTo = ActionShapes.AddListPressed,
|
||||
icon = Icons.Rounded.Add,
|
||||
@@ -650,12 +657,11 @@ private fun LazyListScope.listsSection(
|
||||
items = group.lists,
|
||||
keyOf = { it.list.id },
|
||||
onReorder = { ordered -> onReorder(ordered.map { it.list.id }) },
|
||||
rowHeight = 72.dp,
|
||||
rowHeight = FloretDensity.rowHeight,
|
||||
) { overview, position, dragHandle, isDragging ->
|
||||
GroupedRow(
|
||||
title = overview.list.name,
|
||||
position = position,
|
||||
minHeight = 72.dp,
|
||||
gapBelow = false,
|
||||
container = if (isDragging) MaterialTheme.colorScheme.secondaryContainer else null,
|
||||
leading = { ListColorChip(overview.list.color) },
|
||||
@@ -677,7 +683,6 @@ private fun LazyListScope.listsSection(
|
||||
GroupedRow(
|
||||
title = overview.list.name,
|
||||
position = positionOf(index, group.lists.size),
|
||||
minHeight = 72.dp,
|
||||
leading = { ListColorChip(overview.list.color) },
|
||||
trailing = {
|
||||
if (options.counts && overview.openCount > 0) {
|
||||
@@ -735,9 +740,13 @@ private fun LazyListScope.filtersSection(
|
||||
null
|
||||
} else {
|
||||
{
|
||||
IconButton(onClick = onNewFilter) {
|
||||
Icon(Icons.Rounded.Add, contentDescription = stringResource(R.string.filter_new_title))
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.AddFilter,
|
||||
morphTo = ActionShapes.AddListPressed,
|
||||
icon = Icons.Rounded.Add,
|
||||
contentDescription = stringResource(R.string.filter_new_title),
|
||||
onClick = onNewFilter,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -849,7 +858,7 @@ private fun HomeTopBar(
|
||||
onToggleSearch = onToggleSearch,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
ShapedActionButton(
|
||||
ActionButton(
|
||||
shape = ActionShapes.Settings,
|
||||
icon = Icons.Rounded.Settings,
|
||||
contentDescription = stringResource(R.string.settings_title),
|
||||
@@ -877,11 +886,21 @@ private fun SearchSlot(
|
||||
onToggleSearch: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
// Under reduced motion the pill fades in place instead of unfurling.
|
||||
val reduced = rememberReduceMotion()
|
||||
Box(modifier = modifier, contentAlignment = Alignment.CenterEnd) {
|
||||
AnimatedVisibility(
|
||||
visible = searchActive,
|
||||
enter = expandHorizontally(tween(300), expandFrom = Alignment.End) + fadeIn(tween(280)),
|
||||
exit = shrinkHorizontally(tween(220), shrinkTowards = Alignment.End) + fadeOut(tween(140)),
|
||||
enter = if (reduced) {
|
||||
fadeIn(tween(280))
|
||||
} else {
|
||||
expandHorizontally(tween(300), expandFrom = Alignment.End) + fadeIn(tween(280))
|
||||
},
|
||||
exit = if (reduced) {
|
||||
fadeOut(tween(140))
|
||||
} else {
|
||||
shrinkHorizontally(tween(220), shrinkTowards = Alignment.End) + fadeOut(tween(140))
|
||||
},
|
||||
) {
|
||||
SearchPill(
|
||||
query = query,
|
||||
@@ -893,7 +912,7 @@ private fun SearchSlot(
|
||||
)
|
||||
}
|
||||
// Always on top, at the end — the bar's fixed search icon and toggle.
|
||||
ShapedActionButton(
|
||||
ActionButton(
|
||||
shape = ActionShapes.Search,
|
||||
icon = Icons.Rounded.Search,
|
||||
contentDescription = stringResource(R.string.home_search_hint),
|
||||
@@ -970,7 +989,7 @@ private fun TodayHero(
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val pressed by interaction.collectIsPressedAsState()
|
||||
val corner by animateDpAsState(if (pressed) 34.dp else 22.dp, label = "todayCorner")
|
||||
val corner by animateDpAsState(if (pressed) 34.dp else 22.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "todayCorner")
|
||||
val left = total - done
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
@@ -1017,6 +1036,9 @@ private fun TodayHero(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
trackColor = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.22f),
|
||||
wavelength = TodayWavelength,
|
||||
// A still wave when motion is reduced or the system removed animations (#157).
|
||||
waveSpeed = if (rememberLoopingMotion()) TodayWavelength else 0.dp,
|
||||
)
|
||||
Text(stringResource(R.string.progress_fraction_compact, done, total), style = MaterialTheme.typography.titleMedium)
|
||||
}
|
||||
@@ -1025,6 +1047,8 @@ private fun TodayHero(
|
||||
}
|
||||
}
|
||||
|
||||
private val TodayWavelength = WavyProgressIndicatorDefaults.CircularWavelength
|
||||
|
||||
/** A grouped card previewing the next few upcoming tasks, with a "view all" tail. */
|
||||
@Composable
|
||||
private fun UpcomingPreview(
|
||||
@@ -1156,7 +1180,7 @@ private fun tileStyle(source: BlockSource, state: ListsUiState.Content): TileSty
|
||||
private fun CountCard(style: TileStyle, count: Int, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val pressed by interaction.collectIsPressedAsState()
|
||||
val corner by animateDpAsState(if (pressed) 34.dp else 22.dp, label = "smartCorner")
|
||||
val corner by animateDpAsState(if (pressed) 34.dp else 22.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "smartCorner")
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(corner),
|
||||
|
||||
@@ -4,7 +4,18 @@ import android.os.Build
|
||||
import android.text.format.DateFormat
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.Switch
|
||||
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.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -14,28 +25,39 @@ 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.domain.localeWeekStart
|
||||
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.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.PreviewOptionRow
|
||||
import de.jeanlucmakiola.floret.locale.currentLocale
|
||||
import de.jeanlucmakiola.floret.prefs.ActionStyle
|
||||
import de.jeanlucmakiola.floret.prefs.LayoutDensity
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
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,53 +80,86 @@ internal fun AppearanceScreen(
|
||||
predictiveBack = true,
|
||||
visible = visible,
|
||||
) {
|
||||
GroupedSectionHeader(stringResource(R.string.settings_group_colours))
|
||||
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(
|
||||
GroupedSwitchRow(
|
||||
title = stringResource(R.string.settings_dynamic_color),
|
||||
summary = if (dynamicColorAvailable) {
|
||||
stringResource(R.string.settings_dynamic_color_hint)
|
||||
} else {
|
||||
stringResource(R.string.settings_dynamic_color_unavailable)
|
||||
},
|
||||
checked = state.settings.dynamicColor && dynamicColorAvailable,
|
||||
onCheckedChange = viewModel::setDynamicColor,
|
||||
position = Position.Bottom,
|
||||
trailing = {
|
||||
Switch(
|
||||
checked = state.settings.dynamicColor && dynamicColorAvailable,
|
||||
onCheckedChange = viewModel::setDynamicColor,
|
||||
enabled = dynamicColorAvailable,
|
||||
)
|
||||
},
|
||||
onClick = if (dynamicColorAvailable) {
|
||||
{ viewModel.setDynamicColor(!state.settings.dynamicColor) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
enabled = dynamicColorAvailable,
|
||||
leading = { Icon(Icons.Rounded.Palette, contentDescription = null) },
|
||||
)
|
||||
|
||||
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))
|
||||
PreviewOptionRow(
|
||||
options = ActionStyle.entries,
|
||||
selected = state.settings.actionStyle,
|
||||
label = { stringResource(actionStyleLabel(it)) },
|
||||
onSelect = viewModel::setActionStyle,
|
||||
preview = { ActionStylePreview(PreviewActions, shaped = it == ActionStyle.SHAPES) },
|
||||
)
|
||||
|
||||
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 +266,23 @@ 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>> = 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
|
||||
|
||||
@@ -5,7 +5,6 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -40,6 +39,7 @@ import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.floret.locale.relativeTimeAgo
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderUnit
|
||||
import de.jeanlucmakiola.floret.reminders.decomposeReminderMinutes
|
||||
import de.jeanlucmakiola.floret.components.BusyIndicator
|
||||
|
||||
/** Backup & restore: export, import and the automatic backup (after Calendula). */
|
||||
@Composable
|
||||
@@ -113,7 +113,7 @@ internal fun BackupScreen(
|
||||
title = stringResource(R.string.backup_auto_now),
|
||||
position = Position.Bottom,
|
||||
dimmed = state.running,
|
||||
trailing = if (state.running) ({ CircularProgressIndicator(Modifier.size(20.dp)) }) else null,
|
||||
trailing = if (state.running) ({ BusyIndicator(Modifier.size(20.dp)) }) else null,
|
||||
onClick = viewModel::backUpNow.takeUnless { state.running },
|
||||
)
|
||||
GroupedHint(backupStatusText(state), style = MaterialTheme.typography.bodySmall)
|
||||
|
||||
@@ -10,7 +10,6 @@ import de.jeanlucmakiola.agendula.data.prefs.ListPersistence
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ReminderDescription
|
||||
import de.jeanlucmakiola.agendula.data.prefs.Settings
|
||||
import de.jeanlucmakiola.agendula.data.prefs.SettingsPrefs
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.agendula.data.prefs.TimeFormatPref
|
||||
import de.jeanlucmakiola.agendula.data.reminders.ReminderScheduler
|
||||
import de.jeanlucmakiola.agendula.data.reminders.TaskNotifier
|
||||
@@ -28,6 +27,9 @@ import de.jeanlucmakiola.agendula.domain.DefaultDueDate
|
||||
import de.jeanlucmakiola.agendula.domain.DefaultStartDate
|
||||
import de.jeanlucmakiola.agendula.domain.TaskFormField
|
||||
import de.jeanlucmakiola.agendula.domain.TaskList
|
||||
import de.jeanlucmakiola.floret.prefs.ActionStyle
|
||||
import de.jeanlucmakiola.floret.prefs.LayoutDensity
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderLead
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderOverride
|
||||
import de.jeanlucmakiola.agendula.widget.TaskWidgetUpdater
|
||||
@@ -98,8 +100,8 @@ data class TransferUiState(
|
||||
)
|
||||
|
||||
/**
|
||||
* Drives both the Settings screen and the app theme (MainActivity collects the
|
||||
* same instance), so a theme change applies app-wide at once.
|
||||
* Drives the Settings screens. The app theme reads the stored settings itself,
|
||||
* so a change made here applies app-wide at once.
|
||||
*/
|
||||
@HiltViewModel
|
||||
class SettingsViewModel @Inject constructor(
|
||||
@@ -116,9 +118,9 @@ class SettingsViewModel @Inject constructor(
|
||||
repository: TasksRepository,
|
||||
) : ViewModel() {
|
||||
|
||||
// MainActivity collects this for the theme, above the permission gate and for
|
||||
// the whole Activity lifetime — so the list flow must survive the pre-grant
|
||||
// SecurityException and recover once permission is given, not die for good.
|
||||
// The list flow may be collected before the provider permission is granted, so
|
||||
// it must survive the pre-grant SecurityException and recover once permission
|
||||
// is given, not die for good.
|
||||
val state: StateFlow<SettingsUiState> =
|
||||
combine(
|
||||
prefs.settings,
|
||||
@@ -244,6 +246,9 @@ class SettingsViewModel @Inject constructor(
|
||||
|
||||
fun setThemeMode(mode: ThemeMode) = viewModelScope.launch { prefs.setThemeMode(mode) }
|
||||
fun setDynamicColor(enabled: Boolean) = viewModelScope.launch { prefs.setDynamicColor(enabled) }
|
||||
fun setDensity(density: LayoutDensity) = viewModelScope.launch { prefs.setDensity(density) }
|
||||
fun setActionStyle(style: ActionStyle) = viewModelScope.launch { prefs.setActionStyle(style) }
|
||||
fun setReduceMotion(enabled: Boolean) = viewModelScope.launch { prefs.setReduceMotion(enabled) }
|
||||
fun setDefaultList(id: Long?) = viewModelScope.launch { prefs.setDefaultListId(id) }
|
||||
fun setDefaultReminders(leads: List<ReminderLead>) = viewModelScope.launch {
|
||||
prefs.setDefaultReminders(leads)
|
||||
|
||||
@@ -18,7 +18,6 @@ import androidx.compose.material.icons.rounded.MoveDown
|
||||
import androidx.compose.material.icons.rounded.PhoneAndroid
|
||||
import androidx.compose.material.icons.rounded.SwapHoriz
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -47,6 +46,7 @@ import de.jeanlucmakiola.floret.components.FullScreenPicker
|
||||
import de.jeanlucmakiola.floret.components.GroupedRow
|
||||
import de.jeanlucmakiola.floret.components.Position
|
||||
import de.jeanlucmakiola.floret.components.SelectedCheck
|
||||
import de.jeanlucmakiola.floret.components.BusyIndicator
|
||||
|
||||
/**
|
||||
* Where the tasks live: the store picker the resolver's `autoMode()` has always
|
||||
@@ -282,7 +282,7 @@ private fun TransferStatus(state: TransferUiState) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
CircularProgressIndicator(Modifier.size(18.dp))
|
||||
BusyIndicator(Modifier.size(18.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.settings_copy_running),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
|
||||
@@ -4,6 +4,8 @@ import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.VisibilityThreshold
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
@@ -58,13 +60,10 @@ import androidx.compose.material.icons.rounded.PushPin
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.Badge
|
||||
import androidx.compose.material3.BadgedBox
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExtendedFloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.MediumTopAppBar
|
||||
import androidx.compose.material3.Scaffold
|
||||
@@ -114,6 +113,7 @@ import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
@@ -147,6 +147,11 @@ import de.jeanlucmakiola.floret.components.SnackChipMargin
|
||||
import de.jeanlucmakiola.floret.time.formatDateTimeCompact
|
||||
import de.jeanlucmakiola.floret.components.pastelize
|
||||
import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.floret.identity.FloretDensity
|
||||
import de.jeanlucmakiola.floret.identity.reducibleSpec
|
||||
import de.jeanlucmakiola.floret.identity.rememberReduceMotion
|
||||
import de.jeanlucmakiola.floret.components.ActionButton
|
||||
import de.jeanlucmakiola.agendula.ui.common.ActionShapes
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
|
||||
@@ -260,37 +265,38 @@ fun TaskListScreen(
|
||||
},
|
||||
actions = {
|
||||
if (listId != null) {
|
||||
IconButton(onClick = viewModel::openSearch, enabled = content != null) {
|
||||
Icon(Icons.Rounded.Search, contentDescription = stringResource(R.string.task_search_action))
|
||||
}
|
||||
}
|
||||
IconButton(onClick = { showSort = true }, enabled = content != null) {
|
||||
val narrowed = content?.selectedTags?.isNotEmpty() == true || content?.upcomingLimited == true
|
||||
BadgedBox(badge = { if (narrowed) Badge() }) {
|
||||
Icon(Icons.Rounded.Tune, contentDescription = stringResource(R.string.view_options_title))
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.Search,
|
||||
icon = Icons.Rounded.Search,
|
||||
contentDescription = stringResource(R.string.task_search_action),
|
||||
onClick = viewModel::openSearch,
|
||||
enabled = content != null,
|
||||
)
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.ViewOptions,
|
||||
icon = Icons.Rounded.Tune,
|
||||
contentDescription = stringResource(R.string.view_options_title),
|
||||
onClick = { showSort = true },
|
||||
enabled = content != null,
|
||||
badge = content?.selectedTags?.isNotEmpty() == true || content?.upcomingLimited == true,
|
||||
)
|
||||
if (savedFilter != null) {
|
||||
IconButton(onClick = { onEditFilter(savedFilter.id) }) {
|
||||
Icon(Icons.Rounded.Edit, contentDescription = stringResource(R.string.filter_edit_title))
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.Edit,
|
||||
icon = Icons.Rounded.Edit,
|
||||
contentDescription = stringResource(R.string.filter_edit_title),
|
||||
onClick = { onEditFilter(savedFilter.id) },
|
||||
)
|
||||
}
|
||||
if (list != null) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (list.isReadOnly) readOnlyHint = true else editingList = true
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
Icons.Rounded.Edit,
|
||||
contentDescription = stringResource(R.string.list_edit_title),
|
||||
tint = if (list.isReadOnly) {
|
||||
LocalContentColor.current.copy(alpha = 0.38f)
|
||||
} else {
|
||||
LocalContentColor.current
|
||||
},
|
||||
)
|
||||
}
|
||||
ActionButton(
|
||||
shape = ActionShapes.Edit,
|
||||
icon = Icons.Rounded.Edit,
|
||||
contentDescription = stringResource(R.string.list_edit_title),
|
||||
onClick = { if (list.isReadOnly) readOnlyHint = true else editingList = true },
|
||||
dimmed = list.isReadOnly,
|
||||
)
|
||||
}
|
||||
// A list or a saved filter can become a view of its own (#59).
|
||||
if (list != null || savedFilter != null) {
|
||||
@@ -712,7 +718,8 @@ internal fun LazyListScope.taskRows(
|
||||
// animateItem so an (un)expanding group fades its subtasks in/out
|
||||
// and slides the rows below — clean whether the children were
|
||||
// already loaded (real list) or arrive a frame later (smart list).
|
||||
val rowModifier = Modifier.animateItem()
|
||||
// Under reduced motion they only fade; nothing slides.
|
||||
val rowModifier = if (rememberReduceMotion()) Modifier.animateItem(placementSpec = null) else Modifier.animateItem()
|
||||
when (val row = r.row) {
|
||||
is ListRow.Parent -> TaskRow(
|
||||
modifier = rowModifier,
|
||||
@@ -907,8 +914,8 @@ internal fun TaskRowContent(
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val pressed by interaction.collectIsPressedAsState()
|
||||
val full by animateDpAsState(if (pressed) 36.dp else 22.dp, label = "fullCorner")
|
||||
val small by animateDpAsState(if (pressed) 36.dp else 6.dp, label = "smallCorner")
|
||||
val full by animateDpAsState(if (pressed) 36.dp else 22.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "fullCorner")
|
||||
val small by animateDpAsState(if (pressed) 36.dp else 6.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "smallCorner")
|
||||
val dark = isSystemInDarkTheme()
|
||||
val due = task.shownValue(TaskEnd.DUE)?.formatDateTimeCompact(!task.hasTime(TaskEnd.DUE), LocalUse24HourFormat.current)
|
||||
val listName = task.listName?.takeIf { showListName && it.isNotBlank() }
|
||||
@@ -930,8 +937,8 @@ internal fun TaskRowContent(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 64.dp)
|
||||
.padding(start = 12.dp, end = 16.dp, top = 8.dp, bottom = 8.dp),
|
||||
.heightIn(min = FloretDensity.cardRowHeight)
|
||||
.padding(start = 12.dp, end = 16.dp, top = FloretDensity.cardRowInset, bottom = FloretDensity.cardRowInset),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// Calendula's signature accent: a slim pastelised colour bar for the
|
||||
@@ -1136,7 +1143,7 @@ private fun AddSubtaskRow(
|
||||
modifier = modifier.fillMaxWidth().padding(horizontal = 16.dp).then(gap).revealOnFocus(),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().heightIn(min = 52.dp).padding(start = 12.dp, end = 8.dp),
|
||||
modifier = Modifier.fillMaxWidth().heightIn(min = FloretDensity.nestedRowHeight).padding(start = 12.dp, end = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Spacer(Modifier.width(5.dp)) // the parents' colour-bar slot, kept for alignment
|
||||
@@ -1184,7 +1191,7 @@ private fun AddSubtaskRow(
|
||||
/** The trailing expand/collapse control for a parent row — a rotating chevron. */
|
||||
@Composable
|
||||
private fun SubtaskExpandButton(expanded: Boolean, onToggle: () -> Unit) {
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, label = "subtaskExpand")
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, reducibleSpec(spring()), label = "subtaskExpand")
|
||||
IconButton(onClick = onToggle) {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.ExpandMore,
|
||||
@@ -1260,8 +1267,8 @@ private fun SubtaskRow(
|
||||
)
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val pressed by interaction.collectIsPressedAsState()
|
||||
val full by animateDpAsState(if (pressed) 36.dp else 22.dp, label = "subFullCorner")
|
||||
val small by animateDpAsState(if (pressed) 36.dp else 6.dp, label = "subSmallCorner")
|
||||
val full by animateDpAsState(if (pressed) 36.dp else 22.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "subFullCorner")
|
||||
val small by animateDpAsState(if (pressed) 36.dp else 6.dp, reducibleSpec(spring(visibilityThreshold = Dp.VisibilityThreshold)), label = "subSmallCorner")
|
||||
val gap = if (lastInRun) Modifier else Modifier.padding(bottom = 2.dp)
|
||||
SwipeToDismissBox(
|
||||
state = dismissState,
|
||||
@@ -1280,8 +1287,8 @@ private fun SubtaskRow(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 56.dp)
|
||||
.padding(start = 12.dp, end = 16.dp, top = 6.dp, bottom = 6.dp),
|
||||
.heightIn(min = FloretDensity.nestedRowHeight)
|
||||
.padding(start = 12.dp, end = 16.dp, top = FloretDensity.nestedRowInset, bottom = FloretDensity.nestedRowInset),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// No colour bar — that absence (with the grouped nesting) marks the row
|
||||
@@ -1364,7 +1371,7 @@ private fun CollapsibleSectionHeader(
|
||||
onToggle: () -> Unit,
|
||||
onClear: (() -> Unit)? = null,
|
||||
) {
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, label = "chevron")
|
||||
val rotation by animateFloatAsState(if (expanded) 180f else 0f, reducibleSpec(spring()), label = "chevron")
|
||||
Surface(
|
||||
onClick = onToggle,
|
||||
color = MaterialTheme.colorScheme.surface,
|
||||
|
||||
@@ -5,7 +5,8 @@ import android.app.UiModeManager
|
||||
import android.os.Build
|
||||
import androidx.annotation.StyleRes
|
||||
import de.jeanlucmakiola.agendula.R
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.isPureBlack
|
||||
|
||||
/**
|
||||
* Hands the app's theme setting to the system, which draws the launch window
|
||||
|
||||
@@ -2,7 +2,12 @@ package de.jeanlucmakiola.agendula.ui.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import de.jeanlucmakiola.agendula.data.prefs.Settings
|
||||
import de.jeanlucmakiola.floret.identity.FloretExpressiveTheme
|
||||
import de.jeanlucmakiola.floret.prefs.ActionStyle
|
||||
import de.jeanlucmakiola.floret.prefs.LayoutDensity
|
||||
import de.jeanlucmakiola.floret.prefs.isDark
|
||||
import de.jeanlucmakiola.floret.prefs.isPureBlack
|
||||
|
||||
/**
|
||||
* Agendula's theme: the family's [FloretExpressiveTheme] machinery (dynamic
|
||||
@@ -16,6 +21,9 @@ fun AgendulaTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
dynamicColor: Boolean = true,
|
||||
pureBlack: Boolean = false,
|
||||
compactLayout: Boolean = false,
|
||||
shapedActions: Boolean = false,
|
||||
reduceMotion: Boolean = false,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
FloretExpressiveTheme(
|
||||
@@ -25,6 +33,21 @@ fun AgendulaTheme(
|
||||
dynamicColor = dynamicColor,
|
||||
pureBlack = pureBlack,
|
||||
typography = AgendulaTypography,
|
||||
compactLayout = compactLayout,
|
||||
shapedActions = shapedActions,
|
||||
reduceMotion = reduceMotion,
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
||||
/** [AgendulaTheme] as the stored [settings] ask for it: theme mode, colours, density, buttons and motion. */
|
||||
@Composable
|
||||
fun AgendulaTheme(settings: Settings, content: @Composable () -> Unit) = AgendulaTheme(
|
||||
darkTheme = settings.themeMode.isDark(isSystemInDarkTheme()),
|
||||
dynamicColor = settings.dynamicColor,
|
||||
pureBlack = settings.themeMode.isPureBlack,
|
||||
compactLayout = settings.density == LayoutDensity.COMPACT,
|
||||
shapedActions = settings.actionStyle == ActionStyle.SHAPES,
|
||||
reduceMotion = settings.reduceMotion,
|
||||
content = content,
|
||||
)
|
||||
@@ -55,6 +55,7 @@ import de.jeanlucmakiola.floret.components.pastelize
|
||||
import de.jeanlucmakiola.floret.components.positionOf
|
||||
import de.jeanlucmakiola.floret.glance.WidgetBackground
|
||||
import de.jeanlucmakiola.floret.glance.WidgetThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.isDark
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -135,11 +136,7 @@ class TaskWidgetConfigActivity : ComponentActivity() {
|
||||
selectedListIds = parseWidgetListIds(state[WIDGET_LIST_IDS_KEY])
|
||||
}
|
||||
val dark = settings.themeMode.isDark(isSystemInDarkTheme())
|
||||
AgendulaTheme(
|
||||
darkTheme = dark,
|
||||
dynamicColor = settings.dynamicColor,
|
||||
pureBlack = settings.themeMode.isPureBlack,
|
||||
) {
|
||||
AgendulaTheme(settings) {
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {}
|
||||
WidgetFilterPicker(
|
||||
kind = kind,
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.jeanlucmakiola.agendula.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateFormat
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.agendula.data.prefs.is24Hour
|
||||
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
@@ -14,6 +13,7 @@ import de.jeanlucmakiola.agendula.domain.calendarDate
|
||||
import de.jeanlucmakiola.agendula.domain.comparator
|
||||
import de.jeanlucmakiola.floret.glance.WidgetBackground
|
||||
import de.jeanlucmakiola.floret.glance.WidgetThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.jeanlucmakiola.agendula.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateFormat
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.agendula.data.prefs.is24Hour
|
||||
import de.jeanlucmakiola.agendula.domain.SmartList
|
||||
import de.jeanlucmakiola.agendula.domain.Task
|
||||
@@ -12,6 +11,7 @@ import de.jeanlucmakiola.agendula.domain.TaskFiltering
|
||||
import de.jeanlucmakiola.agendula.domain.TaskList
|
||||
import de.jeanlucmakiola.agendula.domain.TaskSorting
|
||||
import de.jeanlucmakiola.agendula.domain.comparator
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.time.DayWindow
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
|
||||
@@ -526,6 +526,19 @@
|
||||
<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">Screens fade instead of sliding, and looping animations like the progress wave stay still. The system “Remove animations” setting does the same.</string>
|
||||
<string name="settings_group_colours">Colours</string>
|
||||
<string name="settings_group_date_time">Date & 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>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package de.jeanlucmakiola.agendula.data.prefs
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||
import androidx.datastore.preferences.core.emptyPreferences
|
||||
import androidx.datastore.preferences.core.mutablePreferencesOf
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.agendula.data.tasks.ProviderEnvironment
|
||||
import de.jeanlucmakiola.agendula.data.tasks.ProviderResolver
|
||||
import de.jeanlucmakiola.floret.prefs.ActionStyle
|
||||
import de.jeanlucmakiola.floret.prefs.LayoutDensity
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/** Density, button style and reduce motion as [Settings] carries them; the stored keys are floret-kit's to test. */
|
||||
class AppearanceSettingsTest {
|
||||
|
||||
private class MemoryDataStore(initial: Preferences = emptyPreferences()) : DataStore<Preferences> {
|
||||
override val data = MutableStateFlow(initial)
|
||||
override suspend fun updateData(transform: suspend (t: Preferences) -> Preferences) =
|
||||
transform(data.value).also { data.value = it }
|
||||
}
|
||||
|
||||
private object NoProviders : ProviderEnvironment {
|
||||
override fun packageDeclaring(authority: String): String? = null
|
||||
override fun isGranted(permission: String) = false
|
||||
override fun appLabel(packageName: String): String? = null
|
||||
}
|
||||
|
||||
private fun prefs(dataStore: DataStore<Preferences> = MemoryDataStore()) =
|
||||
SettingsPrefs(dataStore, ProviderResolver(NoProviders))
|
||||
|
||||
@Test
|
||||
fun `a fresh install is comfortable, icons only, with motion on`() = runBlocking<Unit> {
|
||||
val settings = prefs().settings.first()
|
||||
|
||||
assertThat(Triple(settings.density, settings.actionStyle, settings.reduceMotion))
|
||||
.isEqualTo(Triple(LayoutDensity.COMFORTABLE, ActionStyle.ICONS, false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an existing install gets icons only too`() = runBlocking<Unit> {
|
||||
val upgraded = MemoryDataStore(
|
||||
mutablePreferencesOf(
|
||||
stringPreferencesKey("theme_mode") to "DARK",
|
||||
booleanPreferencesKey("dynamic_color") to false,
|
||||
),
|
||||
)
|
||||
|
||||
assertThat(prefs(upgraded).settings.first().actionStyle).isEqualTo(ActionStyle.ICONS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the choices are kept`() = runBlocking<Unit> {
|
||||
val prefs = prefs()
|
||||
|
||||
prefs.setDensity(LayoutDensity.COMPACT)
|
||||
prefs.setActionStyle(ActionStyle.SHAPES)
|
||||
prefs.setReduceMotion(true)
|
||||
|
||||
val settings = prefs.settings.first()
|
||||
assertThat(Triple(settings.density, settings.actionStyle, settings.reduceMotion))
|
||||
.isEqualTo(Triple(LayoutDensity.COMPACT, ActionStyle.SHAPES, true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a theme stored before floret-kit took the keys over is kept`() = runBlocking<Unit> {
|
||||
val upgraded = MemoryDataStore(
|
||||
mutablePreferencesOf(
|
||||
stringPreferencesKey("theme_mode") to "BLACK",
|
||||
booleanPreferencesKey("dynamic_color") to false,
|
||||
),
|
||||
)
|
||||
|
||||
val settings = prefs(upgraded).settings.first()
|
||||
|
||||
assertThat(settings.themeMode to settings.dynamicColor).isEqualTo(ThemeMode.BLACK to false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a theme choice is written where earlier versions read it`() = runBlocking<Unit> {
|
||||
val dataStore = MemoryDataStore()
|
||||
|
||||
prefs(dataStore).setThemeMode(ThemeMode.DARK)
|
||||
|
||||
assertThat(dataStore.data.value[stringPreferencesKey("theme_mode")]).isEqualTo("DARK")
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package de.jeanlucmakiola.agendula.ui.theme
|
||||
import android.app.UiModeManager
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.agendula.R
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class SystemThemeTest {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.jeanlucmakiola.agendula.widget
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.agendula.data.prefs.ThemeMode
|
||||
import de.jeanlucmakiola.agendula.domain.SmartList
|
||||
import de.jeanlucmakiola.agendula.domain.TaskFilter
|
||||
import de.jeanlucmakiola.agendula.domain.TaskSorting
|
||||
@@ -10,6 +9,7 @@ import de.jeanlucmakiola.agendula.domain.allDayInstantOf
|
||||
import de.jeanlucmakiola.agendula.domain.testTask
|
||||
import de.jeanlucmakiola.floret.glance.WidgetBackground
|
||||
import de.jeanlucmakiola.floret.glance.WidgetThemeMode
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
|
||||
+1
-1
Submodule floret-kit updated: 0c8f5367f5...a7f8166c4b.
@@ -174,6 +174,7 @@ floret-core-time = { group = "de.jeanlucmakiola.floret", name = "core-time" }
|
||||
floret-core-reminders = { group = "de.jeanlucmakiola.floret", name = "core-reminders" }
|
||||
floret-core-locale = { group = "de.jeanlucmakiola.floret", name = "core-locale" }
|
||||
floret-core-crash = { group = "de.jeanlucmakiola.floret", name = "core-crash" }
|
||||
floret-core-prefs = { group = "de.jeanlucmakiola.floret", name = "core-prefs" }
|
||||
floret-identity = { group = "de.jeanlucmakiola.floret", name = "identity" }
|
||||
floret-components = { group = "de.jeanlucmakiola.floret", name = "components" }
|
||||
floret-glance = { group = "de.jeanlucmakiola.floret", name = "glance" }
|
||||
|
||||
Reference in new issue
Block a user