68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
// Metro module 5638 (f5639).
|
|
import { memo, useRef, useState, useEffect, useMemo } from "react";
|
|
import { StyleSheet, View } from "react-native";
|
|
import subscribeToKeyboardUIStore from "./subscribeToKeyboardUIStore";
|
|
import { getSystemKeyboardHeight } from "./useSystemKeyboardHeight.native";
|
|
import { getKeyboardType } from "./useKeyboardType";
|
|
import { KeyboardTypes } from "./KeyboardTypes";
|
|
import { getCustomKeyboardHeight } from "./useCustomKeyboardHeight";
|
|
import { getKeyboardDuration } from "./useKeyboardDuration";
|
|
import { DeprecatedLayoutAnimationKeyboard } from "../../animations/native/DeprecatedLayoutAnimation";
|
|
const r28 = memo(function KeyboardAwareView(props) {
|
|
let ref2;
|
|
const { style, children, pointerEvents, animated = true } = props;
|
|
let c14956_1 = animated;
|
|
let keyboardHeightOffset = props.keyboardHeightOffset;
|
|
if (keyboardHeightOffset === void 0) {
|
|
keyboardHeightOffset = 0;
|
|
}
|
|
let c14956_2 = keyboardHeightOffset;
|
|
ref2 = void 0;
|
|
const r14 = Math;
|
|
let r23 = getSystemKeyboardHeight();
|
|
if (r23 === 0) {
|
|
r23 = getKeyboardType() !== KeyboardTypes.SYSTEM ? getCustomKeyboardHeight() : 0;
|
|
}
|
|
const ref = useRef(r14.max(0, r23 + keyboardHeightOffset));
|
|
const [state, setState] = useState(ref.current);
|
|
useEffect(() => subscribeToKeyboardUIStore(function() {
|
|
const r5 = Math;
|
|
let r15 = getSystemKeyboardHeight();
|
|
if (r15 === 0) {
|
|
r15 = getKeyboardType() !== KeyboardTypes.SYSTEM ? getCustomKeyboardHeight() : 0;
|
|
}
|
|
const current = r5.max(0, r15 + c14956_2);
|
|
if (ref.current !== current) {
|
|
ref.current = current;
|
|
setState(current);
|
|
}
|
|
}), [keyboardHeightOffset]);
|
|
ref2 = useRef(false);
|
|
useEffect(() => {
|
|
if (ref2.current) {
|
|
const keyboardDuration = getKeyboardDuration();
|
|
if (c14956_1 && keyboardDuration > 0) {
|
|
DeprecatedLayoutAnimationKeyboard(keyboardDuration);
|
|
}
|
|
} else {
|
|
ref2.current = true;
|
|
}
|
|
}, [animated, state]);
|
|
return <View style={useMemo(() => {
|
|
if (style == null) {
|
|
return {
|
|
marginBottom: state
|
|
};
|
|
}
|
|
const r9 = StyleSheet.flatten(style);
|
|
return typeof r9.marginBottom === "number" ? {
|
|
...r9,
|
|
marginBottom: r9.marginBottom + state
|
|
} : {
|
|
...r9,
|
|
marginBottom: state
|
|
};
|
|
}, [state, style])} pointerEvents={pointerEvents}>{children}</View>;
|
|
});
|
|
export default r28;
|