Browse Source

Merge branch 'main' of github.com:IGSD-UoW/WPD-MobileApp

master
GabrielTrettel 4 years ago
parent
commit
f9fe24c481
  1. 6
      src/app/components/Button.js
  2. 1
      src/app/components/forms/FormImagePicker.js
  3. 1
      src/app/config/colors.js
  4. 5
      src/app/database/databaseLoader.js
  5. 3
      src/app/database/db.js
  6. 20
      src/app/screens/PluviometerSharingDataScreen.js

6
src/app/components/Button.js

@ -3,7 +3,7 @@ import { StyleSheet, Text, TouchableOpacity } from "react-native";
import colors from "../config/colors"; import colors from "../config/colors";
function AppButton({ title, onPress, color = "primary" }) {
function AppButton({ title, onPress, color = "lightBlue" }) {
return ( return (
<TouchableOpacity <TouchableOpacity
style={[styles.button, { backgroundColor: colors[color] }]} style={[styles.button, { backgroundColor: colors[color] }]}
@ -16,8 +16,8 @@ function AppButton({ title, onPress, color = "primary" }) {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
button: { button: {
backgroundColor: colors.primary,
borderRadius: 6,
backgroundColor: colors.lightBlue,
borderRadius: 20,
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
width: "100%", width: "100%",

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,

20
src/app/screens/PluviometerSharingDataScreen.js

@ -30,16 +30,19 @@ 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();
}, []); }, []);
const location = context.eventCoordinates; const location = context.eventCoordinates;
const address = context.eventLocation;
const address = context.eventLocation;
const [dateTime, setDateTime] = useState(moment()); const [dateTime, setDateTime] = useState(moment());
const [time, setTime] = useState(moment()); const [time, setTime] = useState(moment());
@ -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