Auto-scroll agenda to current day and time on open#419
Conversation
Agent-Logs-Url: https://github.com/paug/AndroidMakersApp/sessions/e260d2e1-e554-4ec0-84b4-e415ce4764d1 Co-authored-by: benju69 <2486590+benju69@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the agenda UI so that when the user opens the agenda, it defaults to today’s tab and the session list starts near the current time slot (via an initial lazy list index), avoiding a post-render scroll animation.
Changes:
- Added an
initialFirstVisibleItemIndexparameter toAgendaColumnand wired it intorememberLazyListState. - In
AgendaPager, detects whether a page corresponds to “today” and computes an initial scroll index for that day. - Introduced
currentTimeScrollIndex()to compute the lazy-list index of the last started time-slot header.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
shared/ui/src/commonMain/kotlin/com/androidmakers/ui/agenda/AgendaPager.kt |
Computes “today” per page and derives an initial scroll index; adds currentTimeScrollIndex() helper. |
shared/ui/src/commonMain/kotlin/com/androidmakers/ui/agenda/AgendaColumn.kt |
Accepts an initial list position and passes it into rememberLazyListState for first render positioning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val isToday = remember(page) { | ||
| days[page].date == Clock.System.todayIn(eventTimeZone) | ||
| } |
There was a problem hiding this comment.
isToday is memoized only by page, but it depends on days[page].date and on Clock.System.todayIn(eventTimeZone). With the current remember(page) it can become stale (e.g., if days updates while staying on the same page index, or if the date changes while the screen stays in the back stack). Consider computing isToday directly from day.date (no remember), or at least keying remember on day.date (and avoid indexing back into days since day is already available).
| val isToday = remember(page) { | |
| days[page].date == Clock.System.todayIn(eventTimeZone) | |
| } | |
| val isToday = day.date == Clock.System.todayIn(eventTimeZone) |
When opening the agenda, the app should land on today's tab and scroll the list to the current time slot — e.g. at 13:37 it should show the 13:30 sticky header.
Changes
AgendaColumn: AddedinitialFirstVisibleItemIndex: Int = 0parameter, passed directly torememberLazyListStateso the list starts at the right position before first render (no scroll animation).AgendaPager: For each page, checks whether it represents today (comparingDaySchedule.dateagainstClock.System.todayIn(eventTimeZone)). If so, callscurrentTimeScrollIndex()and passes the result toAgendaColumn; otherwise defaults to0.currentTimeScrollIndex(): Walks theMap<String, List<UISession>>accumulating lazy list item indices (1 header + N sessionsper slot) and tracks the index of the last slot whosestartDate ≤ now. Returns0if all slots are in the future.