Classic agenda: readable dimming on any fill, year on far dates (#489)

This commit is contained in:
makiolaj committed 2026-11-09 19:27:27 +01:00
1 parent 7d149d2ab1
commit f896153fb7
3 files changed
+16 -5

No files matched your search

@@ -61,6 +61,7 @@ import de.jeanlucmakiola.calendula.ui.common.eventAccent
import de.jeanlucmakiola.calendula.ui.common.EventDimAlpha
import de.jeanlucmakiola.calendula.widget.AgendaWidgetStyle
import de.jeanlucmakiola.floret.glance.LocalWidgetSeeThrough
import de.jeanlucmakiola.floret.glance.withAlpha
import de.jeanlucmakiola.calendula.widget.WidgetDimFillAlpha
import de.jeanlucmakiola.calendula.widget.widgetEventInk
import de.jeanlucmakiola.calendula.ui.common.SECONDARY_INK_ALPHA
@@ -422,7 +423,7 @@ private fun ClassicEventRow(row: AgendaRow.Event, data: AgendaWidgetData.Ready,
text = event.title.ifBlank { context.getString(R.string.event_untitled) },
maxLines = 1,
style = TextStyle(
color = if (dimmed) GlanceTheme.colors.outline else GlanceTheme.colors.onSurface,
color = if (dimmed) GlanceTheme.colors.onSurface.withAlpha(CLASSIC_DIM_INK) else GlanceTheme.colors.onSurface,
fontSize = metrics.eventTitle,
textDecoration = glanceDeclinedDecoration(event.isCrossedOut),
),
@@ -431,7 +432,11 @@ private fun ClassicEventRow(row: AgendaRow.Event, data: AgendaWidgetData.Ready,
text = eventTimeSummary(context, event, row.date, data.is24Hour),
maxLines = 1,
style = TextStyle(
color = if (dimmed) GlanceTheme.colors.outline else GlanceTheme.colors.onSurfaceVariant,
color = if (dimmed) {
GlanceTheme.colors.onSurfaceVariant.withAlpha(CLASSIC_DIM_INK)
} else {
GlanceTheme.colors.onSurfaceVariant
},
fontSize = metrics.eventTime,
),
)
@@ -443,6 +448,9 @@ private fun ClassicEventRow(row: AgendaRow.Event, data: AgendaWidgetData.Ready,
private val CLASSIC_CARD_TOP_PAD = 8.dp
private val CLASSIC_CARD_H_PAD = 10.dp
/** How strongly a finished event's text shows in the classic style, on any fill. */
private const val CLASSIC_DIM_INK = 0.5f
/** Where each row sits among the rows of its day, from each row's date, for the grouped-card shapes. */
private fun dayPositions(dates: List<LocalDate>): List<Position> = buildList {
var start = 0
@@ -639,7 +647,7 @@ private fun agendaDayLabel(context: Context, date: LocalDate, today: LocalDate):
val java = java.time.LocalDate.of(date.year, date.month.ordinal + 1, date.day)
// Weekday + date in the locale's own field order (compact: no year), rather
// than a hardcoded day-month layout.
val formatted = localizedDateFormatter(locale, "EEEdMMM").format(java)
val formatted = localizedDateFormatter(locale, if (date.year == today.year) "EEEdMMM" else "EEEdMMMy").format(java)
return if (relative != null) "$relative · $formatted" else formatted
}
@@ -72,6 +72,7 @@ import kotlin.math.roundToInt
import de.jeanlucmakiola.floret.components.GroupedSliderRow
import de.jeanlucmakiola.calendula.widget.AgendaWidgetStyle
import java.text.NumberFormat
import de.jeanlucmakiola.floret.locale.currentLocale
import androidx.compose.runtime.remember
private val PreviewMaxHeight = 280.dp
@@ -247,7 +248,9 @@ private fun ConfigOptions(
value = opacity,
onValueChange = { onAppearance(state.appearance.copy(opacity = it)) },
position = Position.Middle,
valueLabel = remember(opacity) { NumberFormat.getPercentInstance().format(opacity) },
valueLabel = currentLocale().let { locale ->
remember(opacity, locale) { NumberFormat.getPercentInstance(locale).format(opacity) }
},
valueRange = MIN_OPACITY..1f,
steps = OPACITY_STEPS,
)