Skip to main content

MaestroOverlay

MaestroKit provides a suite of SwiftUI components that make integrating rich UI elements seamless. In this chapter, we’ll walk through how to instantiate and use the MaestroOverlay component.

MaestroOverlay is a struct that provides an overlay view for you to add to your app's view heirarchy. The overlay should be presented either in a .overlay view modifier, or in a ZStack above your other views.

The order of events in using the MaestroOverlay goes like this:

  • The SDK determines that a MaestroOverlay needs to be shown
  • The SDK calls shouldShowOverlay(buttonSize:overlayType:payload:) in the MaestroEventDelegate to tell your app to display an overlay with the given buttonSize.
  • Your app instances MaestroOverlay(buttonPosition:overlayType:payload:) with a buttonPosition that indicates the position at which the overlay should be disaplayed. Your app should determine the best place for the overlay given the buttonSize provided in the shouldShowOverlay() call. The overlayType and payload parameters should be the values you received from the SDK in the shouldShowOverlay(buttonSize:overlayType:payload) call.
  • If the user takes no action, or clicks the button, the overlay will call shouldHideOverlay() in your app's MaestroEventDelegate implementation to let you know the overlay should be dismissed.
  • Your app should call didShowOverlay() and didHideOverlay() when those events occur, to keep the SDK apprised of your current use of the MaestroOverlay.
struct MaestroOverlay: View

Parameters

  • buttonPosition: CGPoint - An optional CGFloat defining the width of the Overlay.
  • overlayType: OverlayType - The type of overlay to be shown.
  • payload: MaestroOverlayEvent - The optional payload for the overlay.

Sample Usage

struct ContentView: View {
var body: some View {
MaestroOverlay(
buttonPosition: CGPoint(x: 1100, y: 100),
overlayType: .fantasy,
payload: nil
)
}
}