BnSafeAreaInsets
Namespace: BlazorNative.Core
The area of the display obscured by system UI — notches, camera cutouts, status bars, home indicators and rounded corners — reported by the shell in its own layout units.
public readonly record struct BnSafeAreaInsets
Inheritance Object → ValueType → BnSafeAreaInsets
Implements IEquatable<BnSafeAreaInsets>
Attributes IsReadOnlyAttribute
Remarks:
HAND-WRITTEN, like BnHostEvents: this is public API with a PublicAPI baseline, and a generator able to rewrite a frozen surface is worse than the drift it prevents.
The values change at runtime — rotation, a keyboard appearing, a call banner — so treat them as current rather than constant.
Fields
Zero
No obscured area on any edge. Also the value before the first shell report arrives, which is why the first frame of a run renders un-inset.
public static BnSafeAreaInsets Zero;
Properties
Top
public double Top { get; init; }
Property Value
Right
public double Right { get; init; }
Property Value
Bottom
public double Bottom { get; init; }
Property Value
Left
public double Left { get; init; }
Property Value
Current
The most recently reported insets — BnSafeAreaInsets.Zero until the first
safeAreaChanged host event arrives, and reset to BnSafeAreaInsets.Zero by
BnSafeAreaInsets.ResetForTests().
public static BnSafeAreaInsets Current { get; }
Property Value
Remarks:
FRAMEWORK-OWNED: the reserved safeAreaChanged host-event arm
(Exports.DispatchHostSafeArea, BlazorNative.Runtime) is the only
production writer, via BnSafeAreaInsets.Report(BnSafeAreaInsets). Runtime calls the same public
BnSafeAreaInsets.Report(BnSafeAreaInsets) method app code could call, the same trade
BnLog.Level makes for the same reason (see that type's remarks):
a public, honestly-named seam beats an InternalsVisibleTo web. Since 18.1 this
package does grant Runtime InternalsVisibleTo, for one member only:
BnLog.Flush, which blazornative_shutdown calls to drain BnLog's queue
and which app code has no reason to call. BnSafeAreaInsets.Report(BnSafeAreaInsets) stays public.
Constructors
BnSafeAreaInsets(Double, Double, Double, Double)
The area of the display obscured by system UI — notches, camera cutouts, status bars, home indicators and rounded corners — reported by the shell in its own layout units.
public BnSafeAreaInsets(double Top, double Right, double Bottom, double Left)
Parameters
Top Double
Right Double
Bottom Double
Left Double
Remarks:
HAND-WRITTEN, like BnHostEvents: this is public API with a PublicAPI baseline, and a generator able to rewrite a frozen surface is worse than the drift it prevents.
The values change at runtime — rotation, a keyboard appearing, a call banner — so treat them as current rather than constant.
Methods
Report(BnSafeAreaInsets)
Stores insets as BnSafeAreaInsets.Current and raises
BnSafeAreaInsets.Changed for every subscriber, with per-subscriber isolation — a
throwing subscriber is stderr-logged and the remaining subscribers still run,
the same posture NativeNavigationManager.RaiseRouteChanged uses for
INavigationManager.RouteChanged. Called by the runtime's
safeAreaChanged host-event arm on every valid payload — including when
no session is mounted, so a later mount starts with the right values instead
of rendering at zero a second time.
public static void Report(BnSafeAreaInsets insets)
Parameters
insets BnSafeAreaInsets
ResetForTests()
Test-only: resets BnSafeAreaInsets.Current to BnSafeAreaInsets.Zero and
clears every BnSafeAreaInsets.Changed subscriber, so tests don't leak state or
handlers across runs — the same posture as
HostSession.ResetForTests/NativeShellBridge.ResetForTests.
The production ABI never calls this.
public static void ResetForTests()
SetForTests(BnSafeAreaInsets)
Test-only: places a known BnSafeAreaInsets.Current value WITHOUT
raising BnSafeAreaInsets.Changed — for seeding state before a session mounts
(e.g. so a component's first render already sees the right insets) without
fabricating a safeAreaChanged payload. Production code must call
BnSafeAreaInsets.Report(BnSafeAreaInsets) instead: that is the path that notifies subscribers.
public static void SetForTests(BnSafeAreaInsets insets)
Parameters
insets BnSafeAreaInsets
Events
Changed
Raised by BnSafeAreaInsets.Report(BnSafeAreaInsets) every time the shell reports new
insets, synchronously on the calling thread — even when the reported value
equals the previous one. A subscribing component calls its own
StateHasChanged() here (a later phase); this type only republishes,
it never renders anything itself.
public static event Action<BnSafeAreaInsets>? Changed;