Skip to content

Transition Plugin

The TransitionPlugin allows for specifying transitions for when Player loads a flow, and for transition between views in the same flow.

CocoaPods

Add the subspec to your Podfile.

pod 'PlayerUI/TransitionPlugin'

In your Swift file, import the pod. Only one import is needed for all PlayerUI pods.

import PlayerUI

Swift Package Manager

Add the product to the appropriate target's dependencies in your Package.swift.

.target(
name: "MyApp",
dependencies: [
.product(name: "PlayerUITransitionPlugin", package: "playerui-swift-package"),
]
)

In your Swift file, import the sub-package. A different import is needed for each PlayerUI sub-package.

import PlayerUITransitionPlugin
SwiftUIPlayer(flow: flowString, plugins: [TransitionPlugin(popTransition: .pop)], result: $resultBinding)

To specify different transition, just supply a PlayerViewTransition to the plugin initializer:

let customTransition = PlayerViewTransition(
transition: AnyTransition.opacity,
animationCurve: Animation.linear
)
let plugin = TransitionPlugin(
stateTransition: customTransition,
pushTransition: customTransition,
popTransition: customTransition
)

By default there are 5 transitions included with the SwiftUIPlayer:

/// Transition that slides views in from the trailing edge and out from to the leading edge of the screen
PlayerViewTransition.slideInSlideOut
/// Transition that slides views in from the trailing edge and fades out views on removal
PlayerViewTransition.slideInFadeOut
/// Transition that fades views in and slides out to the leading edge of the screen on removal
PlayerViewTransition.fadeInSlideOut
/// Transition that slides views in from the trailing edge and out from to the leading edge of the screen
PlayerViewTransition.push
/// Transition that slides views in from the leading edge and out from to the trailing edge of the screen
PlayerViewTransition.pop