Skip to content

Instantly share code, notes, and snippets.

@marcelpinto
Last active August 26, 2022 09:13
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 marcelpinto/96708acff5f392d7a5405a70ae37a66c to your computer and use it in GitHub Desktop.
Save marcelpinto/96708acff5f392d7a5405a70ae37a66c to your computer and use it in GitHub Desktop.
/**
* Copyright 2022 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
@OptIn(ExperimentalGlanceRemoteViewsApi::class)
@Preview
@Composable
fun SampleGlanceWidgetPreview() {
// The size of the widget
val displaySize = DpSize(200.dp, 200.dp)
// Provide a state depending on the GlanceAppWidget state definition
val state = preferencesOf(SampleGlanceWidget.countKey to 2)
GlanceAppWidgetHostPreview(
modifier = Modifier.fillMaxSize(),
glanceAppWidget = SampleGlanceWidget, // The actual instance
state = state,
displaySize = displaySize,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment