Skip to content

Add ZStack and lift the view builder child limit - #11

Merged
colemancda merged 5 commits into
masterfrom
feature/zstack-rebase
Jul 22, 2026
Merged

colemancda merged 5 commits into
masterfrom
feature/zstack-rebase

Conversation

@colemancda

Copy link
Copy Markdown
Member

Re-lands the commits from #10, which never reached master.

#10 was based on feature/modifiers and merged five minutes after that branch had already gone to master via #9, so its commits landed in feature/modifiers and stopped there. AndroidFrameLayout.swift and the view builder change are both absent from master. These are the same five commits, cherry-picked onto master cleanly with no conflicts.

Original description follows.

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 (from the original branch):

  • 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.

Re-verified swift build after the cherry-pick onto master.

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 7e78402 into master Jul 22, 2026
6 checks passed
@colemancda
colemancda deleted the feature/zstack-rebase branch July 22, 2026 13:27
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