Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/api-migrations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# LUI API migration guide

### Apple row intrinsic text priority

Non-growing `text`, `heading`, and `paragraph` children in Apple rows now
retain intrinsic width ahead of growing siblings, without requiring
`single-line`. For example, `row [button ~grow:1.0 ~text:"Tab" [];
text ~value:"✓" []]` keeps its trailing glyph visible. No wire or caller
changes are required. Flexible containers keep their existing priority;
growing text still shares the growing-child priority. Explicit `single-line`
priority is unchanged. Android and web layout are unchanged.

### Foreground accent ink compatibility

`primary` and `accent` in a foreground slot retain their accent ink color;
Expand Down
10 changes: 6 additions & 4 deletions platform/apple/Sources/LUIAppleBackend/LUISwiftUIRoot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6441,13 +6441,14 @@ enum LUIRowLayoutPolicy {
}

static func childLayoutPriority(
kind: LUINodeKind? = nil,
grow: Double?,
styleClass: String?
) -> Double {
// Grow children take remaining width before non-growing flexible
// containers (including empty rows/columns). Explicit single-line
// content keeps its higher intrinsic priority; all growers stay equal.
max((grow ?? 0) > 0 ? 0.5 : 0,
// Intrinsic text precedes growers; flexible containers remain last.
let growing = (grow ?? 0) > 0
let intrinsicText = kind == .text || kind == .heading || kind == .paragraph
return max(growing ? 0.5 : (intrinsicText ? 1 : 0),
LUITextLinePolicy.layoutPriority(styleClass: styleClass))
}

Expand Down Expand Up @@ -6530,6 +6531,7 @@ private struct LUIRowView: View {
maxHeight: cross == "stretch" ? .infinity : nil
)
.layoutPriority(LUIRowLayoutPolicy.childLayoutPriority(
kind: child?.kind,
grow: child?.grow,
styleClass: child?.styleClass
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,20 @@ struct LUISwiftUIBackendTests {

@Test("growing Row children preserve intrinsic trailing controls")
func growingRowChildrenPreserveTrailingControls() {
let growingButton = LUIRowLayoutPolicy.childLayoutPriority(
kind: .button, grow: 1, styleClass: nil)
for kind in [LUINodeKind.text, .heading, .paragraph] {
#expect(LUIRowLayoutPolicy.childLayoutPriority(
kind: kind, grow: nil, styleClass: nil) > growingButton)
#expect(LUIRowLayoutPolicy.childLayoutPriority(
kind: kind, grow: 0, styleClass: "secondary") > growingButton)
#expect(LUIRowLayoutPolicy.childLayoutPriority(
kind: kind, grow: 1, styleClass: nil) == growingButton)
}
Comment on lines +1716 to +1725

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Rendered glyph width remains untested

growingRowChildrenPreserveTrailingControls checks priority numbers without rendering a row. These assertions pass even if nonWrappingRowContent stops forwarding the child's kind. A hosted, constrained-width row test can verify that the trailing glyph retains nonzero width.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

for kind in [LUINodeKind.row, .column, .spacer] {
#expect(LUIRowLayoutPolicy.childLayoutPriority(
kind: kind, grow: nil, styleClass: nil) == 0)
}
#expect(LUIRowLayoutPolicy.childLayoutPriority(
grow: nil,
styleClass: nil
Expand Down
Loading