This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,35 @@
import * as React from 'react';
import { View } from 'react-native';
import useWindowDimensions from './useWindowDimensions';
export function CompatNativeSafeAreaProvider({
children,
style,
onInsetsChange
}) {
const window = useWindowDimensions();
React.useEffect(() => {
const insets = {
top: 0,
bottom: 0,
left: 0,
right: 0
};
const frame = {
x: 0,
y: 0,
width: window.width,
height: window.height
}; // @ts-ignore: missing properties
onInsetsChange({
nativeEvent: {
insets,
frame
}
});
}, [onInsetsChange, window.height, window.width]);
return /*#__PURE__*/React.createElement(View, {
style: style
}, children);
}
//# sourceMappingURL=CompatNativeSafeAreaProvider.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["CompatNativeSafeAreaProvider.tsx"],"names":["React","View","useWindowDimensions","CompatNativeSafeAreaProvider","children","style","onInsetsChange","window","useEffect","insets","top","bottom","left","right","frame","x","y","width","height","nativeEvent"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,OAAOC,mBAAP,MAAgC,uBAAhC;AAEA,OAAO,SAASC,4BAAT,CAAsC;AAC3CC,EAAAA,QAD2C;AAE3CC,EAAAA,KAF2C;AAG3CC,EAAAA;AAH2C,CAAtC,EAIyB;AAC9B,QAAMC,MAAM,GAAGL,mBAAmB,EAAlC;AACAF,EAAAA,KAAK,CAACQ,SAAN,CAAgB,MAAM;AACpB,UAAMC,MAAM,GAAG;AACbC,MAAAA,GAAG,EAAE,CADQ;AAEbC,MAAAA,MAAM,EAAE,CAFK;AAGbC,MAAAA,IAAI,EAAE,CAHO;AAIbC,MAAAA,KAAK,EAAE;AAJM,KAAf;AAMA,UAAMC,KAAK,GAAG;AACZC,MAAAA,CAAC,EAAE,CADS;AAEZC,MAAAA,CAAC,EAAE,CAFS;AAGZC,MAAAA,KAAK,EAAEV,MAAM,CAACU,KAHF;AAIZC,MAAAA,MAAM,EAAEX,MAAM,CAACW;AAJH,KAAd,CAPoB,CAapB;;AACAZ,IAAAA,cAAc,CAAC;AAAEa,MAAAA,WAAW,EAAE;AAAEV,QAAAA,MAAF;AAAUK,QAAAA;AAAV;AAAf,KAAD,CAAd;AACD,GAfD,EAeG,CAACR,cAAD,EAAiBC,MAAM,CAACW,MAAxB,EAAgCX,MAAM,CAACU,KAAvC,CAfH;AAgBA,sBAAO,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEZ;AAAb,KAAqBD,QAArB,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport { NativeSafeAreaProviderProps } from './SafeArea.types';\nimport useWindowDimensions from './useWindowDimensions';\n\nexport function CompatNativeSafeAreaProvider({\n children,\n style,\n onInsetsChange,\n}: NativeSafeAreaProviderProps) {\n const window = useWindowDimensions();\n React.useEffect(() => {\n const insets = {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n };\n const frame = {\n x: 0,\n y: 0,\n width: window.width,\n height: window.height,\n };\n // @ts-ignore: missing properties\n onInsetsChange({ nativeEvent: { insets, frame } });\n }, [onInsetsChange, window.height, window.width]);\n return <View style={style}>{children}</View>;\n}\n"]}

View File

@ -0,0 +1,7 @@
export const initialWindowMetrics = null;
/**
* @deprecated
*/
export const initialWindowSafeAreaInsets = null;
//# sourceMappingURL=InitialWindow.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["InitialWindow.ts"],"names":["initialWindowMetrics","initialWindowSafeAreaInsets"],"mappings":"AAEA,OAAO,MAAMA,oBAAoC,GAAG,IAA7C;AAEP;;;;AAGA,OAAO,MAAMC,2BAA8C,GAAG,IAAvD","sourcesContent":["import { EdgeInsets, Metrics } from './SafeArea.types';\n\nexport const initialWindowMetrics: Metrics | null = null;\n\n/**\n * @deprecated\n */\nexport const initialWindowSafeAreaInsets: EdgeInsets | null = null;\n"]}

