Created
January 18, 2022 03:49
-
-
Save husaynhakeem/0c12305486ca3cb84b89b3cc01725175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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