A component library for SwiftUI views.
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding ComponentsBook as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.Package(url: "https://github.com/mosaic6/ComponentsBook.git", majorVersion: 1)
]
- Add a new application target to your existing application
- Link
ComponentsBook
toFrameworks, Libraries, and Embedded Content
in your new target
- Import
ComponentsBook
inContentView
import ComponentsBook
- Add an array of your SwiftUI views as an array of
Chapter
types
let chapters: [Chapter] = [
/// Group Button controls here
Chapter(type: .controls, pages: [
Page(subType: .controlType(.buttons), title: "Example Button", description: nil, view: AnyView(ExampleButton()))
]),
/// Group Page views here
Chapter(type: .views, pages: [
Page(subType: .viewType(.actionSheets), title: "Empty View", description: nil, view: AnyView(CustomActionSheet()))
])
]
- Update the
body
property withComponentsBook(dataModel: DataModel(chapters: chapters))
var body: some View {
ComponentsBook(dataModel: DataModel(chapters: chapters))
}
Build and run and have fun!