SlideKit
SlideKit helps you make presentation slides on SwiftUI.
Set Up Project
- Please make a Xcode project by Mint. (SlideGen is a command line tool which generates a template project for SlideKit.)
$ mint run mtj0928/SlideGen SamplePresentations -p macOS
- Open the generated Xcode project.
$ open SamplePresentations/SamplePresentations.xcodeproj
- Build and run the project.
If an error like
Couldn’t get revision ‘0.0.10^{commit}’:
occurs, doFile > Packages > Reset Package Caches
on Xcode.
Usage
How to add your slide
- Define a new slide like this.
import SlideKit
import SwiftUI
struct SimpleSlide: Slide {
var body: some View {
HeaderSlide("This is Simple Slide") {
Item("You can use Item!!")
Item("Nested item is supported.") {
Item("Enumerated item is also supported.", accessory: 1)
Item("2nd Item.", accessory: 2)
}
}
}
}
- Preview your slide with
SlidePreview
.
struct SimpleSlide_Previews: PreviewProvider {
static var previews: some View {
SlidePreview {
SimpleSlide()
}
}
}
- Finally, add the slide to
SlideIndexController
inSamplePresentations.swift
. Run the project and you can see SimpleSlide!!
/// Please add your slides into the trailing closure
let slideIndexController = SlideIndexController {
SampleSlide()
+ SimpleSlide()
}
How to use PhasedState
- Please add an enum
SlidePhasedState
in your slide.
struct SimpleSlide: Slide {
enum SlidePhasedState: Int, PhasedState {
case initial, second, third
}
@Phase var phasedStateStore
// ...
}
- The
SlidePhasedState
represents sub-steps on one slide, and you can switch the layout based on the current phase.
struct SimpleSlide: Slide {
// ...
var body: some View {
HeaderSlide("This is Simple Slide") {
Item("You can use Item!!")
if phasedStateStore.after(.second) {
Item("Nested item is supported.") {
Item("Enumerated item is also supported.", accessory: 1)
if phasedStateStore.after(.third) {
Item("2nd Item.", accessory: 2)
}
}
}
}
}
}