Created
March 17, 2023 19:33
-
-
Save terrysahaidak/e732c6ea5df748dfb2b66e0adbdd6e45 to your computer and use it in GitHub Desktop.
This file contains 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
const KeyboardAvoidingView = (props) => { | |
const behavior = props.behavior; | |
const keyboard = useAnimatedKeyboard(); | |
const insets = useSafeAreaInsets(); | |
const animatedStyle = useAnimatedStyle(() => { | |
const value = keyboard.height.value - insets.bottom; | |
if (behavior === 'height') { | |
return { | |
height: value, | |
flex: 0, | |
}; | |
} | |
if (behavior === 'padding') { | |
return { | |
paddingBottom: value, | |
}; | |
} | |
if (behavior === 'position') { | |
return { | |
bottom: value, | |
}; | |
} | |
return { | |
}; | |
}); | |
return ( | |
<Reanimated.View style={StyleSheet.compose(props.style, animatedStyle)}> | |
{props.children} | |
</Reanimated.View> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment