From 37288fcbd220466780c3d85c0c4cf9b325392785 Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Wed, 24 Feb 2021 15:58:13 -0300 Subject: [PATCH] Closing MapModal when user clicks outside modal component. --- src/app/components/MapModal.js | 54 ++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/app/components/MapModal.js b/src/app/components/MapModal.js index e1c8682..617ffa0 100644 --- a/src/app/components/MapModal.js +++ b/src/app/components/MapModal.js @@ -1,8 +1,34 @@ import React, { Component } from "react"; -import { Modal, Text, TouchableOpacity, View, StyleSheet } from "react-native"; +import { + Modal, + Text, + TouchableOpacity, + View, + StyleSheet, + TouchableWithoutFeedback, +} from "react-native"; import { screen_height, screen_width } from "../config/dimensions"; -function MapModal({ isVisible, setIsVisible }) { +function modalContent(isVisible, setIsVisible) { + return ( + { + setIsVisible(!isVisible); + }} + > + Hide Modal + + ); +} + +function MapModal({ + isVisible, + setIsVisible, + title, + description, + icon, + pictures, +}) { console.log(screen_width); return ( @@ -14,19 +40,13 @@ function MapModal({ isVisible, setIsVisible }) { alert("Modal has been closed."); }} > + setIsVisible(!isVisible)}> + + + - - Hello World! - - { - setIsVisible(!isVisible); - }} - > - Hide Modal - - + {modalContent(isVisible, setIsVisible)} @@ -60,6 +80,14 @@ const styles = StyleSheet.create({ shadowRadius: 4, elevation: 5, }, + modalOverlay: { + position: "absolute", + top: 0, + bottom: 0, + left: 0, + right: 0, + backgroundColor: "rgba(0,0,0,0)", + }, }); export default MapModal;