View File

@ -0,0 +1,9 @@
import { UIManager } from 'react-native';
const RNCSafeAreaProviderConfig = UIManager.getViewManagerConfig('RNCSafeAreaProvider');
export const initialWindowMetrics = RNCSafeAreaProviderConfig != null && RNCSafeAreaProviderConfig.Constants != null ? RNCSafeAreaProviderConfig.Constants.initialWindowMetrics : null;
/**
* @deprecated
*/
export const initialWindowSafeAreaInsets = initialWindowMetrics === null || initialWindowMetrics === void 0 ? void 0 : initialWindowMetrics.insets;
//# sourceMappingURL=InitialWindow.native.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["InitialWindow.native.ts"],"names":["UIManager","RNCSafeAreaProviderConfig","getViewManagerConfig","initialWindowMetrics","Constants","initialWindowSafeAreaInsets","insets"],"mappings":"AAAA,SAASA,SAAT,QAA0B,cAA1B;AAGA,MAAMC,yBAAyB,GAAGD,SAAS,CAACE,oBAAV,CAChC,qBADgC,CAAlC;AAIA,OAAO,MAAMC,oBAAoB,GAAIF,yBAAyB,IAAI,IAA7B,IACrCA,yBAAyB,CAACG,SAA1B,IAAuC,IADF,GAEjCH,yBAAyB,CAACG,SAA1B,CAAoCD,oBAFH,GAGjC,IAHG;AAKP;;;;AAGA,OAAO,MAAME,2BAA2B,GAAGF,oBAAH,aAAGA,oBAAH,uBAAGA,oBAAoB,CAAEG,MAA1D","sourcesContent":["import { UIManager } from 'react-native';\nimport { Metrics } from './SafeArea.types';\n\nconst RNCSafeAreaProviderConfig = UIManager.getViewManagerConfig(\n 'RNCSafeAreaProvider',\n) as any;\n\nexport const initialWindowMetrics = (RNCSafeAreaProviderConfig != null &&\nRNCSafeAreaProviderConfig.Constants != null\n ? RNCSafeAreaProviderConfig.Constants.initialWindowMetrics\n : null) as Metrics | null;\n\n/**\n * @deprecated\n */\nexport const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;\n"]}

View File

