-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tile Preview unable to render ProgressIndicatorLayout #236
Comments
The issue is the usage of Would we need to have two separate Previews, e.g. a @Composable
private fun LayoutRootPreview(rootLayout: LayoutElementBuilders.LayoutElement) {
val tile =
TileBuilders.Tile.Builder()
.setResourcesVersion("1")
.setTimeline(
TimelineBuilders.Timeline.Builder().addTimelineEntry(
TimelineBuilders.TimelineEntry.Builder().setLayout(
LayoutElementBuilders.Layout.Builder().setRoot(
rootLayout
).build()
).build()
).build()
).build()
val tileResources = ResourceBuilders.Resources.Builder()
.build()
TilePreview(tile, tileResources)
} |
How's this? @Composable
private fun LayoutElementPreview(
element: LayoutElement,
@ColorInt windowBackgroundColor: Int = android.graphics.Color.BLACK,
tileResourcesFn: ResourceBuilders.Resources.Builder.() -> Unit = {}
) {
val root = LayoutElementBuilders.Box.Builder()
.setModifiers(
ModifiersBuilders.Modifiers.Builder().setBackground(
ModifiersBuilders.Background.Builder()
.setColor(ColorBuilders.argb(windowBackgroundColor))
.build()
).build()
)
.setHorizontalAlignment(LayoutElementBuilders.HORIZONTAL_ALIGN_CENTER)
.setVerticalAlignment(LayoutElementBuilders.VERTICAL_ALIGN_CENTER)
.setHeight(DimensionBuilders.ExpandedDimensionProp.Builder().build())
.setWidth(DimensionBuilders.ExpandedDimensionProp.Builder().build())
.addContent(element)
.build()
LayoutRootPreview(root = root, tileResourcesFn)
}
@Composable
private fun LayoutRootPreview(
root: LayoutElement,
tileResourcesFn: ResourceBuilders.Resources.Builder.() -> Unit = {}
) {
val tile = TileBuilders.Tile.Builder()
.setResourcesVersion("1")
.setTimeline(singleEntryTimeline(root))
.build()
val tileResources = ResourceBuilders.Resources.Builder()
.apply(tileResourcesFn)
.build()
TilePreview(tile, tileResources)
} |
@ataulm Do I leave the PR to you, no rush from my side. And good to know that the approach works with all component types. |
Addressed in #240 |
The other previews are fine:
The code for the layout:
Horologist: 0.0.23
Tiles Material Components: https://androidx.dev/snapshots/builds/8730571/artifacts
The text was updated successfully, but these errors were encountered: