Repository Public MIT
1# GlassTimeline23| | |4|---|---|5| Identifier | `glass-timeline` |6| Module | `SPGlassData` |7| Kind | `content-component` — plain content, no surface and no glass |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Data/GlassTimelineExample.swift` |1011## Minimal usage1213```swift14ScrollView {15 GlassTimeline(events)16}17```1819```swift20let events = [21 GlassTimelineEvent(id: "ordered", date: orderedAt, title: "Order placed"),22 GlassTimelineEvent(id: "shipped", date: shippedAt, title: "Handed to the carrier", systemImage: "shippingbox"),23]24```2526## Variants2728| Variant | Use |29|---|---|30| `order: .ascending` | Oldest first (default): a history read from the beginning. |31| `order: .descending` | Most recent first: an activity feed. |32| Event with `systemImage` | The marker is the SF Symbol instead of a dot. |33| Event with `detail` | A second line under the title. |3435## Parameters3637| Parameter | Type | Default | Meaning |38|---|---|---|---|39| `events` | `[GlassTimelineEvent]` | — | Events in any order. |40| `order` | `GlassTimelineOrder` | `.ascending` | Chronological direction. |41| `emptyTitle` | `LocalizedStringKey?` | `nil` | Text of the empty state; defaults to the localised "No events". |4243`GlassTimelineEvent(id:date:title:detail:systemImage:)` — `title` and `detail` are data and displayed as they are.4445Calendar, time zone and locale come from the environment (`\.calendar`, `\.timeZone`, `\.locale`).4647### Layout and tone4849| Parameter | Type | Default | Meaning |50|---|---|---|---|51| `GlassTimelineEvent.tone` | `GlassBadgeTone` | `.accent` | Colour of the event's marker. Decorative: the title carries the meaning. |5253Each event shows its time in a leading column, a marker on a rail (a tinted tile holding the event's symbol, or a ring) and its title and detail. Day titles are uppercase eyebrow labels followed by a hairline. At accessibility text sizes the time moves above the title. The timeline has no surface of its own: place it in a `GlassCard` or on a page.5455## States5657- **Empty**: a `ContentUnavailableView` with `emptyTitle`.58- **Populated**: one header per calendar day (complete localised date) followed by that day's events with their time.5960## Advanced example6162```swift63GlassTimeline(log, order: .descending, emptyTitle: "Nothing has happened yet")64 .environment(\.timeZone, TimeZone(identifier: "Asia/Tokyo") ?? .gmt)65 .environment(\.locale, Locale(identifier: "fr_CA"))6667// Grouping is a pure function, usable for exports or tests:68var calendar = Calendar(identifier: .gregorian)69calendar.timeZone = TimeZone(identifier: "America/Toronto") ?? .gmt70let days = GlassTimelineLogic.groups(log, order: .ascending, calendar: calendar)71let title = GlassTimelineLogic.dayTitle(days[0].day, calendar: calendar, locale: Locale(identifier: "fr_CA"))72```7374## Accessibility7576- Day titles are headers, so VoiceOver users can jump from day to day with the rotor.77- Each event is one element reading its time, title and detail.78- Markers and the connecting line are decorative and hidden from assistive technologies.79- Dates and times are formatted with `Date.FormatStyle` in the environment's locale, calendar and time zone; text follows Dynamic Type and wraps.80- Layout uses leading and trailing only, so it mirrors in right-to-left languages.8182## Limits8384- The day of an event depends on the time zone: the same instant can appear under different days for two users. This is intended; pass the time zone you want through the environment.85- Days of 23 or 25 hours (daylight saving time) are single groups; grouping relies on `Calendar.startOfDay(for:)`.86- Events with the same date keep the order of the input array.87- Events are sorted and grouped in `body` on every update; for very long logs paginate in the model.88- The timeline has no scroll view of its own and no interaction (no selection, no expansion).89- Events are a fixed value type; a timeline with custom rows should use `GlassTimelineLogic` with its own views.90