@ -0,0 +1,138 @@
import * as React from 'react';
import { View } from 'react-native';
/**
* TODO:
* Currently insets and frame are based on the window and are not
* relative to the provider view. This is inconsistent with iOS and Android.
* However in most cases if the provider view covers the screen this is not
* an issue.
*/
const CSSTransitions = {
WebkitTransition: 'webkitTransitionEnd',
Transition: 'transitionEnd',
MozTransition: 'transitionend',
MSTransition: 'msTransitionEnd',
OTransition: 'oTransitionEnd'
};
export default function NativeSafeAreaView({
children,
style,
onInsetsChange
}) {
React.useEffect(() => {
// Skip for SSR.
if (typeof document === 'undefined') {
return;
}
const element = createContextElement();
document.body.appendChild(element);
const onEnd = () => {
const {
paddingTop,
paddingBottom,
paddingLeft,
paddingRight
} = window.getComputedStyle(element);
const insets = {
top: paddingTop ? parseInt(paddingTop, 10) : 0,
bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
right: paddingRight ? parseInt(paddingRight, 10) : 0
};
const frame = {
x: 0,
y: 0,
width: document.documentElement.offsetWidth,
height: document.documentElement.offsetHeight
}; // @ts-ignore: missing properties
onInsetsChange({
nativeEvent: {
insets,
frame
}
});
};
element.addEventListener(getSupportedTransitionEvent(), onEnd);
onEnd();
return () => {
document.body.removeChild(element);
element.removeEventListener(getSupportedTransitionEvent(), onEnd);
};
}, [onInsetsChange]);
return /*#__PURE__*/React.createElement(View, {
style: style
}, children);
}
let _supportedTransitionEvent = null;
function getSupportedTransitionEvent() {
if (_supportedTransitionEvent !== null) {
return _supportedTransitionEvent;
}
const element = document.createElement('invalidtype');
_supportedTransitionEvent = CSSTransitions.Transition;
for (const key in CSSTransitions) {
if (element.style[key] !== undefined) {
_supportedTransitionEvent = CSSTransitions[key];
break;
}
}
return _supportedTransitionEvent;
}
let _supportedEnv = null;
function getSupportedEnv() {
if (_supportedEnv !== null) {
return _supportedEnv;
}
const {
CSS
} = window;
if (CSS && CSS.supports && CSS.supports('top: constant(safe-area-inset-top)')) {
_supportedEnv = 'constant';
} else {
_supportedEnv = 'env';
}
return _supportedEnv;
}
function getInset(side) {
return "".concat(getSupportedEnv(), "(safe-area-inset-").concat(side, ")");
}
function createContextElement() {
const element = document.createElement('div');
const {
style
} = element;
style.position = 'fixed';
style.left = '0';
style.top = '0';
style.width = '0';
style.height = '0';
style.zIndex = '-1';
style.overflow = 'hidden';
style.visibility = 'hidden'; // Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
style.transitionDuration = '0.05s';
style.transitionProperty = 'padding';
style.transitionDelay = '0s';
style.paddingTop = getInset('top');
style.paddingBottom = getInset('bottom');
style.paddingLeft = getInset('left');
style.paddingRight = getInset('right');
return element;
}
//# sourceMappingURL=NativeSafeAreaProvider.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
export default CompatNativeSafeAreaProvider;
//# sourceMappingURL=NativeSafeAreaProvider.macos.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["NativeSafeAreaProvider.macos.tsx"],"names":["CompatNativeSafeAreaProvider"],"mappings":"AAAA,SAASA,4BAAT,QAA6C,gCAA7C;AAEA,eAAeA,4BAAf","sourcesContent":["import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';\n\nexport default CompatNativeSafeAreaProvider;\n"]}

View File

@ -0,0 +1,3 @@
import { requireNativeComponent } from 'react-native';
export default requireNativeComponent('RNCSafeAreaProvider');
//# sourceMappingURL=NativeSafeAreaProvider.native.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["NativeSafeAreaProvider.native.tsx"],"names":["requireNativeComponent"],"mappings":"AAAA,SAASA,sBAAT,QAAuC,cAAvC;AAGA,eAAeA,sBAAsB,CACnC,qBADmC,CAArC","sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport { NativeSafeAreaProviderProps } from './SafeArea.types';\n\nexport default requireNativeComponent<NativeSafeAreaProviderProps>(\n 'RNCSafeAreaProvider',\n);\n"]}

View File

@ -0,0 +1,3 @@
import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
export default CompatNativeSafeAreaProvider;
//# sourceMappingURL=NativeSafeAreaProvider.windows.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["NativeSafeAreaProvider.windows.tsx"],"names":["CompatNativeSafeAreaProvider"],"mappings":"AAAA,SAASA,4BAAT,QAA6C,gCAA7C;AAEA,eAAeA,4BAAf","sourcesContent":["import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';\n\nexport default CompatNativeSafeAreaProvider;\n"]}

View File

@ -0,0 +1,2 @@
//# sourceMappingURL=SafeArea.types.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}

View File

