Browse Source

Going back 1 level in navigation stack when some data is inserted

master
GabrielTrettel 4 years ago
parent
commit
e4ef1e4eb6
  1. 7
      src/app/screens/PluviometerSharingDataScreen.js
  2. 5
      src/app/screens/RainSharingDataScreen.js
  3. 15
      src/app/screens/RiverFloodSharingDataScreen.js
  4. 5
      src/app/screens/SharingFloodZonesScreen.js

7
src/app/screens/PluviometerSharingDataScreen.js

@ -48,9 +48,10 @@ function PluviometerSharingDataScreen() {
pluviometer: "", pluviometer: "",
images: [], images: [],
}} }}
onSubmit={(values) =>
insertPluviometerData({ ...values, date, location })
}
onSubmit={(values) => {
insertPluviometerData({ ...values, date, location });
props.navigation.goBack(null);
}}
validationSchema={validationSchema} validationSchema={validationSchema}
> >
<View style={{ marginTop: 30 }}> <View style={{ marginTop: 30 }}>

5
src/app/screens/RainSharingDataScreen.js

@ -44,7 +44,10 @@ function RainSharingDataScreen() {
initialValues={{ initialValues={{
images: [], images: [],
}} }}
onSubmit={(values) => insertRainData({ ...values, rain, location })}
onSubmit={(values) => {
insertRainData({ ...values, rain, location });
props.navigation.goBack(null);
}}
validationSchema={validationSchema} validationSchema={validationSchema}
> >
<View> <View>

15
src/app/screens/RiverFloodSharingDataScreen.js

@ -17,7 +17,7 @@ const validationSchema = Yup.object().shape({
const borderWidth = 4; const borderWidth = 4;
function RiverFloodSharingDataScreen() {
function RiverFloodSharingDataScreen(props) {
const [riverScale, setRiverScale] = useState(0); const [riverScale, setRiverScale] = useState(0);
const location = useLocation(); const location = useLocation();
@ -38,9 +38,10 @@ function RiverFloodSharingDataScreen() {
initialValues={{ initialValues={{
images: [], images: [],
}} }}
onSubmit={(values) =>
insertRiverData({ ...values, riverScale, location })
}
onSubmit={(values) => {
insertRiverData({ ...values, riverScale, location });
props.navigation.goBack(null);
}}
validationSchema={validationSchema} validationSchema={validationSchema}
> >
<View> <View>
@ -106,7 +107,11 @@ function RiverFloodSharingDataScreen() {
</View> </View>
<FormImagePicker backgroundColor="#1976D2" name="images" /> <FormImagePicker backgroundColor="#1976D2" name="images" />
<SubmitButton title="Enviar" backgroundColor={colors.primary} />
<SubmitButton
title="Enviar"
backgroundColor={colors.primary}
onPress={() => props.navigation.pop()}
/>
</Form> </Form>
</Screen> </Screen>
); );

5
src/app/screens/SharingFloodZonesScreen.js

@ -54,7 +54,10 @@ function SharingFloodZonesScreen() {
images: [], images: [],
description: "", description: "",
}} }}
onSubmit={(values) => submitForm({ ...values, passable, location })}
onSubmit={(values) => {
submitForm({ ...values, passable, location });
props.navigation.goBack(null);
}}
validationSchema={validationSchema} validationSchema={validationSchema}
> >
<View style={styles.imgs_container}> <View style={styles.imgs_container}>

Loading…
Cancel
Save