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(id:buttonSize:) in the MaestroEventDelegate to tell your app to display an overlay with the given id, and the buttonSize of the button it will contain.
  • Your app instances MaestroOverlay(id:buttonPosition:) with the same id you received in the shouldShowOverlay() call, and a buttonPosition that will allow the overlay's button to be properly displayed, given the buttonSize provided in the shouldShowOverlay() 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 needs to be hidden.
  • Your app should call didShowOverlay() and didHideOverlay() when those events occur, to keep the SDK up-to-date.
struct MaestroOverlay: View

Parameters

  • id: String - A required string attained from the shouldShowOverlay() delegate call's id parameter.
  • buttonPosition: CGPoint - An optional CGFloat defining the width of the Overlay.

Sample Usage

struct ContentView: View {
var body: some View {
MaestroOverlay(
id: "content-id-recieved-in-delegate-call",
buttonPosition: CGPoint(x: 1100, y: 100)
)
}
}