Run Sourcery to generate your Exhibition: sourcery --sources Your/Source/Path --templates Exhibition.swifttemplate --output ./Sources/Generated
Show Exhibition() in a swift view
Custom Layout
If you would like your exhibit to have some custom layout, there is an optional function in ExhibitProvider you can implement.
Here is an example of embeding the exhibit within a List:
static func exhibitLayout(content: AnyView) -> some View {
List {
content
}
}
You can also provide a custom View here to provide presentation samples:
struct CustomLayout<Content: View>: View {
let content: Content
@State var isPresented: Bool = false
var body: some View {
Button("Open") {
isPresented = true
}
.sheet(isPresented: $isPresented) {
content
}
}
}
static func exhibitLayout(content: AnyView) -> some View {
CustomLayout(content: content)
}
Custom Parameter views
Exhibition supports a number of types in the parameter list of the debug menu.
You can add your own arbitrary types along with a view to modify the parameter, or override the views for existing types.
Conform to ParameterView, and pass the type in via the .parameterView modifier on Exhibition.
struct DoublingStringParameterView: ParameterView {
let key: String
@Binding var value: String
var body: some View {
Button(key) {
value += value
}
}
}
Exhibition()
.parameterView(DoublingStringParameterView.self)
Exhibition
Exhibition is a framework and generator for displaying and debugging a SwiftUI component library.
Inspired by Storybook and Showkase
Installation
Swift Package Manager
https://github.com/mjarvis/Exhibition
to your project via Xcode.Usage
ExhibitProvider
Sourcery
to generate your Exhibition:sourcery --sources Your/Source/Path --templates Exhibition.swifttemplate --output ./Sources/Generated
Exhibition()
in a swift viewCustom Layout
If you would like your exhibit to have some custom layout, there is an optional function in
ExhibitProvider
you can implement.Here is an example of embeding the exhibit within a
List
:You can also provide a custom
View
here to provide presentation samples:Custom Parameter views
Exhibition supports a number of types in the parameter list of the debug menu. You can add your own arbitrary types along with a view to modify the parameter, or override the views for existing types. Conform to
ParameterView
, and pass the type in via the.parameterView
modifier onExhibition
.