From 52de8f3b4bcd00e4294621027c410382824c50ef Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Thu, 7 Oct 2021 22:02:58 -0300 Subject: [PATCH] Initial implementation of ConfirmationModal in AccountScreen --- src/app/components/ConfirmationModal.js | 96 +++++++++++++++++++++++++ src/app/screens/AccountScreen.js | 41 +++++++---- 2 files changed, 123 insertions(+), 14 deletions(-) create mode 100644 src/app/components/ConfirmationModal.js diff --git a/src/app/components/ConfirmationModal.js b/src/app/components/ConfirmationModal.js new file mode 100644 index 0000000..c8cfd66 --- /dev/null +++ b/src/app/components/ConfirmationModal.js @@ -0,0 +1,96 @@ +import React from "react"; +import { + Modal, + StyleSheet, + Text, + TouchableHighlight, + View, +} from "react-native"; + +import { MaterialCommunityIcons } from "@expo/vector-icons"; +import colors from "../config/colors"; +import { dimensions } from "../config/dimensions"; +import { TouchableOpacity } from "react-native-gesture-handler"; + +function Btn({ label, onPress, bgColor, txtColor }) { + return ( + onPress()}> + + {label} + + + ); +} + +export default function ConfirmationModal({ + show, + title = "", + description = "", + confirmationLabel = "", + declineLabel = "", + onConfirm = () => {}, + onDecline = () => {}, +}) { + console.log("show: " + show); + return ( + + + + + {title} + + + {description} + + + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + width: "80%", + height: 150, + justifyContent: "center", + alignSelf: "center", + backgroundColor: colors.lightestGray, + borderColor: colors.primary, + borderWidth: 2, + borderRadius: 12, + padding: 12, + }, + text: { + fontSize: dimensions.text.default, + textAlign: "left", + fontWeight: "bold", + }, +}); diff --git a/src/app/screens/AccountScreen.js b/src/app/screens/AccountScreen.js index aa2ab7f..83f1fd9 100644 --- a/src/app/screens/AccountScreen.js +++ b/src/app/screens/AccountScreen.js @@ -1,4 +1,4 @@ -import React, { useContext } from "react"; +import React, { useContext, useState } from "react"; import { Text, Image, View, StyleSheet, ScrollView } from "react-native"; import Screen from "../components/Screen"; import { AuthContext } from "../auth/context"; @@ -7,11 +7,8 @@ import { TouchableOpacity } from "react-native-gesture-handler"; import assets from "../config/assets"; import { MaterialCommunityIcons, FontAwesome } from "@expo/vector-icons"; import colors from "../config/colors"; +import ConfirmationModal from "../components/ConfirmationModal"; -function handleLogOut(setUser) { - setUser(null); - authStorage.removeToken(); -} function UserHeader({ name, fone }) { return ( @@ -77,6 +74,13 @@ function ProfileItensList({ icon, IconProvider, title, onPress }) { function AccountScreen(props) { const { user, setUser } = useContext(AuthContext); + const [ showLog, setShowLog ] = useState(false); + + const logout = () => { + setUser(null); + authStorage.removeToken(); + }; + const profileItems = [ { icon: "account", @@ -123,17 +127,17 @@ function AccountScreen(props) { IconProvider: MaterialCommunityIcons, title: "sair", onPress: () => { - handleLogOut(setUser); - }, - }, - { - icon: "trash-can", - IconProvider: MaterialCommunityIcons, - title: "DESATIVAR CONTA", - onPress: () => { - console.log("7"); + setShowLog(true) }, }, + // { + // icon: "trash-can", + // IconProvider: MaterialCommunityIcons, + // title: "DESATIVAR CONTA", + // onPress: () => { + // console.log("7"); + // }, + // }, ]; return ( @@ -158,6 +162,15 @@ function AccountScreen(props) { ))} + setShowLog(false)} + />