Skip to content

mosaic6/ComponentsBook

Repository files navigation

ComponentsBook

A component library for SwiftUI views.

Installation

Swift Package Manager

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)
]

Usage

  • Add a new application target to your existing application

Screen Shot 2021-10-15 at 3 49 37 PM

  • Link ComponentsBook to Frameworks, Libraries, and Embedded Content in your new target

Screen Shot 2021-10-15 at 3 51 33 PM

  • Import ComponentsBook in ContentView
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 with ComponentsBook(dataModel: DataModel(chapters: chapters))
var body: some View {
    ComponentsBook(dataModel: DataModel(chapters: chapters))
}

Build and run and have fun!

About

A place for all your SwiftUI views ๐Ÿ˜‰

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages