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.
- Documentations
- Add tests
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"
)
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)
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 **/ }
)
Timeline is released under the MIT license. See LICENSE for details.
Created by Jan Timar.