Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save husaynhakeem/0c12305486ca3cb84b89b3cc01725175 to your computer and use it in GitHub Desktop.
Save husaynhakeem/0c12305486ca3cb84b89b3cc01725175 to your computer and use it in GitHub Desktop.
class ActionWidget : GlanceAppWidget() {
@Composable
override fun Content() {
Button(
text = "Log on a click event",
onClick = actionRunCallback<LogActionCallback>(
parameters = actionParametersOf(
actionWidgetKey to "log event"
)
)
)
}
}
class LogActionCallback : ActionCallback {
override suspend fun onRun(
context: Context,
glanceId: GlanceId,
parameters: ActionParameters
) {
log("Item with id $glanceId and params $parameters clicked.")
}
}
val actionWidgetKey = ActionParameters.Key<String>("action-widget-key")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment