diff options
| -rw-r--r-- | android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt index b40b868..f8d8ae1 100644 --- a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt +++ b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt @@ -62,11 +62,14 @@ class DootWidget : GlanceAppWidget() { fun WidgetRoot(items: List<WidgetItem>, now: Instant) { val zone = ZoneId.systemDefault() val nowZoned: ZonedDateTime = now.atZone(zone) - val scheduled = items.filter { it.start != null }.sortedBy { Instant.parse(it.start!!) } + val allScheduled = items.filter { it.start != null }.sortedBy { Instant.parse(it.start!!) } + // Past tasks float at now (before untimed tasks); past events stay in the grid at 50% alpha + val pastTasks = allScheduled.filter { it.type == "task" && Instant.parse(it.start!!) < now } + val scheduledEvents = allScheduled.filter { it.type != "task" || Instant.parse(it.start!!) >= now } val floating = items.filter { it.start == null } - val fragments = SlotPacker.pack(floating, scheduled, now) - val gridStart = calcGridStart(scheduled, nowZoned.hour) - val gridEnd = calcGridEnd(scheduled, nowZoned.hour) + val fragments = SlotPacker.pack(pastTasks + floating, scheduledEvents, now) + val gridStart = calcGridStart(scheduledEvents, nowZoned.hour) + val gridEnd = calcGridEnd(scheduledEvents, nowZoned.hour) Column( modifier = GlanceModifier @@ -86,7 +89,7 @@ fun WidgetRoot(items: List<WidgetItem>, now: Instant) { } for (hour in gridStart..gridEnd) { - HourRow(hour, nowZoned, scheduled, fragments, zone) + HourRow(hour, nowZoned, scheduledEvents, fragments, zone) } } } @@ -157,7 +160,7 @@ fun EventBlock(event: WidgetItem, isPast: Boolean) { Row( modifier = GlanceModifier .fillMaxWidth() - .padding(vertical = 2.dp) + .padding(vertical = 4.dp) .clickable(actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(event.url.ifEmpty { "https://calendar.google.com" })))), verticalAlignment = Alignment.CenterVertically ) { @@ -171,9 +174,9 @@ fun EventBlock(event: WidgetItem, isPast: Boolean) { text = event.title, style = TextStyle( color = ColorProvider(Color.White.copy(alpha = alpha)), - fontSize = 13.sp + fontSize = 14.sp ), - modifier = GlanceModifier.padding(start = 6.dp), + modifier = GlanceModifier.padding(start = 8.dp), maxLines = 1 ) } @@ -206,7 +209,7 @@ fun TaskRow(task: WidgetItem) { Row( modifier = GlanceModifier .fillMaxWidth() - .padding(horizontal = 8.dp, vertical = 2.dp), + .padding(horizontal = 8.dp, vertical = 5.dp), verticalAlignment = Alignment.CenterVertically ) { if (task.completable) { @@ -235,9 +238,9 @@ fun TaskRow(task: WidgetItem) { text = task.title, style = TextStyle( color = ColorProvider(Color(0xFFDDDDDD.toInt())), - fontSize = 13.sp + fontSize = 14.sp ), - modifier = GlanceModifier.padding(start = 7.dp), + modifier = GlanceModifier.padding(start = 8.dp), maxLines = 1 ) } |
