SlideKit

SlideKit helps you make presentation slides on SwiftUI.

Set Up Project

  1. 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
  1. Open the generated Xcode project.
$ open SamplePresentations/SamplePresentations.xcodeproj
  1. Build and run the project. If an error like Couldn’t get revision ‘0.0.10^{commit}’: occurs, do File > Packages > Reset Package Caches on Xcode.

Usage

How to add your slide

  1. 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)
            }
        }
    }
}
  1. Preview your slide with SlidePreview.

struct SimpleSlide_Previews: PreviewProvider {
    static var previews: some View {
        SlidePreview {
            SimpleSlide()
        }
    }
}

SimpleSlidePreview

  1. Finally, add the slide to SlideIndexController in SamplePresentations.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

  1. Please add an enum SlidePhasedState in your slide.

struct SimpleSlide: Slide {

    enum SlidePhasedState: Int, PhasedState {
        case initial, second, third
    }

    @Phase var phasedStateStore
    // ...
}
  1. 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)
                    }
                }   
            }
        }
    }
}

GitHub

View Github