From 1bfa9086e0d1240ff8be301542d27c3aac2511d3 Mon Sep 17 00:00:00 2001 From: GenericJam Date: Sun, 30 Aug 2026 00:45:44 -0600 Subject: [PATCH] fix(ios): honor fixed-height boxes Bead: clarity-590 --- ios/MobRootView.swift | 4 ++++ test/mob/native_box_layout_test.exs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/mob/native_box_layout_test.exs diff --git a/ios/MobRootView.swift b/ios/MobRootView.swift index 32397c48..ad0c147a 100644 --- a/ios/MobRootView.swift +++ b/ios/MobRootView.swift @@ -767,6 +767,10 @@ private struct MobBox: View { height: node.fixedHeight > 0 ? CGFloat(node.fixedHeight) : nil, alignment: alignment ) + } else if node.fixedHeight > 0 { + stack + .frame(height: CGFloat(node.fixedHeight), alignment: alignment) + .frame(maxWidth: .infinity, alignment: alignment) } else if node.fillHeight { // fill_height: true is what lets a wrapping box stretch to the // viewport so center alignment lands on the visible midpoint diff --git a/test/mob/native_box_layout_test.exs b/test/mob/native_box_layout_test.exs new file mode 100644 index 00000000..5d04a5fe --- /dev/null +++ b/test/mob/native_box_layout_test.exs @@ -0,0 +1,19 @@ +# These source-contract tests guard native SwiftUI behavior that Elixir cannot execute. +# credo:disable-for-this-file Jump.CredoChecks.VacuousTest +defmodule Mob.NativeBoxLayoutTest do + use ExUnit.Case, async: true + + @root Path.expand("../..", __DIR__) + + test "iOS box applies a fixed height without a fixed width" do + source = File.read!(Path.join(@root, "ios/MobRootView.swift")) + + assert source =~ + " } else if node.fixedHeight > 0 {\n" <> + " stack\n" <> + " .frame(height: CGFloat(node.fixedHeight), " <> + "alignment: alignment)\n" <> + " .frame(maxWidth: .infinity, alignment: alignment)\n" <> + " } else if node.fillHeight {\n" + end +end