1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import React, { useState } from 'react';
- import {
- Modal,
- View,
- Text,
- Pressable,
- StyleSheet,
- TouchableWithoutFeedback
- } from 'react-native';
-
- const BootstrapModal = ({ visible, setVisible }) => {
-
- return (
- <Modal
- transparent
- animationType="fade"
- visible={visible}
- onRequestClose={() => setVisible(false)}
- >
- <TouchableWithoutFeedback onPress={() => setVisible(false)}>
- <View style={styles.backdrop} />
- </TouchableWithoutFeedback>
-
- <View style={styles.centeredView}>
- <View style={styles.modalView}>
- <Text style={styles.modalText}>This is a Bootstrap-like Modal!</Text>
- <Pressable
- style={[styles.button, styles.buttonClose]}
- onPress={() => setVisible(false)}
- >
- <Text style={styles.textStyle}>Close</Text>
- </Pressable>
- </View>
- </View>
- </Modal>
- );
- };
-
- const styles = StyleSheet.create({
- centeredView: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- zIndex: 10,
- },
- backdrop: {
- ...StyleSheet.absoluteFillObject,
- backgroundColor: 'rgba(0,0,0,0.5)',
- },
- modalView: {
- width: '80%',
- backgroundColor: 'white',
- borderRadius: 12,
- padding: 20,
- alignItems: 'center',
- shadowColor: '#000',
- shadowOpacity: 0.3,
- shadowRadius: 4,
- elevation: 5,
- },
- openButton: {
- backgroundColor: '#007bff',
- borderRadius: 6,
- padding: 10,
- elevation: 2,
- },
- button: {
- marginTop: 15,
- padding: 10,
- borderRadius: 6,
- },
- buttonClose: {
- backgroundColor: '#dc3545',
- },
- textStyle: {
- color: 'white',
- fontWeight: '600',
- textAlign: 'center',
- },
- modalText: {
- fontSize: 18,
- textAlign: 'center',
- },
- });
-
- export default BootstrapModal;
|