|
|
@ -1,56 +1,55 @@ |
|
|
|
import React, { useState } from "react"; |
|
|
|
import { Button, StyleSheet, View } from "react-native"; |
|
|
|
import { StyleSheet, View } from "react-native"; |
|
|
|
import * as Yup from "yup"; |
|
|
|
|
|
|
|
import { |
|
|
|
Form, |
|
|
|
FormField, |
|
|
|
FormPicker as Picker, |
|
|
|
SubmitButton, |
|
|
|
} from "../components/forms"; |
|
|
|
import CategoryPickerItem from "../components/CategoryPickerItem"; |
|
|
|
import { Form, FormPicker as Picker, SubmitButton } from "../components/forms"; |
|
|
|
import Screen from "../components/Screen"; |
|
|
|
import FormImagePicker from "../components/forms/FormImagePicker"; |
|
|
|
import useLocation from "../hooks/useLocation"; |
|
|
|
import { Image, Text, TouchableOpacity } from "react-native"; |
|
|
|
import { Image, Text } from "react-native"; |
|
|
|
import colors from "../config/colors"; |
|
|
|
import { TouchableNativeFeedback } from "react-native-gesture-handler"; |
|
|
|
import { insertRiverData } from "../database/databaseLoader"; |
|
|
|
|
|
|
|
const validationSchema = Yup.object().shape({ |
|
|
|
images: Yup.array().min(1, "Por favor, selecione ao menos uma imagem"), |
|
|
|
description: Yup.string() |
|
|
|
.label("Description") |
|
|
|
.required("Por favor, forneça uma descrição"), |
|
|
|
}); |
|
|
|
|
|
|
|
const borderWidth = 4; |
|
|
|
|
|
|
|
function RiverFloodSharingDataScreen() { |
|
|
|
const [passable, setPassable] = useState(0); |
|
|
|
const [riverScale, setRiverScale] = useState(0); |
|
|
|
const location = useLocation(); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Screen style={styles.container}> |
|
|
|
<Text style={{ fontSize: 18, fontWeight: 'bold', color: '#1976D2', textAlign: 'center', marginBottom: 30 }}> |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
fontSize: 18, |
|
|
|
fontWeight: "bold", |
|
|
|
color: "#1976D2", |
|
|
|
textAlign: "center", |
|
|
|
marginBottom: 30, |
|
|
|
}} |
|
|
|
> |
|
|
|
Nível da água do rio |
|
|
|
</Text> |
|
|
|
<Form |
|
|
|
initialValues={{ |
|
|
|
title: "", |
|
|
|
price: "", |
|
|
|
description: "", |
|
|
|
category: null, |
|
|
|
images: [], |
|
|
|
}} |
|
|
|
onSubmit={(values) => submitForm({ ...values, passable, location })} |
|
|
|
onSubmit={(values) => |
|
|
|
insertRiverData({ ...values, riverScale, location }) |
|
|
|
} |
|
|
|
validationSchema={validationSchema} |
|
|
|
> |
|
|
|
<View> |
|
|
|
<View |
|
|
|
style={{ flexDirection: "row", justifyContent: "space-around" }} |
|
|
|
> |
|
|
|
<TouchableNativeFeedback onPress={() => setPassable(0)}> |
|
|
|
<TouchableNativeFeedback onPress={() => setRiverScale(0)}> |
|
|
|
<View |
|
|
|
borderWidth={passable == 0 ? borderWidth : 0} |
|
|
|
borderWidth={riverScale == 0 ? borderWidth : 0} |
|
|
|
style={styles.img_block} |
|
|
|
> |
|
|
|
<Image |
|
|
@ -61,9 +60,9 @@ function RiverFloodSharingDataScreen() { |
|
|
|
</View> |
|
|
|
</TouchableNativeFeedback> |
|
|
|
|
|
|
|
<TouchableNativeFeedback onPress={() => setPassable(1)}> |
|
|
|
<TouchableNativeFeedback onPress={() => setRiverScale(1)}> |
|
|
|
<View |
|
|
|
borderWidth={passable == 1 ? borderWidth : 0} |
|
|
|
borderWidth={riverScale == 1 ? borderWidth : 0} |
|
|
|
style={styles.img_block} |
|
|
|
> |
|
|
|
<Image |
|
|
@ -78,9 +77,9 @@ function RiverFloodSharingDataScreen() { |
|
|
|
<View |
|
|
|
style={{ flexDirection: "row", justifyContent: "space-around" }} |
|
|
|
> |
|
|
|
<TouchableNativeFeedback onPress={() => setPassable(2)}> |
|
|
|
<TouchableNativeFeedback onPress={() => setRiverScale(2)}> |
|
|
|
<View |
|
|
|
borderWidth={passable == 2 ? borderWidth : 0} |
|
|
|
borderWidth={riverScale == 2 ? borderWidth : 0} |
|
|
|
style={styles.img_block} |
|
|
|
> |
|
|
|
<Image |
|
|
@ -91,9 +90,9 @@ function RiverFloodSharingDataScreen() { |
|
|
|
</View> |
|
|
|
</TouchableNativeFeedback> |
|
|
|
|
|
|
|
<TouchableNativeFeedback onPress={() => setPassable(3)}> |
|
|
|
<TouchableNativeFeedback onPress={() => setRiverScale(3)}> |
|
|
|
<View |
|
|
|
borderWidth={passable == 3 ? borderWidth : 0} |
|
|
|
borderWidth={riverScale == 3 ? borderWidth : 0} |
|
|
|
style={styles.img_block} |
|
|
|
> |
|
|
|
<Image |
|
|
@ -123,7 +122,7 @@ const styles = StyleSheet.create({ |
|
|
|
borderStyle: "dotted", |
|
|
|
borderColor: colors.primary, |
|
|
|
alignItems: "center", |
|
|
|
width:130, |
|
|
|
width: 130, |
|
|
|
}, |
|
|
|
floodingLogo: { |
|
|
|
width: 85, |
|
|
|