Skip to content

Commit

Permalink
add function goToBarcodeScanner and goToCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoOTdC committed Aug 19, 2020
1 parent c7e95ec commit ef6861b
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/screens/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ export default function index({ route, navigation }) {
Alert.alert(message);
}

function goToBarcodeScanner() {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeUrl());
dispatch(removeNameOfProduct());
navigation.navigate("BarcodeScanner");
}

function goToCamera() {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeUrl());
dispatch(removeNameOfProduct());
navigation.navigate("Camera");
}

return (
<View
style={{
Expand Down Expand Up @@ -128,33 +144,19 @@ export default function index({ route, navigation }) {
title="TRY AGAIN"
onPress={() => {
if (nameOfProduct) {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeUrl());
dispatch(removeNameOfProduct());
navigation.navigate("BarcodeScanner");
goToBarcodeScanner();
} else {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeMessage());
navigation.navigate("Camera");
goToCamera();
}
}}
/>
<Button
title={nameOfProduct ? "Try Camera" : "Try Barcode Scanner"}
onPress={() => {
if (nameOfProduct) {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeUrl());
dispatch(removeNameOfProduct());
navigation.navigate("Camera");
goToCamera();
} else {
setFoodLabel("");
dispatch(removeLabels());
dispatch(removeMessage());
navigation.navigate("BarcodeScanner");
goToBarcodeScanner();
}
}}
/>
Expand Down

0 comments on commit ef6861b

Please sign in to comment.