joshdholtz / DeckUI

Swift DSL for writing slide decks in Xcode
MIT License
601 stars 27 forks source link

Custom transitions per `Slide` #6

Closed yonomitt closed 1 year ago

yonomitt commented 1 year ago

A feature that might be useful would be to customize a transition on a per slide basis. The Presenter could still be the source for the default transition for the entire Deck, but each Slide could contain their own preferred SlideDirection (or in the future SlideTransition #5), which would override the default.

This could be accomplished by including a:

public struct Slide: Identifiable {
    ...
    let slideDirection: SlideDirection?
    ...
}

And then changing Presenter.nextSlide() to look something like:

private func nextSlide() {
    let slides = self.deck.slides()
    if self.index >= (slides.count - 1) {
        if self.loop {
            self.index = 0
        }
    } else {
        self.index += 1
    }

    let newSlide = slides[self.index]
    self.activeTransition = (newSlide.slideDirection self.slideDirection).next
}

Something similar could be done for Presenter.prevSlide()

yonomitt commented 1 year ago

I will see if I can get a PR for this soon