decord/source/1561_useSafeAreaInsets.js

153 lines
4.7 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 1561
2026-07-25 08:10:48 +00:00
// Function ID: 17617
2026-07-20 16:05:17 +00:00
// Name: useSafeAreaInsets
2026-07-23 10:11:24 +00:00
// Dependencies: [57, 29, 31, 27, 33, 1562]
2026-07-20 16:05:17 +00:00
// Exports: SafeAreaListener, SafeAreaProvider, useSafeArea, useSafeAreaFrame, withSafeAreaInsets
// Module 1561 (useSafeAreaInsets)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
import _objectWithoutProperties from "_objectWithoutProperties";
import importAllResult from "result";
import get_ActivityIndicator from "get ActivityIndicator";
import { jsx } from "jsxProd";
2026-07-20 16:05:17 +00:00
let StyleSheet;
2026-07-23 10:11:24 +00:00
let closure_7;
const require = arg1;
2026-07-20 16:05:17 +00:00
function useSafeAreaInsets() {
2026-07-23 10:11:24 +00:00
context = importAllResult.useContext(context);
2026-07-20 16:05:17 +00:00
if (null == context) {
const _Error = Error;
2026-07-23 10:11:24 +00:00
const error = new Error(c12);
2026-07-20 16:05:17 +00:00
throw error;
} else {
return context;
}
}
2026-07-23 10:11:24 +00:00
let closure_2 = ["children", "initialMetrics", "initialSafeAreaInsets", "style"];
let closure_3 = ["onChange", "style", "children"];
({ Dimensions: closure_7, StyleSheet } = get_ActivityIndicator);
let context = importAllResult.createContext(null);
let context1 = importAllResult.createContext(null);
2026-07-20 16:05:17 +00:00
const styles = StyleSheet.create({ fill: { flex: 1 } });
2026-07-23 10:11:24 +00:00
let c12 = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
2026-07-20 16:05:17 +00:00
export const SafeAreaInsetsContext = context;
export const SafeAreaFrameContext = context1;
export const SafeAreaProvider = function SafeAreaProvider(arg0) {
let children;
let initialMetrics;
let initialSafeAreaInsets;
let style;
({ initialMetrics, initialSafeAreaInsets } = arg0);
({ children, style } = arg0);
2026-07-23 10:11:24 +00:00
context = importAllResult.useContext(context);
context1 = importAllResult.useContext(context1);
2026-07-20 16:05:17 +00:00
let insets;
if (null != initialMetrics) {
insets = initialMetrics.insets;
}
if (null != insets) {
initialSafeAreaInsets = insets;
}
if (null != initialSafeAreaInsets) {
context = initialSafeAreaInsets;
}
let tmp6 = null;
if (null != context) {
tmp6 = context;
}
2026-07-23 10:11:24 +00:00
const tmp7 = callback(importAllResult.useState(tmp6), 2);
2026-07-20 16:05:17 +00:00
const first = tmp7[0];
2026-07-23 10:11:24 +00:00
const _require = tmp7[1];
2026-07-20 16:05:17 +00:00
let frame;
if (null != initialMetrics) {
frame = initialMetrics.frame;
}
if (null != frame) {
context1 = frame;
}
if (null == context1) {
2026-07-23 10:11:24 +00:00
let obj = { x: 0, y: 0, width: store.get("window").width, height: store.get("window").height };
2026-07-20 16:05:17 +00:00
context1 = obj;
}
2026-07-23 10:11:24 +00:00
const tmp12 = callback(importAllResult.useState(context1), 2);
const dependencyMap = tmp12[1];
2026-07-20 16:05:17 +00:00
const onInsetsChange = importAllResult.useCallback((nativeEvent) => {
2026-07-23 10:11:24 +00:00
let closure_0;
let closure_1;
2026-07-20 16:05:17 +00:00
({ frame: closure_0, insets: closure_1 } = nativeEvent.nativeEvent);
callback2((height) => {
let tmp = height;
if (styles) {
if (styles.height === height.height) {
if (styles.width === height.width) {
if (styles.x === height.x) {
tmp = height;
}
}
}
tmp = styles;
}
return tmp;
});
callback((arg0) => {
let rect = arg0;
if (arg0) {
if (closure_1.bottom === rect.bottom) {
if (closure_1.left === rect.left) {
return rect;
}
}
}
rect = closure_1;
});
}, []);
style = [closure_11.fill, ];
style[1] = style;
obj = {};
let tmp15 = null;
if (null != first) {
obj = { value: tmp12[0] };
const obj1 = { value: first, children };
2026-07-23 10:11:24 +00:00
obj.children = <context.Provider value={first}>{children}</context.Provider>;
tmp15 = <context1.Provider value={tmp12[0]} />;
2026-07-20 16:05:17 +00:00
}
obj.children = tmp15;
2026-07-23 10:11:24 +00:00
return jsx(_require(1562).NativeSafeAreaProvider, Object.assign({ style, onInsetsChange }, callback2(arg0, closure_2), obj));
2026-07-20 16:05:17 +00:00
};
export const SafeAreaListener = function SafeAreaListener(onChange) {
let children;
let style;
2026-07-23 10:11:24 +00:00
onChange = onChange.onChange;
2026-07-20 16:05:17 +00:00
({ style, children } = onChange);
const items = [closure_11.fill, style];
2026-07-23 10:11:24 +00:00
return jsx(onChange(1562).NativeSafeAreaProvider, Object.assign({}, callback2(onChange, closure_3), {
2026-07-20 16:05:17 +00:00
style: items,
onInsetsChange(insets) {
onChange({ insets: insets.nativeEvent.insets, frame: insets.nativeEvent.frame });
},
children
}));
};
export { useSafeAreaInsets };
export const useSafeAreaFrame = function useSafeAreaFrame() {
const context = importAllResult.useContext(context1);
if (null == context) {
const _Error = Error;
2026-07-23 10:11:24 +00:00
const error = new Error(c12);
2026-07-20 16:05:17 +00:00
throw error;
} else {
return context;
}
};
export const withSafeAreaInsets = function withSafeAreaInsets(arg0) {
2026-07-23 10:11:24 +00:00
let closure_0 = arg0;
return importAllResult.forwardRef((arg0, ref) => outer1_8(closure_0, Object.assign({}, arg0, { insets: outer1_13(), ref })));
2026-07-20 16:05:17 +00:00
};
export const useSafeArea = function useSafeArea() {
return useSafeAreaInsets();
};
export const SafeAreaConsumer = context.Consumer;
export const SafeAreaContext = context;