@ -0,0 +1,107 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { Dimensions, StyleSheet } from 'react-native';
import NativeSafeAreaProvider from './NativeSafeAreaProvider';
export const SafeAreaInsetsContext = React.createContext(null);
export const SafeAreaFrameContext = React.createContext(null);
export function SafeAreaProvider({
children,
initialMetrics,
initialSafeAreaInsets,
style
}) {
var _ref, _ref2, _initialMetrics$inset, _ref3, _initialMetrics$frame;
const parentInsets = useParentSafeAreaInsets();
const parentFrame = useParentSafeAreaFrame();
const [insets, setInsets] = React.useState((_ref = (_ref2 = (_initialMetrics$inset = initialMetrics === null || initialMetrics === void 0 ? void 0 : initialMetrics.insets) !== null && _initialMetrics$inset !== void 0 ? _initialMetrics$inset : initialSafeAreaInsets) !== null && _ref2 !== void 0 ? _ref2 : parentInsets) !== null && _ref !== void 0 ? _ref : null);
const [frame, setFrame] = React.useState((_ref3 = (_initialMetrics$frame = initialMetrics === null || initialMetrics === void 0 ? void 0 : initialMetrics.frame) !== null && _initialMetrics$frame !== void 0 ? _initialMetrics$frame : parentFrame) !== null && _ref3 !== void 0 ? _ref3 : {
// Backwards compat so we render anyway if we don't have frame.
x: 0,
y: 0,
width: Dimensions.get('window').width,
height: Dimensions.get('window').height
});
const onInsetsChange = React.useCallback(event => {
const {
nativeEvent: {
frame: nextFrame,
insets: nextInsets
}
} = event;
if ( // Backwards compat with old native code that won't send frame.
nextFrame && (nextFrame.height !== frame.height || nextFrame.width !== frame.width || nextFrame.x !== frame.x || nextFrame.y !== frame.y)) {
setFrame(nextFrame);
}
if (!insets || nextInsets.bottom !== insets.bottom || nextInsets.left !== insets.left || nextInsets.right !== insets.right || nextInsets.top !== insets.top) {
setInsets(nextInsets);
}
}, [frame, insets]);
return /*#__PURE__*/React.createElement(NativeSafeAreaProvider, {
style: [styles.fill, style],
onInsetsChange: onInsetsChange
}, insets != null ? /*#__PURE__*/React.createElement(SafeAreaFrameContext.Provider, {
value: frame
}, /*#__PURE__*/React.createElement(SafeAreaInsetsContext.Provider, {
value: insets
}, children)) : null);
}
const styles = StyleSheet.create({
fill: {
flex: 1
}
});
function useParentSafeAreaInsets() {
return React.useContext(SafeAreaInsetsContext);
}
function useParentSafeAreaFrame() {
return React.useContext(SafeAreaFrameContext);
}
export function useSafeAreaInsets() {
const safeArea = React.useContext(SafeAreaInsetsContext);
if (safeArea == null) {
throw new Error('No safe area insets value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.');
}
return safeArea;
}
export function useSafeAreaFrame() {
const frame = React.useContext(SafeAreaFrameContext);
if (frame == null) {
throw new Error('No safe area frame value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.');
}
return frame;
}
export function withSafeAreaInsets(WrappedComponent) {
return /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(SafeAreaConsumer, null, insets => /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, {
insets: insets,
ref: ref
}))));
}
/**
* @deprecated
*/
export function useSafeArea() {
return useSafeAreaInsets();
}
/**
* @deprecated
*/
export const SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
/**
* @deprecated
*/
export const SafeAreaContext = SafeAreaInsetsContext;
//# sourceMappingURL=SafeAreaContext.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,81 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from './SafeAreaContext';
// prettier-ignore
const TOP = 0b1000,
RIGHT = 0b0100,
BOTTOM = 0b0010,
LEFT = 0b0001,
ALL = 0b1111;
/* eslint-disable no-bitwise */
const edgeBitmaskMap = {
top: TOP,
right: RIGHT,
bottom: BOTTOM,
left: LEFT
};
export function SafeAreaView(_ref) {
let {
style = {},
mode,
edges
} = _ref,
rest = _objectWithoutProperties(_ref, ["style", "mode", "edges"]);
const insets = useSafeAreaInsets();
const edgeBitmask = edges != null ? edges.reduce((accum, edge) => accum | edgeBitmaskMap[edge], 0) : ALL;
const appliedStyle = React.useMemo(() => {
const insetTop = edgeBitmask & TOP ? insets.top : 0;
const insetRight = edgeBitmask & RIGHT ? insets.right : 0;
const insetBottom = edgeBitmask & BOTTOM ? insets.bottom : 0;
const insetLeft = edgeBitmask & LEFT ? insets.left : 0;
const flatStyle = StyleSheet.flatten(style);
if (mode === 'margin') {
const {
margin = 0,
marginVertical = margin,
marginHorizontal = margin,
marginTop = marginVertical,
marginRight = marginHorizontal,
marginBottom = marginVertical,
marginLeft = marginHorizontal
} = flatStyle;
const marginStyle = {
marginTop: marginTop + insetTop,
marginRight: marginRight + insetRight,
marginBottom: marginBottom + insetBottom,
marginLeft: marginLeft + insetLeft
};
return [style, marginStyle];
} else {
const {
padding = 0,
paddingVertical = padding,
paddingHorizontal = padding,
paddingTop = paddingVertical,
paddingRight = paddingHorizontal,
paddingBottom = paddingVertical,
paddingLeft = paddingHorizontal
} = flatStyle;
const paddingStyle = {
paddingTop: paddingTop + insetTop,
paddingRight: paddingRight + insetRight,
paddingBottom: paddingBottom + insetBottom,
paddingLeft: paddingLeft + insetLeft
};
return [style, paddingStyle];
}
}, [style, insets, mode, edgeBitmask]);
return /*#__PURE__*/React.createElement(View, _extends({
style: appliedStyle
}, rest));
}
//# sourceMappingURL=SafeAreaView.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
import { View } from 'react-native';
export const SafeAreaView = View;
//# sourceMappingURL=SafeAreaView.macos.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["SafeAreaView.macos.tsx"],"names":["View","SafeAreaView"],"mappings":"AAAA,SAASA,IAAT,QAAqB,cAArB;AAEA,OAAO,MAAMC,YAAY,GAAGD,IAArB","sourcesContent":["import { View } from 'react-native';\n\nexport const SafeAreaView = View;\n"]}

