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. 20
      src/app/screens/PluviometerSharingDataScreen.js

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

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

1
src/app/config/colors.js

@ -10,4 +10,5 @@ export default {
lightGray: "#C4C4C4",
gray: "gray",
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);
}
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) {
console.debug("undefined location");
@ -54,6 +54,7 @@ function insertPluviometerData({ pluviometer, images, dateTime, time, location,
parseFloat(location["longitude"]),
parseFloat(pluviometer),
address,
description,
];
transaction(global.userDataBase, query, values);

3
src/app/database/db.js

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

20
src/app/screens/PluviometerSharingDataScreen.js

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

Loading…
Cancel
Save