e00c39aa5f
Flutter's safe area leaves out the window controls of a windowed iPad app, so they covered the list pane's title pill and took its taps. A small Runner plugin reports their corner from UIKit's corner-adapted safe-area regions over a method channel, and SegmentedBar pads the side they overlap. No-op off iOS and when there are no controls.
53 lines
2.7 KiB
Markdown
53 lines
2.7 KiB
Markdown
# Window controls inset (iPadOS 26 windowed apps)
|
||
|
||
Fixes finding 1 of `notes/ipad-layout-review.md`: in a window, the system
|
||
window controls covered the list pane's title pill and took its taps.
|
||
|
||
## How the inset is obtained
|
||
|
||
Flutter's `MediaQuery` padding is UIKit's plain safe area, which never
|
||
includes the controls (in a window on the simulator: top 10, left 0). iOS 26
|
||
reports them through corner-adapted layout regions instead:
|
||
`edgeInsets(for: .safeArea(cornerAdaptation: .horizontal))` gives left 66 and
|
||
`.vertical` gives top 53 while the controls are shown. The horizontal region
|
||
also grows a few points for rounded corners (5.5–9.5 at full screen and on the
|
||
window's other side), so a corner counts as the controls only when both
|
||
regions grow.
|
||
|
||
- `ios/Runner/WindowControlsPlugin.swift` (registered in `AppDelegate`) adds
|
||
an invisible probe view over the Flutter view and sends the rect on the
|
||
`pipelines/window_controls` method channel: `start` returns it, `changed`
|
||
follows window resizes and full screen. Nil before iOS 26 and at portrait
|
||
full screen. UIKit reports nothing for a `UIRequiresFullScreen`
|
||
compatibility window, which the system scales instead.
|
||
- `lib/ui/adaptive/window_controls.dart`: `WindowControls.of` (platform rect;
|
||
a null notifier off iOS), `WindowControlsScope` (fake for tests) and
|
||
`WindowControlsClearance`, which measures its global position after layout
|
||
(and when its route finishes a transition) and pads the side the controls
|
||
overlap, keeping 8 pt clear of them.
|
||
- `SegmentedBar` wraps its row of pieces in `WindowControlsClearance`, so
|
||
every top bar at the window's top corner (the shell's list pane, a page
|
||
pushed at compact width) moves its leading piece right of the controls;
|
||
bars elsewhere (a detail pane) are not touched.
|
||
|
||
## Verification
|
||
|
||
iPad Air 13-inch (M4) simulators only, iOS 26.4 and 27.0, fixture entry
|
||
`tool/search_selection_probe_entry.dart` with
|
||
`route=/chat/perf-chat-0&chats=8&colors=1&msgs=60,20&rich=1&links=1&tasks=4`.
|
||
`simctl` cannot resize a window; a throwaway XCUITest (outside the repo)
|
||
dragged the window's resize grip.
|
||
|
||
- `window-controls-inset/air26-window.jpg`, `-crop.jpg`: 1024x1053 window,
|
||
list beside chat; "Chat" starts right of the controls (was under them:
|
||
`ipad-layout-review/air-win-chat0-crop.jpg`).
|
||
- `air26-window-compact.jpg`, `-crop.jpg`: 519x775 window, the pushed chat's
|
||
Back button starts right of the controls.
|
||
- `air26-fullscreen.jpg`, `-crop.jpg`: the same run dragged back to full
|
||
screen; the pill returns to its 12 pt margin.
|
||
- `ios27-window.jpg`: the same on iOS 27.0.
|
||
|
||
On the iOS 27.0 runtime at landscape full screen UIKit also reports the
|
||
(hidden) controls corner (left 66, top 53 under a top safe area of 10), so the
|
||
list pane's title moves right there too, as UIKit asks.
|