Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

BootstrapModal.jsx 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { useState } from 'react';
  2. import {
  3. Modal,
  4. View,
  5. Text,
  6. Pressable,
  7. StyleSheet,
  8. TouchableWithoutFeedback
  9. } from 'react-native';
  10. const BootstrapModal = ({ visible, setVisible }) => {
  11. return (
  12. <Modal
  13. transparent
  14. animationType="fade"
  15. visible={visible}
  16. onRequestClose={() => setVisible(false)}
  17. >
  18. <TouchableWithoutFeedback onPress={() => setVisible(false)}>
  19. <View style={styles.backdrop} />
  20. </TouchableWithoutFeedback>
  21. <View style={styles.centeredView}>
  22. <View style={styles.modalView}>
  23. <Text style={styles.modalText}>This is a Bootstrap-like Modal!</Text>
  24. <Pressable
  25. style={[styles.button, styles.buttonClose]}
  26. onPress={() => setVisible(false)}
  27. >
  28. <Text style={styles.textStyle}>Close</Text>
  29. </Pressable>
  30. </View>
  31. </View>
  32. </Modal>
  33. );
  34. };
  35. const styles = StyleSheet.create({
  36. centeredView: {
  37. flex: 1,
  38. justifyContent: 'center',
  39. alignItems: 'center',
  40. zIndex: 10,
  41. },
  42. backdrop: {
  43. ...StyleSheet.absoluteFillObject,
  44. backgroundColor: 'rgba(0,0,0,0.5)',
  45. },
  46. modalView: {
  47. width: '80%',
  48. backgroundColor: 'white',
  49. borderRadius: 12,
  50. padding: 20,
  51. alignItems: 'center',
  52. shadowColor: '#000',
  53. shadowOpacity: 0.3,
  54. shadowRadius: 4,
  55. elevation: 5,
  56. },
  57. openButton: {
  58. backgroundColor: '#007bff',
  59. borderRadius: 6,
  60. padding: 10,
  61. elevation: 2,
  62. },
  63. button: {
  64. marginTop: 15,
  65. padding: 10,
  66. borderRadius: 6,
  67. },
  68. buttonClose: {
  69. backgroundColor: '#dc3545',
  70. },
  71. textStyle: {
  72. color: 'white',
  73. fontWeight: '600',
  74. textAlign: 'center',
  75. },
  76. modalText: {
  77. fontSize: 18,
  78. textAlign: 'center',
  79. },
  80. });
  81. export default BootstrapModal;