fix: Add height verification to fix modal dimension (#3573)

This commit is contained in:
Gleidson Daniel Silva 2022-01-11 11:35:06 -03:00 committed by GitHub
parent 8d2226c279
commit 0eb862abdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 9 deletions

View File

@ -1,5 +1,5 @@
import React from 'react';
import { StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
import { StyleSheet, TouchableWithoutFeedback, useWindowDimensions, View } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import { NavigationContainerProps } from '@react-navigation/core';
@ -23,11 +23,21 @@ const styles = StyleSheet.create({
}
});
export const ModalContainer = ({ navigation, children, theme }: IModalContainer): JSX.Element => (
<View style={[styles.root, { backgroundColor: `${themes[theme].backdropColor}70` }]}>
<TouchableWithoutFeedback onPress={() => navigation.pop()}>
<View style={styles.backdrop} />
</TouchableWithoutFeedback>
<View style={sharedStyles.modalFormSheet}>{children}</View>
</View>
);
export const ModalContainer = ({ navigation, children, theme }: IModalContainer): JSX.Element => {
const { height } = useWindowDimensions();
const modalHeight = sharedStyles.modalFormSheet.height;
return (
<View style={[styles.root, { backgroundColor: `${themes[theme].backdropColor}70` }]}>
<TouchableWithoutFeedback onPress={() => navigation.pop()}>
<View style={styles.backdrop} />
</TouchableWithoutFeedback>
<View
style={{
...sharedStyles.modalFormSheet,
height: modalHeight > height ? height : modalHeight
}}>
{children}
</View>
</View>
);
};