2020-09-27 13:05:26 +05:00
|
|
|
import React from 'react';
|
2020-09-30 15:58:19 +05:00
|
|
|
import {
|
|
|
|
|
Animated,
|
2020-11-17 20:17:50 +05:00
|
|
|
KeyboardAvoidingView,
|
2020-09-30 15:58:19 +05:00
|
|
|
Modal,
|
2020-11-17 20:17:50 +05:00
|
|
|
Platform,
|
|
|
|
|
SafeAreaView,
|
2020-09-30 15:58:19 +05:00
|
|
|
StyleSheet,
|
|
|
|
|
TouchableOpacity,
|
|
|
|
|
View,
|
|
|
|
|
} from 'react-native';
|
2020-09-27 13:05:26 +05:00
|
|
|
import {useTracked} from '../../provider';
|
|
|
|
|
|
2020-09-30 15:58:19 +05:00
|
|
|
const BaseDialog = ({
|
|
|
|
|
visible,
|
|
|
|
|
onRequestClose,
|
|
|
|
|
children,
|
|
|
|
|
onShow,
|
|
|
|
|
animation = 'fade',
|
2020-11-17 20:17:50 +05:00
|
|
|
premium,
|
2021-01-14 18:58:29 +05:00
|
|
|
statusBarTranslucent = true,
|
|
|
|
|
transparent,
|
2021-04-06 13:26:26 +05:00
|
|
|
centered=true
|
2020-09-30 15:58:19 +05:00
|
|
|
}) => {
|
2020-09-27 13:05:26 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
2020-09-30 15:58:19 +05:00
|
|
|
const scaleValue = new Animated.Value(1);
|
|
|
|
|
|
2020-09-27 13:05:26 +05:00
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
visible={visible}
|
|
|
|
|
transparent={true}
|
|
|
|
|
animated
|
2020-11-25 11:46:44 +05:00
|
|
|
statusBarTranslucent={statusBarTranslucent}
|
2020-09-30 15:58:19 +05:00
|
|
|
onShow={() => {
|
|
|
|
|
if (onShow) {
|
|
|
|
|
onShow();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
animationType={animation}
|
2020-09-27 13:05:26 +05:00
|
|
|
onRequestClose={onRequestClose}>
|
2021-04-08 10:27:47 +05:00
|
|
|
<SafeAreaView
|
|
|
|
|
style={ {
|
|
|
|
|
backgroundColor: transparent
|
|
|
|
|
? 'transparent'
|
|
|
|
|
: state.colors.night
|
|
|
|
|
? 'rgba(255,255,255,0.15)'
|
|
|
|
|
: 'rgba(0,0,0,0.3)',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2020-11-17 20:17:50 +05:00
|
|
|
<KeyboardAvoidingView
|
|
|
|
|
behavior={Platform.OS === 'ios' ? 'padding' : null}
|
|
|
|
|
style={[
|
|
|
|
|
styles.backdrop,
|
2021-04-06 13:26:26 +05:00
|
|
|
{
|
|
|
|
|
justifyContent:centered? "center" : "flex-start"
|
|
|
|
|
}
|
2020-11-17 20:17:50 +05:00
|
|
|
]}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={onRequestClose}
|
|
|
|
|
style={styles.overlayButton}
|
|
|
|
|
/>
|
|
|
|
|
{premium}
|
2020-09-30 15:58:19 +05:00
|
|
|
|
2020-11-17 20:17:50 +05:00
|
|
|
{children}
|
|
|
|
|
</KeyboardAvoidingView>
|
|
|
|
|
</SafeAreaView>
|
2020-09-27 13:05:26 +05:00
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
backdrop: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
},
|
|
|
|
|
overlayButton: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default BaseDialog;
|