The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { requireNativeView } from "expo"; |
| 2 | import type { NativeSyntheticEvent, ViewProps } from "react-native"; |
| 3 | import type { VerticalHinge } from "../lib/layout"; |
| 4 | |
| 5 | interface ObserverProps extends ViewProps { |
| 6 | readonly onHingeChange: ( |
| 7 | event: NativeSyntheticEvent<Partial<VerticalHinge & { readonly windowX: number }>>, |
| 8 | ) => void; |
| 9 | } |
| 10 | |
| 11 | const Observer = requireNativeView<ObserverProps>("T3FoldPosture"); |
| 12 | |
| 13 | /** Reports a vertical hinge in this view's coordinates while the device is bent like a book. */ |
| 14 | export function AndroidHingeObserver(props: { |
| 15 | /** Receives the hinge in this view's coordinates and in window coordinates. */ |
| 16 | readonly onChange: (hinge: VerticalHinge | null, windowHinge: VerticalHinge | null) => void; |
| 17 | }) { |
| 18 | return ( |
| 19 | <Observer |
| 20 | pointerEvents="none" |
| 21 | onHingeChange={({ nativeEvent: { x, width, windowX } }) => |
| 22 | x === undefined || width === undefined || windowX === undefined |
| 23 | ? props.onChange(null, null) |
| 24 | : props.onChange({ x, width }, { x: windowX, width }) |
| 25 | } |
| 26 | style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }} |
| 27 | /> |
| 28 | ); |
| 29 | } |