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.
| @@ -567,6 +567,8 @@ final class NativeLayoutUnitTests: XCTestCase { | ||
| 567 | 567 | ["id": "expand", "type": "Button", "props": ["testID": "expand", "title": "+"], |
| 568 | 568 | "style": ["position": "absolute", "top": 12, "right": 12, "minWidth": 44, "minHeight": 44]], |
| 569 | 569 | box("bounded", style: ["position": "absolute", "right": 12, "bottom": 12, "width": 300, "height": 120, "maxWidth": "50%", "maxHeight": 60]), |
| 570 | box("wide-ratio", style: ["position": "absolute", "left": 0, "top": 0, "width": 300, "aspectRatio": 2, "maxWidth": 100]), | |
| 571 | box("tall-ratio", style: ["position": "absolute", "left": 110, "top": 0, "height": 120, "aspectRatio": 2, "maxHeight": 60]), | |
| 570 | 572 | 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 | 573 | ])) |
| 572 | 574 | settle(controller) |
| @@ -580,6 +582,12 @@ final class NativeLayoutUnitTests: XCTestCase { | ||
| 580 | 582 | XCTAssertEqual(bounded.height, 60, accuracy: 0.5) |
| 581 | 583 | XCTAssertEqual(bounded.maxX, root.maxX - 12, accuracy: 0.5) |
| 582 | 584 | XCTAssertEqual(bounded.maxY, root.maxY - 12, accuracy: 0.5) |
| 585 | let wideRatio = try frame("wide-ratio", in: controller) | |
| 586 | XCTAssertEqual(wideRatio.width, 100, accuracy: 0.5) | |
| 587 | XCTAssertEqual(wideRatio.height, 50, accuracy: 0.5, "An automatic height follows the constrained width") | |
| 588 | let tallRatio = try frame("tall-ratio", in: controller) | |
| 589 | XCTAssertEqual(tallRatio.width, 120, accuracy: 0.5, "An automatic width follows the constrained height") | |
| 590 | XCTAssertEqual(tallRatio.height, 60, accuracy: 0.5) | |
| 583 | 591 | let wrapped = try frame("wrapped", in: controller) |
| 584 | 592 | XCTAssertEqual(wrapped.width, 80, accuracy: 0.5) |
| 585 | 593 | XCTAssertGreaterThan(wrapped.height, 44, "Width bounds participate in intrinsic text measurement") |
| @@ -2684,15 +2684,21 @@ private class CraftNativeFlowView: UIStackView { | ||
| 2684 | 2684 | var fixedHeight = style.top != nil && style.bottom != nil |
| 2685 | 2685 | ? max(0, content.height - (style.top ?? 0) - (style.bottom ?? 0)) |
| 2686 | 2686 | : style.height?.resolve(content.height) |
| 2687 | let authoredWidth = fixedWidth != nil | |
| 2688 | let authoredHeight = fixedHeight != nil | |
| 2687 | 2689 | (fixedWidth, fixedHeight) = aspectDimensions(style, width: fixedWidth, height: fixedHeight) |
| 2688 | 2690 | 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 | var boundedWidth = clamp(measured.width, style.minWidth?.resolve(content.width), style.maxWidth?.resolve(content.width)) | |
| 2692 | let proposedHeight = !authoredHeight && style.aspectRatio != nil ? boundedWidth / style.aspectRatio! : fixedHeight | |
| 2693 | if abs(boundedWidth - measured.width) > 0.0001 || proposedHeight != fixedHeight { | |
| 2691 | 2694 | // A narrower label or container must wrap before its |
| 2692 | 2695 | // height and bottom anchor are resolved. |
| 2693 | measured = CraftNativeFlexLayout.measure(child, width: boundedWidth, height: fixedHeight, maxWidth: content.width, maxHeight: content.height) | |
| 2696 | measured = CraftNativeFlexLayout.measure(child, width: boundedWidth, height: proposedHeight, maxWidth: content.width, maxHeight: content.height) | |
| 2694 | 2697 | } |
| 2695 | 2698 | let boundedHeight = clamp(measured.height, style.minHeight?.resolve(content.height), style.maxHeight?.resolve(content.height)) |
| 2699 | if !authoredWidth, authoredHeight, let ratio = style.aspectRatio { | |
| 2700 | boundedWidth = clamp(boundedHeight * ratio, style.minWidth?.resolve(content.width), style.maxWidth?.resolve(content.width)) | |
| 2701 | } | |
| 2696 | 2702 | let x = style.left ?? (style.right.map { content.width - $0 - boundedWidth } ?? 0) |
| 2697 | 2703 | let y = style.top ?? (style.bottom.map { content.height - $0 - boundedHeight } ?? 0) |
| 2698 | 2704 | frames.append((child, CGRect(x: content.minX + x, y: content.minY + y, width: boundedWidth, height: boundedHeight))) |