View File

@ -0,0 +1,3 @@
import { requireNativeComponent } from 'react-native';
export const SafeAreaView = requireNativeComponent('RNCSafeAreaView');
//# sourceMappingURL=SafeAreaView.native.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["SafeAreaView.native.tsx"],"names":["requireNativeComponent","SafeAreaView"],"mappings":"AAAA,SAASA,sBAAT,QAAuC,cAAvC;AAGA,OAAO,MAAMC,YAAY,GAAGD,sBAAsB,CAChD,iBADgD,CAA3C","sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport { NativeSafeAreaViewProps } from './SafeArea.types';\n\nexport const SafeAreaView = requireNativeComponent<NativeSafeAreaViewProps>(\n 'RNCSafeAreaView',\n);\n"]}

View File

@ -0,0 +1,3 @@
import { View } from 'react-native';
export const SafeAreaView = View;
//# sourceMappingURL=SafeAreaView.windows.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["SafeAreaView.windows.tsx"],"names":["View","SafeAreaView"],"mappings":"AAAA,SAASA,IAAT,QAAqB,cAArB;AAEA,OAAO,MAAMC,YAAY,GAAGD,IAArB","sourcesContent":["import { View } from 'react-native';\n\nexport const SafeAreaView = View;\n"]}

View File

@ -0,0 +1,5 @@
export * from './SafeAreaContext';
export * from './SafeAreaView';
export * from './InitialWindow';
export * from './SafeArea.types';
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"AAAA,cAAc,mBAAd;AACA,cAAc,gBAAd;AACA,cAAc,iBAAd;AACA,cAAc,kBAAd","sourcesContent":["export * from './SafeAreaContext';\nexport * from './SafeAreaView';\nexport * from './InitialWindow';\nexport * from './SafeArea.types';\n"]}

View File

