Skip to content

Commit

Permalink
Fix item spacing of list replacement content in squoosh (#1686)
Browse files Browse the repository at this point in the history
Fixes #1541. Set the default flex_grow value to 0 for list replacement
items. This prevents the items in the list from stretching to fit the
container they are in.

This change puts several of the validation tests previously in the
DEFAULT_RENDERER_ONLY category into the BOTH category. Squoosh is now
able to render these examples correctly, with some (CrossAxis Fill)
being more correct than the non-squoosh version.
  • Loading branch information
rylin8 authored Sep 28, 2024
1 parent 17e7bf7 commit 5b1b4a1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ internal fun defaultLayoutStyle(): LayoutStyle.Builder {
builder.margin = newDimensionRectPointsZero()
builder.padding = newDimensionRectPointsZero()
builder.item_spacing = ItemSpacing.Auto(0, 0)
builder.flex_grow = 1.0f
builder.flex_grow = 0.0f
builder.flex_shrink = 0.0f
builder.flex_basis = newDimensionProtoUndefined()
builder.bounding_box = com.android.designcompose.serdegen.Size(0f, 0f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ val EXAMPLES: ArrayList<Triple<String, @Composable () -> Unit, String?>> =
Triple("V Constraints", { VConstraintsTest() }, ConstraintsDoc.javaClass.name),
Triple("Image Update", { ImageUpdateTest() }, ImageUpdateTestDoc.javaClass.name),
Triple("Interaction", { InteractionTest() }, InteractionTestDoc.javaClass.name),
// Layout related tests
Triple("CrossAxis Fill", { CrossAxisFillTest() }, CrossAxisFillTestDoc.javaClass.name),
Triple("Item Spacing", { ItemSpacingTest() }, ItemSpacingTestDoc.javaClass.name),
Triple(
"Layout Replacement",
{ LayoutReplacementTest() },
LayoutReplacementTestDoc.javaClass.name
),
Triple(
"Recurse Customization",
{ RecursiveCustomizations() },
RecursiveCustomizationsDoc.javaClass.name
),
Triple("Layout Tests", { LayoutTests() }, LayoutTestsDoc.javaClass.name),
// Masks/shadows
Triple("Masks", { MaskTest() }, MaskTestDoc.javaClass.name),
Triple("Shadows", { ShadowsTest() }, ShadowsTestDoc.javaClass.name),
// Text validations
Expand All @@ -60,7 +75,13 @@ val EXAMPLES: ArrayList<Triple<String, @Composable () -> Unit, String?>> =
StateCustomizationsDoc.javaClass.name
),
Triple("Telltales", { TelltaleTest() }, TelltaleTestDoc.javaClass.name),
// Variant tests
Triple("Variant *", { VariantAsteriskTest() }, VariantAsteriskTestDoc.javaClass.name),
Triple(
"Variant Interactions",
{ VariantInteractionsTest() },
VariantInteractionsTestDoc.javaClass.name
),
Triple(
"Variant Properties",
{ VariantPropertiesTest() },
Expand Down Expand Up @@ -104,33 +125,15 @@ val DEFAULT_RENDERER_ONLY_EXAMPLES: ArrayList<Triple<String, @Composable () -> U
Triple("Color Tint", { ColorTintTest() }, ColorTintTestDoc.javaClass.name),
// No support for hyperlinks.
Triple("Hyperlink", { HyperlinkTest() }, HyperlinkValidationDoc.javaClass.name),

// Lazy Grid doesn't actually use a doc
// This example is not using any of the renderers.
Triple("Lazy Grid", { LazyGridItemSpans() }, null),
// Squoosh doesn't work with ListContent
Triple("Grid Layout", { GridLayoutTest() }, GridLayoutTestDoc.javaClass.name),
Triple("Grid Widget", { GridWidgetTest() }, GridWidgetTestDoc.javaClass.name),
Triple("List Widget", { ListWidgetTest() }, ListWidgetTestDoc.javaClass.name),
// Squoosh doesn't work with ReplacementContent
Triple("CrossAxis Fill", { CrossAxisFillTest() }, CrossAxisFillTestDoc.javaClass.name),
Triple("Item Spacing", { ItemSpacingTest() }, ItemSpacingTestDoc.javaClass.name),
Triple("Layout Tests", { LayoutTests() }, LayoutTestsDoc.javaClass.name),
Triple(
"Layout Replacement",
{ LayoutReplacementTest() },
LayoutReplacementTestDoc.javaClass.name
),
// Squoosh doesn't support OpenLink
Triple("OpenLink", { OpenLinkTest() }, OpenLinkTestDoc.javaClass.name),
Triple(
"Recurse Customization",
{ RecursiveCustomizations() },
RecursiveCustomizationsDoc.javaClass.name
),
// Squoosh has some problems with this example
Triple("Shared Customization", { ModuleExample() }, ModuleExampleDoc.javaClass.name),
Triple(
"Variant Interactions",
{ VariantInteractionsTest() },
VariantInteractionsTestDoc.javaClass.name
),
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b1b4a1

Please sign in to comment.