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 theMaestroEventDelegate
to tell your app to display an overlay with the givenid
, and thebuttonSize
of the button it will contain. - Your app instances
MaestroOverlay(id:buttonPosition:)
with the sameid
you received in theshouldShowOverlay()
call, and abuttonPosition
that will allow the overlay's button to be properly displayed, given thebuttonSize
provided in theshouldShowOverlay()
call. - If the user takes no action, or clicks the button, the overlay will call
shouldHideOverlay()
in your app'sMaestroEventDelegate
implementation to let you know the overlay needs to be hidden. - Your app should call
didShowOverlay()
anddidHideOverlay()
when those events occur, to keep the SDK up-to-date.
struct MaestroOverlay: View
Parameters
id: String
- A required string attained from theshouldShowOverlay()
delegate call'sid
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)
)
}
}