Skip to main content

MaestroOverlayEvent

Overview

MaestroOverlayEvent is a sealed interface that represents different types of overlay events that can be displayed in the Maestro SDK. Overlay events are notifications or interactive elements that appear on top of the main content, providing users with timely information or engagement opportunities.

Syntax

sealed interface MaestroOverlayEvent

Sealed Subclasses

BetWon

Represents an overlay event for a winning bet notification.

data class BetWon(
val betId: String,
val betType: String
) : MaestroOverlayEvent

Properties:

  • betId: String - Unique identifier for the winning bet
  • betType: String - Type or category of the bet that was won

Fantasy

Represents an overlay event for fantasy sports content.

data class Fantasy(
val payload: FantasyOverlayPayload
) : MaestroOverlayEvent

Properties:

  • payload: FantasyOverlayPayload - Detailed information about the fantasy overlay

Supporting Data Classes

FantasyOverlayPayload

Contains comprehensive information about a fantasy overlay event.

data class FantasyOverlayPayload(
val templateId: String,
val templateName: String?,
val templateMetadata: Map<String, String>,
val overlayId: String,
val overlayName: String,
val tags: List<String>,
val image: String?,
val title: String,
val metadata: String,
val headline: String,
val sportsType: String,
val description: String
)

Properties:

PropertyTypeDescription
templateIdStringUnique identifier for the overlay template
templateNameString?Optional name of the template
templateMetadataMap<String, String>Key-value pairs of template-specific metadata
overlayIdStringUnique identifier for this specific overlay instance
overlayNameStringName of the overlay
tagsList<String>List of tags associated with the overlay for categorization
imageString?Optional URL or path to an image for the overlay
titleStringMain title text to display
metadataStringAdditional metadata in string format
headlineStringHeadline text for the overlay
sportsTypeStringType of sport (e.g., "football", "basketball", "baseball")
descriptionStringDetailed description of the overlay content

Usage Examples

Handling Overlay Events

fun handleOverlayEvent(event: MaestroOverlayEvent) {
when (event) {
is MaestroOverlayEvent.BetWon -> {
showBetWonNotification(
betId = event.betId,
betType = event.betType
)
}
is MaestroOverlayEvent.Fantasy -> {
showFantasyOverlay(event.payload)
}
}
}

BetWon Event Handling

fun showBetWonNotification(betId: String, betType: String) {
val notification = createNotification(
title = "Congratulations!",
message = "Your $betType bet (ID: $betId) won!",
action = "View Details"
)
displayOverlay(notification)
}

// Example in delegate
override fun shouldShowOverlay(event: MaestroOverlayEvent): Boolean {
return when (event) {
is MaestroOverlayEvent.BetWon -> {
// Always show bet won notifications
true
}
is MaestroOverlayEvent.Fantasy -> {
// Check if user has fantasy enabled
userPreferences.isFantasyEnabled()
}
}
}

Fantasy Event Handling

fun showFantasyOverlay(payload: FantasyOverlayPayload) {
val overlay = FantasyOverlayView(context).apply {
setTitle(payload.title)
setHeadline(payload.headline)
setDescription(payload.description)
setSportsType(payload.sportsType)

payload.image?.let { imageUrl ->
loadImage(imageUrl)
}

setTags(payload.tags)
setMetadata(payload.templateMetadata)
}

showOverlay(overlay)
}

Advanced Fantasy Overlay Implementation

@Composable
fun FantasyOverlay(payload: FantasyOverlayPayload, onDismiss: () -> Unit) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Column(modifier = Modifier.padding(16.dp)) {
// Image
payload.image?.let { imageUrl ->
AsyncImage(
model = imageUrl,
contentDescription = payload.title,
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
)
}

// Title
Text(
text = payload.title,
style = MaterialTheme.typography.h5,
modifier = Modifier.padding(top = 8.dp)
)

// Headline
Text(
text = payload.headline,
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.primary,
modifier = Modifier.padding(top = 4.dp)
)

// Sports Type Badge
Chip(
text = payload.sportsType.uppercase(),
modifier = Modifier.padding(top = 8.dp)
)

// Description
Text(
text = payload.description,
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(top = 8.dp)
)

// Tags
FlowRow(modifier = Modifier.padding(top = 8.dp)) {
payload.tags.forEach { tag ->
TagChip(text = tag)
}
}

// Actions
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
horizontalArrangement = Arrangement.End
) {
TextButton(onClick = onDismiss) {
Text("Dismiss")
}
Button(
onClick = { openFantasyDetails(payload.overlayId) },
modifier = Modifier.padding(start = 8.dp)
) {
Text("Learn More")
}
}
}
}
}

Event Filtering by Tags

override fun shouldShowOverlay(event: MaestroOverlayEvent): Boolean {
return when (event) {
is MaestroOverlayEvent.Fantasy -> {
val payload = event.payload
// Show only if user is interested in this sport type
val interestedSports = userPreferences.getInterestedSports()
payload.sportsType in interestedSports &&
// And if any of the tags match user interests
payload.tags.any { it in userPreferences.getInterestedTags() }
}
is MaestroOverlayEvent.BetWon -> true
}
}

Template-Based Rendering

fun renderOverlay(event: MaestroOverlayEvent.Fantasy) {
val templateRenderer = when (event.payload.templateId) {
"template-1" -> StandardFantasyRenderer()
"template-2" -> CompactFantasyRenderer()
"template-3" -> ExpandedFantasyRenderer()
else -> DefaultFantasyRenderer()
}

templateRenderer.render(event.payload)
}

Common Use Cases

Sports Betting Integration

  • Display notifications when user bets are won
  • Show bet results with relevant details
  • Track bet types and outcomes

Fantasy Sports

  • Display fantasy team updates
  • Show player performance overlays
  • Promote fantasy contests and leagues
  • Provide sport-specific fantasy content

Event Tracking

override fun shouldShowOverlay(event: MaestroOverlayEvent): Boolean {
// Track overlay events for analytics
analytics.trackEvent("overlay_triggered", mapOf(
"type" to when (event) {
is MaestroOverlayEvent.BetWon -> "bet_won"
is MaestroOverlayEvent.Fantasy -> "fantasy"
}
))

return true // Or implement custom logic
}

Notes

  • The SDK determines when to show overlays based on configured triggers and events
  • Applications control whether to display overlays via the shouldShowOverlay() delegate method
  • Overlay events are time-sensitive and should be handled promptly
  • Consider user preferences and context when deciding to show overlays
  • Template metadata allows for flexible overlay customization

See Also