WearWidgetPreview

Functions summary

Unit
@Composable
WearWidgetPreview(
    widget: GlanceWearWidget,
    params: WearWidgetParams,
    modifier: Modifier
)

Renders a preview of a GlanceWearWidget in Android Studio.

Unit
@Composable
WearWidgetPreview(
    params: WearWidgetParams,
    modifier: Modifier,
    background: WearWidgetBrush,
    content: @RemoteComposable @Composable () -> Unit
)

Renders a preview of a Wear Widget with the provided Remote Compose content.

Functions

@Composable
fun WearWidgetPreview(
    widget: GlanceWearWidget,
    params: WearWidgetParams,
    modifier: Modifier = Modifier
): Unit

Renders a preview of a GlanceWearWidget in Android Studio.

This utility facilitates rapid development by allowing developers to visualize how their Glance Wear widgets will appear on various device configurations without deploying to a physical device or emulator. It uses the provided WearWidgetParams to represent the widget's layout, including dimensions, padding, and container shape.

Parameters
widget: GlanceWearWidget

The GlanceWearWidget instance to be previewed.

params: WearWidgetParams

The WearWidgetParams to configure parameters (size, shape, padding) for the widget container.

modifier: Modifier = Modifier

The Modifier to be applied to the container box hosting the widget preview. Note that the preview's dimensions are enforced internally based on the provided params. Applying layout-modifying modifiers here might conflict with these internal specifications.

@Composable
fun WearWidgetPreview(
    params: WearWidgetParams,
    modifier: Modifier = Modifier,
    background: WearWidgetBrush = WearWidgetBrush.color(Color.Transparent.rc),
    content: @RemoteComposable @Composable () -> Unit
): Unit

Renders a preview of a Wear Widget with the provided Remote Compose content.

This utility facilitates rapid development by allowing developers to visualize how their Glance Wear widgets will appear on various device configurations without deploying to a physical device or emulator. It uses the provided WearWidgetParams to represent the widget's layout, including dimensions, padding, and container shape.

This overload allows to directly preview a Wear Widget by supplying the Remote Compose content and optional background. It is convenient for complex widgets that switch between multiple layouts based on application state, avoiding the mocking the entire widget or its dependencies.

Parameters
params: WearWidgetParams

The WearWidgetParams to configure parameters (size, shape, padding) for the widget container.

modifier: Modifier = Modifier

The Modifier to be applied to the container box hosting the widget preview.

background: WearWidgetBrush = WearWidgetBrush.color(Color.Transparent.rc)

The WearWidgetBrush to be used as the background of the widget. Defaults to a transparent solid color.

content: @RemoteComposable @Composable () -> Unit

The Composable content of the widget to be previewed.