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