Browse Source

adding description field to pluviometer form screen

master
analuizaff 4 years ago
parent
commit
246ce762d6
  1. 1
      src/app/components/forms/FormImagePicker.js
  2. 1
      src/app/config/colors.js
  3. 5
      src/app/database/databaseLoader.js
  4. 3
      src/app/database/db.js
  5. 18
      src/app/screens/PluviometerSharingDataScreen.js

1
src/app/components/forms/FormImagePicker.js

@ -24,7 +24,6 @@ function FormImagePicker({ name }) {
return ( return (
<View> <View>
<Text style={styles.labelStyle}>Imagens: </Text>
<ImageInputList <ImageInputList
imageUris={imageUris} imageUris={imageUris}
onAddImage={handleAdd} onAddImage={handleAdd}

1
src/app/config/colors.js

@ -10,4 +10,5 @@ export default {
lightGray: "#C4C4C4", lightGray: "#C4C4C4",
gray: "gray", gray: "gray",
lightestGray: "#F0F0F0", lightestGray: "#F0F0F0",
lightBlue:"#1976D2"
}; };

5
src/app/database/databaseLoader.js

@ -39,8 +39,8 @@ function insertFloodZone({ images, description, passable, location, date, time,
transaction(global.userDataBase, query, values); transaction(global.userDataBase, query, values);
} }
function insertPluviometerData({ pluviometer, images, dateTime, time, location, address }) {
const query = `INSERT INTO Pluviometer(Date, Images, Latitude, Longitude, Precipitation, Address) VALUES(?, ?, ?, ?, ?, ?);`;
function insertPluviometerData({ pluviometer, description, images, dateTime, time, location, address }) {
const query = `INSERT INTO Pluviometer(Date, Images, Latitude, Longitude, Precipitation, Address, Description) VALUES(?, ?, ?, ?, ?, ?, ?);`;
if (location === undefined) { if (location === undefined) {
console.debug("undefined location"); console.debug("undefined location");
@ -54,6 +54,7 @@ function insertPluviometerData({ pluviometer, images, dateTime, time, location,
parseFloat(location["longitude"]), parseFloat(location["longitude"]),
parseFloat(pluviometer), parseFloat(pluviometer),
address, address,
description,
]; ];
transaction(global.userDataBase, query, values); transaction(global.userDataBase, query, values);

3
src/app/database/db.js

@ -20,7 +20,8 @@ const init_queries = [
Longitude real NOT NULL, Longitude real NOT NULL,
Precipitation real NOT NULL, Precipitation real NOT NULL,
Time text, Time text,
Address text
Address text,
Description text
);`, );`,
`CREATE TABLE IF NOT EXISTS RainLevel ( `CREATE TABLE IF NOT EXISTS RainLevel (
Id integer PRIMARY KEY autoincrement, Id integer PRIMARY KEY autoincrement,

18
src/app/screens/PluviometerSharingDataScreen.js

@ -30,11 +30,14 @@ const validationSchema = Yup.object().shape({
.label("pluviometer"), .label("pluviometer"),
//data: Yup.string().required("Campo obrigatório. Por favor, selecione a data"), //data: Yup.string().required("Campo obrigatório. Por favor, selecione a data"),
images: Yup.array(), images: Yup.array(),
description: Yup.string().label("Description"),
}); });
function PluviometerSharingDataScreen(props) { function PluviometerSharingDataScreen(props) {
const context = useContext(EventLocationContext); const context = useContext(EventLocationContext);
const amount = 2;
useEffect(() => { useEffect(() => {
context.defaultLocation(); context.defaultLocation();
}, []); }, []);
@ -51,6 +54,7 @@ function PluviometerSharingDataScreen(props) {
initialValues={{ initialValues={{
pluviometer: "", pluviometer: "",
images: [], images: [],
description: "",
}} }}
onSubmit={(values) => { onSubmit={(values) => {
insertPluviometerData({ ...values, dateTime, time, location, address }); insertPluviometerData({ ...values, dateTime, time, location, address });
@ -85,7 +89,7 @@ function PluviometerSharingDataScreen(props) {
flex: 1, flex: 1,
flexDirection: "row", flexDirection: "row",
justifyContent: "space-between", justifyContent: "space-between",
alignContent:"flex-start",
alignContent: "flex-start",
}} }}
> >
{/*Data da coleta:*/} {/*Data da coleta:*/}
@ -115,7 +119,15 @@ function PluviometerSharingDataScreen(props) {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
<View>
<FormField
maxLength={255}
multiline
name="description"
numberOfLines={3}
placeholder="Descrição"
/>
</View>
<SubmitButton title="Enviar" style={{ marginBottom: 100 }} /> <SubmitButton title="Enviar" style={{ marginBottom: 100 }} />
<View style={{ flex: 1 }}></View> <View style={{ flex: 1 }}></View>
</Form> </Form>
@ -139,7 +151,7 @@ const styles = StyleSheet.create({
fontSize: dimensions.text.secondary, fontSize: dimensions.text.secondary,
fontWeight: "bold", fontWeight: "bold",
textAlign: "left", textAlign: "left",
color: colors.primary,
color: colors.lightBlue,
marginBottom: 5, marginBottom: 5,
}, },
}); });

Loading…
Cancel
Save