@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
tsx 32 lines 1.13 KB
Raw
1 import { requireNativeView, requireOptionalNativeModule } from "expo";
2 import type { NativeSyntheticEvent, ViewProps } from "react-native";
3 import type { NativeLayoutMetrics } from "../lib/reserved-regions";
4
5 interface ObserverProps extends ViewProps {
6 readonly onMetricsChange?: (event: NativeSyntheticEvent<NativeLayoutMetrics>) => void;
7 }
8
9 function resolveObserver() {
10 try {
11 const module = requireOptionalNativeModule<{
12 readonly ViewPrototypes?: { readonly T3NativeControls_LayoutMetrics?: unknown };
13 }>("T3NativeControls");
14 if (!module?.ViewPrototypes?.T3NativeControls_LayoutMetrics) return null;
15 return requireNativeView<ObserverProps>("T3NativeControls", "LayoutMetrics");
16 } catch {
17 return null;
18 }
19 }
20 const Observer = resolveObserver();
21
22 export function NativeLayoutObserver(props: {
23 readonly onChange?: (metrics: NativeLayoutMetrics) => void;
24 }) {
25 return Observer ? (
26 <Observer
27 pointerEvents="none"
28 onMetricsChange={props.onChange ? (event) => props.onChange?.(event.nativeEvent) : undefined}
29 style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }}
30 />
31 ) : null;
32 }