Skip to content

jantimar/Timeline

Repository files navigation

Timeline

SPM Compatible Platforms: iOS Platform: tvOS Platform: macOS

MVP concept in SwiftUI for show items in timeline (columns and rows), can be useful for show Time flow, TV program or explain Ant-Man Quantumania.

TODO list

  • Documentations
  • Add tests

Installation

As a Swift Package

Timeline is distributed via SPM. You can use it as a framework in your iOS project. In your Package.swift add a new package dependency:

.package(
    url: "https://github.com/jantimar/Timeline",
    from: "0.1.0"
)

Usage

Import package with import Timeline to enable initialize a view.

Prepare your data to implement TimelineItem and Identifiable protocols in 2 dimensions array [[TimelineItem]]

Initialize aTimelineViewModel with items. You can setup a TimelineScale or used a default a day scale.

let viewModel = TimelineViewModel(items: items) 

When your data is ready you can finally intialize a TimelineView with your model. With a default init with TimelineItemView like a item view and without a grid or with a TimelineGridView

TimelineView(viewModel: viewModel)

default

Or customize with init:

TimelineView(
    item: { item -> ItemView in /** initialize your custome item view **/ },
    grid: { start, end, width -> GridView? in /** initialize your custome grid view **/ }
)

License and Credits

Timeline is released under the MIT license. See LICENSE for details.

Created by Jan Timar.

About

Timeline view in SwiftUI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages