Skip to content

Commit

Permalink
Closes #451: Fix cut off items in scrolling horizontal/vertical list …
Browse files Browse the repository at this point in the history
…widgets

Don't call frameRender() for list widgets since that clips children and any decorative elements to the widget should be applied to the parent.
  • Loading branch information
rylin8 committed Oct 12, 2023
1 parent aa43277 commit a6f5874
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ internal fun DesignFrame(
}
}

// Only render the frame if we don't have a replacement node
// Only render the frame if we don't have a replacement node and layout is absolute
val shape = (view.data as ViewData.Container).shape
if (replacementComponent == null)
if (replacementComponent == null && layoutInfo.shouldRender())
m = m.frameRender(style, shape, customImage, document, name, customizations, maskInfo)

val lazyContent = customizations.getListContent(name)
Expand Down
12 changes: 8 additions & 4 deletions designcompose/src/main/java/com/android/designcompose/Layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasurePolicy
import androidx.compose.ui.layout.ParentDataModifier
import androidx.compose.ui.layout.Placeable
Expand Down Expand Up @@ -376,7 +375,14 @@ internal fun ParentLayoutInfo.withBaseView(baseView: View?): ParentLayoutInfo {
internal val rootParentLayoutInfo = ParentLayoutInfo()
val widgetParent = ParentLayoutInfo(isWidgetChild = true)

internal open class SimplifiedLayoutInfo(val selfModifier: Modifier)
internal open class SimplifiedLayoutInfo(val selfModifier: Modifier) {
internal fun shouldRender(): Boolean {
// We only want to render if the layout is an absolute layout, meaning we are using our
// custom Rust layout implementation. All other layout types mean we are using the list
// widget, and any special visual styles applied in Figma should be on the widget's parent.
return this is LayoutInfoAbsolute
}
}

internal class LayoutInfoAbsolute(selfModifier: Modifier) : SimplifiedLayoutInfo(selfModifier)

Expand Down Expand Up @@ -570,8 +576,6 @@ internal class DesignLayoutData(val name: String, val layoutId: Int) : ParentDat
}
}

internal val Measurable.designLayoutData: DesignLayoutData?
get() = parentData as? DesignLayoutData
internal val Placeable.designLayoutData: DesignLayoutData?
get() = parentData as? DesignLayoutData

Expand Down

0 comments on commit a6f5874

Please sign in to comment.