react-native-keyboard-controller
Version:
Keyboard manager which works in identical way on both iOS and Android
41 lines • 1.14 kB
JavaScript
import React, { useMemo } from "react";
import { Platform, StyleSheet, View } from "react-native";
import { RCTOverKeyboardView } from "../../bindings";
import { useWindowDimensions } from "../../hooks";
const OverKeyboardView = ({
children,
visible
}) => {
const {
height,
width
} = useWindowDimensions();
const inner = useMemo(() => ({
height,
width
}), [height, width]);
const style = useMemo(() => [styles.absolute,
// On iOS - stretch view to full window dimensions to make yoga work
Platform.OS === "ios" ? inner : undefined,
// On Android - we are laid out by ShadowNode, so just stretch to full container
Platform.OS === "android" ? styles.stretch : undefined], [inner]);
return /*#__PURE__*/React.createElement(RCTOverKeyboardView, {
visible: visible
}, /*#__PURE__*/React.createElement(View, {
collapsable: false,
style: style
}, visible && children));
};
const styles = StyleSheet.create({
absolute: {
position: "absolute"
},
stretch: {
top: 0,
bottom: 0,
left: 0,
right: 0
}
});
export default OverKeyboardView;
//# sourceMappingURL=index.js.map