Files
notesnook/apps/mobile/src/components/Dialog/BaseDialog.js

77 lines
1.5 KiB
JavaScript
Raw Normal View History

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,
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
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}>
2020-11-17 20:17:50 +05:00
<SafeAreaView>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : null}
style={[
{
backgroundColor: state.colors.night
? 'rgba(255,255,255,0.15)'
: 'rgba(0,0,0,0.3)',
},
styles.backdrop,
]}>
<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;