Skip to main content

shouldShowPanel

Notifies the client app that the panel should be displayed.

Overview

The SDK calls this method when the panel should be shown to the user. This can occur due to user interaction, SDK logic, or event triggers. Your app should respond by updating its UI to display the panel.

Syntax

abstract fun shouldShowPanel()

Example

class MyActivity : ComponentActivity(), MaestroEventDelegate {

private val _isPanelVisible = MutableStateFlow(false)

override fun shouldShowPanel() {
_isPanelVisible.value = true
}

override fun shouldHidePanel() {
_isPanelVisible.value = false
}
}

@Composable
fun MaestroScreen(sdk: MaestroSDK.Instance, isPanelVisible: StateFlow<Boolean>) {
val showPanel by isPanelVisible.collectAsState()
val viewModel = maestroEventViewModel(sdk)

Box(modifier = Modifier.fillMaxSize()) {
// Video player
VideoPlayer()

// Panel
if (showPanel) {
MaestroPanel(
maestroEventViewModel = viewModel,
modifier = Modifier.fillMaxSize(),
)

// Notify SDK that panel is visible
LaunchedEffect(Unit) {
viewModel.didShowPanel(MaestroPanelType.Chat)
}
}
}
}

Notes

  • Update your UI state to show the panel
  • Notify the SDK when the panel becomes visible using didShowPanel()
  • Handle cases where the panel is already showing
  • Consider animation or transition effects for better UX