also looking at this
feat(maps): add key-free native Android maps and shared map controls
#363
28 files
+1857
-481
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -562,6 +562,29 @@ final class NativeLayoutUnitTests: XCTestCase { | ||
| 562 | 562 | XCTAssertEqual(after.maxX, before.maxX, accuracy: 1, "absolute sibling changed horizontal position") |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | func testAbsoluteChildrenHonorSizeBoundsAndKeepTheirInsetAnchors() throws { | |
| 566 | let controller = screen(box("root", style: ["height": 240], [ | |
| 567 | ["id": "expand", "type": "Button", "props": ["testID": "expand", "title": "+"], | |
| 568 | "style": ["position": "absolute", "top": 12, "right": 12, "minWidth": 44, "minHeight": 44]], | |
| 569 | box("bounded", style: ["position": "absolute", "right": 12, "bottom": 12, "width": 300, "height": 120, "maxWidth": "50%", "maxHeight": 60]), | |
| 570 | text("wrapped", "An absolutely positioned label still wraps at its authored maximum width", style: ["position": "absolute", "left": 12, "top": 12, "maxWidth": 80, "fontSize": 17]), | |
| 571 | ])) | |
| 572 | settle(controller) | |
| 573 | let root = try frame("root", in: controller) | |
| 574 | let expand = try frame("expand", in: controller) | |
| 575 | XCTAssertGreaterThanOrEqual(expand.width, 44) | |
| 576 | XCTAssertEqual(expand.height, 44, accuracy: 0.5, "Floating buttons retain their minimum touch target") | |
| 577 | XCTAssertEqual(expand.maxX, root.maxX - 12, accuracy: 0.5) | |
| 578 | let bounded = try frame("bounded", in: controller) | |
| 579 | XCTAssertEqual(bounded.width, root.width / 2, accuracy: 0.5) | |
| 580 | XCTAssertEqual(bounded.height, 60, accuracy: 0.5) | |
| 581 | XCTAssertEqual(bounded.maxX, root.maxX - 12, accuracy: 0.5) | |
| 582 | XCTAssertEqual(bounded.maxY, root.maxY - 12, accuracy: 0.5) | |
| 583 | let wrapped = try frame("wrapped", in: controller) | |
| 584 | XCTAssertEqual(wrapped.width, 80, accuracy: 0.5) | |
| 585 | XCTAssertGreaterThan(wrapped.height, 44, "Width bounds participate in intrinsic text measurement") | |
| 586 | } | |
| 587 | ||
| 565 | 588 | func testAStyleUpdateIsAppliedInPlaceLayoutIncluded() throws { |
| 566 | 589 | let controller = screen(box("root", style: ["padding": 10], [ |
| 567 | 590 | box("grows", style: ["height": 24, "marginHorizontal": 48]), |
| @@ -2685,10 +2685,17 @@ private class CraftNativeFlowView: UIStackView { | ||
| 2685 | 2685 | ? max(0, content.height - (style.top ?? 0) - (style.bottom ?? 0)) |
| 2686 | 2686 | : style.height?.resolve(content.height) |
| 2687 | 2687 | (fixedWidth, fixedHeight) = aspectDimensions(style, width: fixedWidth, height: fixedHeight) |
| 2688 | let measured = CraftNativeFlexLayout.measure(child, width: fixedWidth, height: fixedHeight, maxWidth: content.width, maxHeight: content.height) | |
| 2689 | let x = style.left ?? (style.right.map { content.width - $0 - measured.width } ?? 0) | |
| 2690 | let y = style.top ?? (style.bottom.map { content.height - $0 - measured.height } ?? 0) | |
| 2691 | frames.append((child, CGRect(x: content.minX + x, y: content.minY + y, width: measured.width, height: measured.height))) | |
| 2688 | var measured = CraftNativeFlexLayout.measure(child, width: fixedWidth, height: fixedHeight, maxWidth: content.width, maxHeight: content.height) | |
| 2689 | let boundedWidth = clamp(measured.width, style.minWidth?.resolve(content.width), style.maxWidth?.resolve(content.width)) | |
| 2690 | if abs(boundedWidth - measured.width) > 0.0001 { | |
| 2691 | // A narrower label or container must wrap before its | |
| 2692 | // height and bottom anchor are resolved. | |
| 2693 | measured = CraftNativeFlexLayout.measure(child, width: boundedWidth, height: fixedHeight, maxWidth: content.width, maxHeight: content.height) | |
| 2694 | } | |
| 2695 | let boundedHeight = clamp(measured.height, style.minHeight?.resolve(content.height), style.maxHeight?.resolve(content.height)) | |
| 2696 | let x = style.left ?? (style.right.map { content.width - $0 - boundedWidth } ?? 0) | |
| 2697 | let y = style.top ?? (style.bottom.map { content.height - $0 - boundedHeight } ?? 0) | |
| 2698 | frames.append((child, CGRect(x: content.minX + x, y: content.minY + y, width: boundedWidth, height: boundedHeight))) | |
| 2692 | 2699 | } |
| 2693 | 2700 | } |
| 2694 | 2701 | return (size, frames) |