Skip to content

Repository files navigation

TimelineUI

CodebergSwift 6.2iOS 26+

A SwiftUI component library for displaying calendar timeline views in iOS apps. Show daily schedules on an hour grid with automatic layout for overlapping events.

Installation

Add TimelineUI to your project using Swift Package Manager:

dependencies:[.package(url:"https://codeberg.org/ctietze/timeline-ui.git", from:"1.0.0")]

Note: This project is canonically hosted on Codeberg. GitHub is a mirror.

Quick Start

import TimelineUI
structScheduleView:View{letevents:[TimelineItem]=[TimelineItem(
title:"Team Meeting",
startDate:Date(),
endDate:Date().addingTimeInterval(3600),
color:.blue,
location:"Conference Room A"),TimelineItem(
title:"Lunch",
startDate:Date().addingTimeInterval(7200),
endDate:Date().addingTimeInterval(10800),
color:.green
)]varbody:someView{DayTimelineView(items: events)}}

Components

DayTimelineView

Full day timeline that automatically expands to fill available space. Shows hour grid lines with events positioned by time.

DayTimelineView(items:[TimelineItem])

CompactTimelineView

Compact timeline window, ideal for widgets or previews.

CompactTimelineView(items:[TimelineItem]) // Fills available height
CompactTimelineView(items:[TimelineItem], heightMode:.flexible) // Same as above
CompactTimelineView(items:[TimelineItem], heightMode:.fixed(hours:2)) // Fixed 2-hour window

Expandable Timeline

Tap a compact timeline to expand into a full day view with a smooth matched geometry animation:

Expandable timeline animation

@StateprivatevarisExpanded=false@NamespaceprivatevartimelineNamespace
// Compact view with tap-to-expand
CompactTimelineView(items: items, heightMode:.fixed(hours:2)).timelineTransition(in: timelineNamespace).onTapGesture{withAnimation(.spring(duration:0.4, bounce:0.15)){
isExpanded =true}}
// Apply expanded overlay at root level
.overlay{if isExpanded {ExpandedTimelineContent(items: items){ headerView }.timelineTransition(in: timelineNamespace)}}

Access Restricted View

Show a blurred timeline with a permission prompt when calendar access hasn't been granted:

CompactTimelineView(items:[]).accessRestricted(!hasCalendarAccess){AccessPromptView.calendar(style:.compact){awaitrequestCalendarAccess()}}

Customize the prompt text:

AccessPromptView.calendar(
title:"Check for conflicts",
message:"See if this time works with your schedule",
buttonLabel:"Enable Calendar"){awaitrequestAccess()}

Or use ViewBuilders for full control over icon and button:

AccessPromptView(
title:"Connect Calendar",
message:"Show your events on the timeline",
icon:{Image(systemName:"calendar.badge.plus")},
buttonLabel:{Label("Allow Access", systemImage:"checkmark.circle")}){awaitrequestAccess()}

Screenshots

LightDark
Compact - Focused 2-3 hour windowCompact lightCompact dark
Day - Full schedule with hour gridDay lightDay dark
Overlapping - Events arranged side-by-sideOverlapping lightOverlapping dark
Many events - Handles busy schedules gracefullyMany lightMany dark
Access restricted - Blurred with permission promptRestricted lightRestricted dark

Requirements

  • iOS 26+
  • Swift 6.2+

License

MIT

About

SwiftUI package to display iOS Calendar.app like timelines with event previews (GitHub mirror of canonical Codeberg repo)

Topics

Resources

Stars

28 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages