Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/added foundation components (2) #15

Merged
merged 7 commits into from
Mar 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(foundation): position of keyboard avoided modal is incorrect when…
… orientation is changed on android
  • Loading branch information
bang9 committed Mar 3, 2022
commit b63ce2c69eb36d3b8207009d83794d1912badfe2
6 changes: 6 additions & 0 deletions packages/uikit-react-native-foundation/src/ui/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StyleSheet,
TouchableWithoutFeedback,
ViewStyle,
useWindowDimensions,
} from 'react-native';

import createStyleSheet from '../../styles/createStyleSheet';
Expand Down Expand Up @@ -54,6 +55,8 @@ const Modal: React.FC<Props> = ({
const showAction = () => setModalVisible(true);
const hideAction = () => hideTransition(() => setModalVisible(false));

const { width, height } = useWindowDimensions();

useEffect(() => {
if (visible) showAction();
else hideAction();
Expand All @@ -79,6 +82,9 @@ const Modal: React.FC<Props> = ({
/>
</TouchableWithoutFeedback>
<KeyboardAvoidingView
// NOTE: This is trick for Android.
// When orientation is changed on Android, the offset is not updated normally.
key={`${width}-${height}`}
enabled={enableKeyboardAvoid}
style={styles.background}
behavior={Platform.select({ ios: 'padding', default: 'height' })}
Expand Down