@ -0,0 +1,29 @@
import { Dimensions } from 'react-native';
import { useEffect, useState } from 'react';
// Copied from https://github.com/facebook/react-native/blob/8d57691a/Libraries/Utilities/useWindowDimensions.js
// for compatibility with React Native < 0.61.
export default function useWindowDimensions() {
const [dimensions, setDimensions] = useState(() => Dimensions.get('window'));
useEffect(() => {
function handleChange({
window
}) {
if (dimensions.width !== window.width || dimensions.height !== window.height || dimensions.scale !== window.scale || dimensions.fontScale !== window.fontScale) {
setDimensions(window);
}
}
Dimensions.addEventListener('change', handleChange); // We might have missed an update between calling `get` in render and
// `addEventListener` in this handler, so we set it here. If there was
// no change, React will filter out this update as a no-op.
handleChange({
window: Dimensions.get('window')
});
return () => {
Dimensions.removeEventListener('change', handleChange);
};
}, [dimensions]);
return dimensions;
}
//# sourceMappingURL=useWindowDimensions.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["useWindowDimensions.tsx"],"names":["Dimensions","useEffect","useState","useWindowDimensions","dimensions","setDimensions","get","handleChange","window","width","height","scale","fontScale","addEventListener","removeEventListener"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,OAApC;AASA;AACA;AACA,eAAe,SAASC,mBAAT,GAA+C;AAC5D,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BH,QAAQ,CAAC,MAAMF,UAAU,CAACM,GAAX,CAAe,QAAf,CAAP,CAA5C;AACAL,EAAAA,SAAS,CAAC,MAAM;AACd,aAASM,YAAT,CAAsB;AAAEC,MAAAA;AAAF,KAAtB,EAA8D;AAC5D,UACEJ,UAAU,CAACK,KAAX,KAAqBD,MAAM,CAACC,KAA5B,IACAL,UAAU,CAACM,MAAX,KAAsBF,MAAM,CAACE,MAD7B,IAEAN,UAAU,CAACO,KAAX,KAAqBH,MAAM,CAACG,KAF5B,IAGAP,UAAU,CAACQ,SAAX,KAAyBJ,MAAM,CAACI,SAJlC,EAKE;AACAP,QAAAA,aAAa,CAACG,MAAD,CAAb;AACD;AACF;;AACDR,IAAAA,UAAU,CAACa,gBAAX,CAA4B,QAA5B,EAAsCN,YAAtC,EAXc,CAYd;AACA;AACA;;AACAA,IAAAA,YAAY,CAAC;AAAEC,MAAAA,MAAM,EAAER,UAAU,CAACM,GAAX,CAAe,QAAf;AAAV,KAAD,CAAZ;AACA,WAAO,MAAM;AACXN,MAAAA,UAAU,CAACc,mBAAX,CAA+B,QAA/B,EAAyCP,YAAzC;AACD,KAFD;AAGD,GAnBQ,EAmBN,CAACH,UAAD,CAnBM,CAAT;AAoBA,SAAOA,UAAP;AACD","sourcesContent":["import { Dimensions } from 'react-native';\nimport { useEffect, useState } from 'react';\n\ntype DisplayMetrics = {\n width: number;\n height: number;\n scale: number;\n fontScale: number;\n};\n\n// Copied from https://github.com/facebook/react-native/blob/8d57691a/Libraries/Utilities/useWindowDimensions.js\n// for compatibility with React Native < 0.61.\nexport default function useWindowDimensions(): DisplayMetrics {\n const [dimensions, setDimensions] = useState(() => Dimensions.get('window'));\n useEffect(() => {\n function handleChange({ window }: { window: DisplayMetrics }) {\n if (\n dimensions.width !== window.width ||\n dimensions.height !== window.height ||\n dimensions.scale !== window.scale ||\n dimensions.fontScale !== window.fontScale\n ) {\n setDimensions(window);\n }\n }\n Dimensions.addEventListener('change', handleChange);\n // We might have missed an update between calling `get` in render and\n // `addEventListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n handleChange({ window: Dimensions.get('window') });\n return () => {\n Dimensions.removeEventListener('change', handleChange);\n };\n }, [dimensions]);\n return dimensions;\n}\n"]}