mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 00:44:49 +00:00
On iOS 27.1+, the window layout probe publishes the top bar guide frame and active occlusion rects. When the top bar starts above the system top inset, the safe-area top moves up to it, and each header row that lands in the band trims its trailing padding to the status region. A row whose controls cannot fit beside it starts below the region on its own. When the guide is missing or starts at or below the system top, the override is a no-op, which is the case on every iPhone and on the Duo outer screen. Co-authored-by: Elsa Granger <zeyugao@outlook.com>
19 lines
702 B
TypeScript
19 lines
702 B
TypeScript
import { createContext, useContext } from "react";
|
|
import { useWindowDimensions } from "react-native";
|
|
import type { TopBand, WindowLayout } from "./model";
|
|
|
|
export const WindowLayoutContext = createContext<WindowLayout | null>(null);
|
|
|
|
/** Published by `WindowLayoutProvider` beside the safe-area insets it derives from it. */
|
|
export const TopBandContext = createContext<TopBand | null>(null);
|
|
|
|
export function useWindowLayout(): WindowLayout | null {
|
|
const layout = useContext(WindowLayoutContext);
|
|
const { width, height } = useWindowDimensions();
|
|
return layout &&
|
|
Math.abs(layout.bounds.width - width) <= 0.5 &&
|
|
Math.abs(layout.bounds.height - height) <= 0.5
|
|
? layout
|
|
: null;
|
|
}
|