also looking at this
test(ios): cover solid navigation bar title modes
#361
3 files
+22
-1
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.
| @@ -697,6 +697,17 @@ app, the iOS shell's gesture also covers the WebView. Pass | ||
| 697 | 697 | gesture of its own; native screens can still opt out independently with |
| 698 | 698 | `tabSwipeEnabled`. |
| 699 | 699 | |
| 700 | On iOS, a native screen can opt into an opaque navigation bar that uses its | |
| 701 | screen background, including the light/dark variant from `craft.config.json`: | |
| 702 | ||
| 703 | ```js | |
| 704 | craft.navigation.setOptions({ navigationBarSolid: true }) | |
| 705 | ``` | |
| 706 | ||
| 707 | This applies to both standard and large-title bars, and remains in place while | |
| 708 | the screen is pushed, popped, or revealed by a tab swipe. The default remains | |
| 709 | UIKit's translucent material; pass `navigationBarSolid: false` to restore it. | |
| 710 | ||
| 700 | 711 | A screen's content stays inside the safe area. To colour the strips under the |
| 701 | 712 | status bar and the home indicator too, such as a black full-screen timer with |
| 702 | 713 | the bar hidden, set `craft.navigation.setOptions({ hidden: true, |
| @@ -595,7 +595,9 @@ final class NativeLayoutUnitTests: XCTestCase { | ||
| 595 | 595 | navigation.loadViewIfNeeded() |
| 596 | 596 | controller.loadViewIfNeeded() |
| 597 | 597 | |
| 598 | controller.evaluateScript("craft.navigation.setOptions({ backgroundColor: '#123456', navigationBarSolid: true })") | |
| 598 | controller.evaluateScript("craft.navigation.setOptions({ title: 'Solid', largeTitle: true, backgroundColor: '#123456', navigationBarSolid: true })") | |
| 599 | XCTAssertEqual(controller.navigationItem.largeTitleDisplayMode, .always) | |
| 600 | XCTAssertTrue(navigation.navigationBar.prefersLargeTitles) | |
| 599 | 601 | let solid = try XCTUnwrap(controller.navigationItem.standardAppearance) |
| 600 | 602 | XCTAssertNil(solid.backgroundEffect) |
| 601 | 603 | // UIKit may normalize clear to nil; both mean no shadow. |
| @@ -606,6 +608,13 @@ final class NativeLayoutUnitTests: XCTestCase { | ||
| 606 | 608 | XCTAssertNotNil(controller.navigationItem.compactAppearance) |
| 607 | 609 | XCTAssertNotNil(controller.navigationItem.compactScrollEdgeAppearance) |
| 608 | 610 | |
| 611 | // The same fill remains attached when a screen opts out of the large | |
| 612 | // title layout; UIKit must not fall back to its translucent scroll-edge | |
| 613 | // material just because the title collapsed. | |
| 614 | controller.evaluateScript("craft.navigation.setOptions({ largeTitle: false })") | |
| 615 | XCTAssertEqual(controller.navigationItem.largeTitleDisplayMode, .never) | |
| 616 | XCTAssertNotNil(controller.navigationItem.scrollEdgeAppearance) | |
| 617 | ||
| 609 | 618 | controller.evaluateScript("craft.navigation.setOptions({ navigationBarSolid: false })") |
| 610 | 619 | XCTAssertNil(controller.navigationItem.standardAppearance) |
| 611 | 620 | XCTAssertNil(controller.navigationItem.scrollEdgeAppearance) |
| @@ -1568,6 +1568,7 @@ describe('Craft iOS builder', () => { | ||
| 1568 | 1568 | expect(screen).toContain('appearance.backgroundColor = screenBackgroundColor ?? config.resolvedBackgroundColor') |
| 1569 | 1569 | expect(screen).toContain('appearance.shadowColor = .clear') |
| 1570 | 1570 | expect(screen).toContain('navigationItem.compactScrollEdgeAppearance = appearance') |
| 1571 | expect(screen).toContain('navigationItem.standardAppearance = nil') | |
| 1571 | 1572 | expect(readFileSync(join(import.meta.dir, '..', 'fixtures/native-screen/NativeLayoutUnitTests.swift'), 'utf8')).toContain('try assertColor(light, red: 1, green: 1, blue: 1)') |
| 1572 | 1573 | // A screen that starts with its scroll view runs edge to edge, so what |
| 1573 | 1574 | // scrolls up goes under the bar, not over its back button; the bottom |