Skip to content

Add ZStack and lift the view builder child limit#10

Merged
colemancda merged 5 commits into
feature/modifiersfrom
feature/zstack
Jul 22, 2026
Merged

Add ZStack and lift the view builder child limit#10
colemancda merged 5 commits into
feature/modifiersfrom
feature/zstack

Conversation

@colemancda

Copy link
Copy Markdown
Member

Stacked on top of #9 — review that first; this PR targets feature/modifiers and will retarget to master once #9 merges.

ZStack

ZStack had no Android renderer. It now renders as a FrameLayout, overlaying children in declaration order.

Alignment needs a little indirection: FrameLayout positions children through their own layout parameters rather than a container-wide gravity, and the renderer only has the parent's native view to work from when it mounts a child. The stack's gravity is therefore retained as the container's coordinator and read back when assigning each child's parameters. Only containers carrying a retained gravity get this treatment, so the frame layouts used for sheets and fragment hosting are untouched.

Children hug their content rather than filling the container, which is what gives the alignment room to act.

View builder child limit

@ViewBuilder was capped at ten children by a fixed set of arity-specific buildBlock overloads. Parameter packs replace all of them with one variadic overload, and TupleView's ten arity-specific initializers likewise collapse into a single variadic one. The empty and single-child buildBlock overloads stay as they are, so a lone child still passes through unwrapped.

The stacks gallery screen now declares thirteen children in one VStack, which previously did not compile.

Verification

On the emulator:

  • ZStack renders correctly at .center, .topLeading, and .bottomTrailing.
  • The thirteen-child stacks screen compiles and renders identically to the grouped version it replaced.
  • Spot-checked Text, Navigation, Sheets, and List for regressions from the view builder change — all render and behave as before.

Replaces the arity-specific initializers with a single variadic one.
Parameter packs replace the fixed set of arity-specific buildBlock overloads,
so a view builder now accepts any number of children.
Children overlay one another in declaration order, positioned by the stack's
alignment. The alignment is retained as the container's coordinator so the
renderer can apply it to each child's layout parameters.
@colemancda
colemancda merged commit 1077807 into feature/modifiers Jul 22, 2026
6 checks passed
@colemancda
colemancda deleted the feature/zstack branch July 22, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant