Created
December 29, 2022 12:02
-
-
Save felippepuhle/fd9d73da5d43930e40e42080b20895ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useHeaderHeight } from "@react-navigation/elements"; | |
import { | |
KeyboardAvoidingView as RNKeyboardAvoidingView, | |
KeyboardAvoidingViewProps as RNKeyboardAvoidingViewProps, | |
Platform, | |
StyleSheet, | |
} from 'react-native'; | |
const BEHAVIOR = Platform.OS === 'ios' ? 'padding' : undefined; | |
const KeyboardAvoidingView = ({ style, ...props }: RNKeyboardAvoidingViewProps) => { | |
const headerHeight = useHeaderHeight(); | |
return ( | |
<RNKeyboardAvoidingView | |
style={[styles.container, style]} | |
behavior={BEHAVIOR} | |
keyboardVerticalOffset={headerHeight} | |
{...props} | |
/> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
}, | |
}); | |
export default KeyboardAvoidingView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment