Skip to content

Add getBarRegion: where a bar fits beside the status icons - #5

Merged
JanMichaelPeter merged 3 commits into
mainfrom
bar-region
Oct 14, 2026
Merged

JanMichaelPeter merged 3 commits into
mainfrom
bar-region

Conversation

@JanMichaelPeter

Copy link
Copy Markdown
Owner

What

WindowPlacementDetector.getBarRegion(WindowEdge edge, double extent) returns where the system places a bar of that thickness along a window edge, as a Rect in Flutter's coordinates, clear of the status icons, the rounded corners and the home indicator. It wraps UIKit's UIView.LayoutRegion.bar(onEdge:extent:) (iOS 27.1).

Why

On the iPhone Duo the status icons sit in a column at the side, or in a band at the top in unfolded portrait. The safe area gives up that whole column or band; there is no public API for the icons' frames, and statusBarFrame is a 2 pt strip there. The bar region is the only API that knows where the icons end: a bar on their edge starts below them, a top bar ends before them.

Measured on the iPhone Duo simulator (iOS 27.1), 64 pt bars:

Posture Safe insets Bar region next to the icons
Folded right 84, bottom 34 right bar from y 170
Unfolded landscape right 84, bottom 34 right bar from y 120
Split screen, app on the right right 84, bottom 34 right bar from y 120
Split screen, app on the left bottom 34 right bar from y 16 (no icons)
Unfolded portrait top 82, bottom 34 top bar x 16–535

How

  • New Pigeon host method getBarRegion(BarEdge, double) -> BarRegion? (regenerated with Pigeon 27.3.0, as before).
  • iOS: looks up the Flutter view in the active window and reads the layout guide's frame. Null before iOS 27.1.
  • Android: returns null (no equivalent).
  • The platform interface defaults to null, so implementations that extend it keep working; mocks that implements it need the method.
  • Public WindowEdge enum, README section, CHANGELOG, version 0.0.3.

Testing

  • Unit tests for the Pigeon mapping and the detector delegation; analyze, tests and the format check pass on Flutter 3.35.6.
  • On the simulator, the plugin returned exactly the rectangles UIKit reports directly, on all four edges.

duo_navigation uses this to keep its side column and title bar clear of the status icons (separate PR, needs this released as 0.0.3).

WindowPlacementDetector.getBarRegion(edge, extent) wraps UIKit's
UIView.LayoutRegion.bar(onEdge:extent:) (iOS 27.1): the region for a bar
of that thickness along a window edge, in Flutter's coordinates, clear of
the status icons, the rounded corners and the home indicator.

On the iPhone Duo the status icons sit in a column at the side (or a band
at the top in unfolded portrait), and the safe area gives up that whole
column or band. A bar region on that edge starts below the icons; a top
bar region ends before them.

Null before iOS 27.1, on Android and without a window. The platform
interface defaults to null, so other implementations keep working.
Bumps the version to 0.0.3.
Xcode 26 (iOS 26 SDK) doesn't know UIView.LayoutRegion.bar(onEdge:extent:),
so the plugin failed to compile there: #available only guards the call at
run time. Look up layoutRegionForBarOnEdge:extent: and
layoutGuideForLayoutRegion: at run time instead, and return nil where they
are missing. Same regions as the direct call on the iOS 27.1 simulator.
@JanMichaelPeter
JanMichaelPeter merged commit 430730c into main Oct 14, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant