import React, { useState } from "react"; import { Text, TouchableOpacity, View, StyleSheet, Image } from "react-native"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import SelfClosingModal from "../components/SelfClosingModal"; import colors from "../config/colors"; import { showMessage } from "react-native-flash-message"; import { dimensions, screen_height } from "../config/dimensions"; import { Svg, Image as ImageSvg } from "react-native-svg"; import { ScrollView } from "react-native-gesture-handler"; import PluviometerGraphics from "./PluviometerGraphics"; const chartHeight = screen_height * 0.3; /* NOTE: `Edit` and `Delete` icons behavior not implemented yet. * * Waiting for API handler to implement this functionality and avoid overwork */ function notImplemented() { showMessage({ message: "Comportamento ainda não implementado", duration: 1950, icon: "warning", type: "warning", }); } function topBar(props) { return ( notImplemented()} > notImplemented()} > props.setIsVisible(!props.isVisible)} > ); } function iconTextRow(props) { return ( {props.description} ); } function iconImageRow(props) { return ( ); } function reviews(props) { const [likes, setLikes] = useState(0); const [dislikes, setDislikes] = useState(0); const updateLikes = () => { setLikes(likes + 1); notImplemented(); }; const updatedislikes = () => { setDislikes(dislikes + 1); notImplemented(); }; return ( updatedislikes()}> {dislikes} { updateLikes(); }} > {likes} ); } function moreInfo() { return ( ); } function componentBody(props) { // NOTE: This code is refered to our local SQLite solution. Revise this when implement rest API. const pictures = JSON.parse(props.pictures); const date = props.date ? props.date : "implementando..."; const address = props.address ? props.address : "Erro ao carregar endereço"; return ( {props.title} {iconTextRow({ name: "map-marker", description: address })} {iconTextRow({ name: "calendar", description: date })} {iconTextRow({ name: "account", description: "Usuário ativo" })} {pictures.length > 0 && iconImageRow({ name: "camera", pic: pictures })} ); } function MapModal(props) { return ( {topBar(props)} {componentBody(props)} {props.name === "pluviometer" ? moreInfo(props) : null} {props.name !== "pluviometer" ? reviews(props) : null} ); } const styles = StyleSheet.create({ bodyRow: { flexDirection: "row", alignSelf: "flex-start", alignContent: "space-between", }, bodyTitle: { fontWeight: "700", fontSize: dimensions.text.secondary, marginBottom: 5, }, bodyInfo: { flexDirection: "column", alignContent: "flex-start", }, bodyIcon: { alignSelf: "flex-start", marginHorizontal: 20, height: 53, width: 53, }, reviewsContainer: { flexDirection: "row", alignSelf: "flex-end", margin: 10, }, review: { flexDirection: "row", alignSelf: "flex-end", alignContent: "space-around", marginHorizontal: 10, }, topBar: { flexDirection: "row", alignSelf: "flex-end", }, topBarIcon: { margin: 10, }, text: { fontWeight: "500", fontSize: dimensions.text.default, }, link: { alignSelf: "center", color: colors.lightBlue, fontWeight: "500", fontSize: dimensions.text.default, }, pluviometer_diary: { height: chartHeight * 1.4, paddingVertical: 20, }, }); export default MapModal;