Skip to content

Commit

Permalink
Merge pull request #232 from anqi20/branch-release
Browse files Browse the repository at this point in the history
Branch release
  • Loading branch information
tsh22 authored Dec 22, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents d230593 + 1aa3a08 commit f53d67b
Showing 16 changed files with 163 additions and 85 deletions.
5 changes: 4 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -18,7 +18,10 @@
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.tsh22.gozerowaste"
"bundleIdentifier": "com.tsh22.gozerowaste",
"infoPlist": {
"NSCameraUsageDescription": "This app uses the camera to scan QR codes to allow users to borrow reusables and earn rewards from bringing their own reusables."
}
},
"android": {
"adaptiveIcon": {
79 changes: 41 additions & 38 deletions components/UnsuccessBox.js
Original file line number Diff line number Diff line change
@@ -10,48 +10,50 @@ export default function UnsuccessBox() {
const navigation = useNavigation();

return (
<View style={{paddingHorizontal: 40}}>
<View style={styles.box}>
<Image
source={require("../assets/AppImages/cross.png")}
style={{ alignSelf: "center", marginBottom: 10 }}
/>
<Text style={[styles.header, { marginBottom: 20 }]}>Oops!</Text>
<Text style={styles.warningText}>Oops, there seems to be an error!</Text>

<View style={styles.icons}>
<Icon
containerStyle={{ marginVertical: 15, marginRight: 80 }}
name="phone"
type="Feather"
color="#0CF574"
size={40}
/>
<Icon
containerStyle={{ marginVertical: 15 }}
name="email"
type="MaterialIcons"
color="#0CF574"
size={40}
<View style={{ paddingHorizontal: 40 }}>
<View style={styles.box}>
<Image
source={require("../assets/AppImages/cross.png")}
style={{ alignSelf: "center", marginBottom: 10 }}
/>
</View>
<Text style={[styles.header, { marginBottom: 20 }]}>Oops!</Text>
<Text style={styles.warningText}>
Oops, there seems to be an error!
</Text>

<FooterText />
<View style={styles.icons}>
<Icon
containerStyle={{ marginVertical: 15, marginRight: 80 }}
name="phone"
type="Feather"
color="#0CF574"
size={40}
/>
<Icon
containerStyle={{ marginVertical: 15 }}
name="email"
type="MaterialIcons"
color="#0CF574"
size={40}
/>
</View>

<Text style={styles.warningText}>
We apologise for the inconvenience!
</Text>
<FooterText />

<TouchableOpacity
style={[globalStyles.button, { width: "100%", alignSelf: "center" }]}
onPress={() => {
navigation.dispatch(StackActions.popToTop());
navigation.navigate("Home Screen");
}}
>
<Text style={globalStyles.buttonText}>Back</Text>
</TouchableOpacity>
</View>
<Text style={styles.warningText}>
We apologise for the inconvenience!
</Text>

<TouchableOpacity
style={[globalStyles.button, { width: "100%", alignSelf: "center" }]}
onPress={() => {
navigation.dispatch(StackActions.popToTop());
navigation.navigate("Home Screen");
}}
>
<Text style={globalStyles.buttonText}>Back</Text>
</TouchableOpacity>
</View>
</View>
);
}
@@ -71,6 +73,7 @@ const styles = StyleSheet.create({
paddingHorizontal: 20,
paddingVertical: 20,
justifyContent: "center",
marginBottom: 30,
},
warningText: {
fontSize: 18,
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
},
"dependencies": {
"@react-native-community/datetimepicker": "3.2.0",
"@react-native-community/hooks": "^2.8.1",
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/bottom-tabs": "^5.11.11",
"@react-navigation/native": "^5.9.4",
12 changes: 12 additions & 0 deletions screens/BasicApi.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import React from "react";
import { View, Text } from "react-native";
import firebase from "../database/firebaseDB";
import moment from "moment";
import { Alert, BackHandler } from "react-native";

// Get user's coins
export function getCoins(uid, setCoins) {
@@ -104,3 +105,14 @@ export function renderAllDates(dates) {
<Text></Text>;
}
}

export const backActionHandler = () => {
Alert.alert("Alert!", "Are you sure you want to exit app?", [
{
text: "Cancel",
onPress: () => null,
},
{ text: "YES", onPress: () => BackHandler.exitApp() },
]);
return true;
};
4 changes: 2 additions & 2 deletions screens/HomeStack.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ const Stack = createStackNavigator();

export default function HomeStack() {
return (
<Stack.Navigator>
<Stack.Navigator options={{ gestureEnabled: false }}>
<Stack.Screen
name="Home Screen"
component={HomeScreen}
@@ -25,7 +25,7 @@ export default function HomeStack() {
<Stack.Screen
name="BYO Stack"
component={BYOStack}
options={{ headerShown: false }}
options={{ headerShown: false, gestureEnabled: false }}
/>
{/* <Stack.Screen
name="Rewards Screen"
28 changes: 14 additions & 14 deletions screens/authentication-screens/ForgotPasswordScreen.js
Original file line number Diff line number Diff line change
@@ -20,11 +20,19 @@ import { AuthContext } from "../../assets/AuthContext";
export default function ForgotPasswordScreen({ navigation }) {
const { forgotPassword } = useContext(AuthContext);

let timeout;
const [email, setEmail] = useState("");
const [statusMsg, setStatusMsg] = useState("");
const [errorMsg, setErrorMsg] = useState("");
//const [time, setTime] = useState(null);
const [disabled, setDisabled] = useState(false);

// Ensure button can only be pressed every 10 seconds
function handleButtonClicked() {
forgotPassword({ email, setStatusMsg, setErrorMsg });
setDisabled(true);
setTimeout(() => {
setDisabled(false);
}, 10000);
}

const validationSchema = yup.object().shape({
email: yup
@@ -34,7 +42,7 @@ export default function ForgotPasswordScreen({ navigation }) {
/(@u.nus.edu|@nus.edu.sg|@u.yale-nus.edu.sg|@u.duke.nus.edu)$/,
"Please enter a valid NUS email"
)
.required("Please enter your email")
.required("Please enter your email"),
});

return (
@@ -44,15 +52,7 @@ export default function ForgotPasswordScreen({ navigation }) {
<Formik
initialValues={{ email: "" }}
validationSchema={validationSchema}
onSubmit={(values) => {
// navigation.navigate("Forgot Password Verification Screen");
if(timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
forgotPassword({ email, setStatusMsg, setErrorMsg })
}, 10000); //timeout for 10 seconds
}}
onSubmit={handleButtonClicked}
>
{({ setFieldValue, handleSubmit, errors, isValid }) => (
<View>
@@ -75,7 +75,7 @@ export default function ForgotPasswordScreen({ navigation }) {
<TouchableOpacity
style={globalStyles.buttonTop}
onPress={handleSubmit}
disabled={!isValid}
disabled={disabled}
>
<Text style={globalStyles.buttonText}>
Send password reset email
@@ -132,7 +132,7 @@ const styles = StyleSheet.create({
color: colors.black,
textAlign: "center",
marginHorizontal: 30,
marginTop: 90,
marginTop: 60,
fontSize: 18,
},
errorMsg: {
11 changes: 11 additions & 0 deletions screens/borrow-screens/BorrowSelectionScreen.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ import firebase from "../../database/firebaseDB";
import { setStallDetails, setQuotas, getBorrowedNum } from "./BorrowApi";
import { UserContext } from "../../assets/UserContext";
import Constants from "expo-constants";
import { useBackHandler } from "@react-native-community/hooks";
import { backActionHandler } from "../BasicApi";

export default function BorrowSelectionScreen({ navigation, route }) {
// Stall name from scanning QR code
@@ -41,6 +43,9 @@ export default function BorrowSelectionScreen({ navigation, route }) {
const [numCups, setCupNum] = useState(0);
const [numContainers, setContainerNum] = useState(0);

// Prevent back button action on Android
useBackHandler(backActionHandler);

// Set up stall details / quotas on intial render
useEffect(() => {
setQuotas(setCupQuota, setContainerQuota);
@@ -142,6 +147,12 @@ export default function BorrowSelectionScreen({ navigation, route }) {
setContainerNum={setContainerNum}
/>
{renderNextButton()}
<TouchableOpacity
onPress={() => navigation.popToTop()}
style={[globalStyles.button, { width: "90%" }]}
>
<Text style={globalStyles.buttonText}>Cancel</Text>
</TouchableOpacity>
</View>
<FooterText />
</View>
12 changes: 6 additions & 6 deletions screens/borrow-screens/BorrowStack.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ const Stack = createStackNavigator();

export default function BorrowStack() {
return (
<Stack.Navigator>
<Stack.Navigator options={{ gestureEnabled: false }}>
<Stack.Screen
name="Borrow QR Screen"
component={BorrowQRScreen}
@@ -20,22 +20,22 @@ export default function BorrowStack() {
<Stack.Screen
name="Selection Screen"
component={BorrowSelectionScreen}
options={{ headerShown: false }}
options={{ headerShown: false, gestureEnabled: false }}
></Stack.Screen>
<Stack.Screen
name="Success Screen"
component={BorrowSuccessfulScreen}
options={{ headerShown: false }}
options={{ headerShown: false, gestureEnabled: false }}
></Stack.Screen>
<Stack.Screen
{/* <Stack.Screen
name="Quota Exceeded"
component={BorrowExceededScreen}
options={{ headerShown: false }}
></Stack.Screen>
></Stack.Screen> */}
<Stack.Screen
name="Unsuccess Screen"
component={BorrowUnsuccessfulScreen}
options={{ headerShown: false }}
options={{ headerShown: false, gestureEnabled: false }}
></Stack.Screen>
<Stack.Screen
name="QR Generator"
6 changes: 6 additions & 0 deletions screens/borrow-screens/BorrowSuccessfulScreen.js
Original file line number Diff line number Diff line change
@@ -6,11 +6,17 @@ import { globalStyles } from "../../assets/globalStyles";
import FooterText from "../../components/FooterText";
import { UserContext } from "../../assets/UserContext";
import { uploadBorrowData } from "./BorrowApi";
import { useBackHandler } from "@react-native-community/hooks";
import { backActionHandler } from "../BasicApi";

export default function BorrowSuccessfulScreen({ route, navigation }) {
const userData = useContext(UserContext);
const { numCups, numContainers } = route.params;
const [hasError, setError] = useState(false);

// Prevent back button action on Android
useBackHandler(backActionHandler);

// console.log(userData.id);
useEffect(() => {
uploadBorrowData(userData.id, numCups, numContainers, setError);
6 changes: 5 additions & 1 deletion screens/borrow-screens/BorrowUnsuccessfulScreen.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,12 @@ import { StyleSheet, Text, ScrollView, Image, Dimensions } from "react-native";
import UnsuccessBox from "../../components/UnsuccessBox";
import colors from "../../assets/colors";
import { globalStyles } from "../../assets/globalStyles";
import { useBackHandler } from "@react-native-community/hooks";
import { backActionHandler } from "../BasicApi";

export default function BorrowUnsuccessfulScreen() {
// Prevent back button action on Android
useBackHandler(backActionHandler);

return (
<ScrollView style={styles.container} showsVerticalScrollIndicator={false}>
@@ -21,4 +25,4 @@ const styles = StyleSheet.create({
container: {
backgroundColor: colors.white,
},
});
});
31 changes: 18 additions & 13 deletions screens/byo-screens/BYOScreen.js
Original file line number Diff line number Diff line change
@@ -95,24 +95,29 @@ export default function BYOScreen({ navigation }) {
}}
>
<View style={styles.box}>

<TouchableOpacity
onPress={() => navigation.navigate("BYO Unsuccessful Screen")}
style={styles.imagePlaceholder}
>
<Text>(Unsuccessful Screen)</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => navigation.navigate("BYO Selection Screen")}
style={styles.imagePlaceholder}
>
<Text>(Selection screen)</Text>
</TouchableOpacity>
{/* <TouchableOpacity
onPress={() => navigation.navigate("BYO Unsuccessful Screen")}
style={styles.imagePlaceholder}
>
<Text>(Unsuccessful Screen)</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => navigation.navigate("BYO Selection Screen")}
style={styles.imagePlaceholder}
>
<Text>(Selection screen)</Text>
</TouchableOpacity> */}
<Text style={styles.text}>Scan the QR code!</Text>
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
style={styles.qr}
/>
<TouchableOpacity
onPress={() => navigation.popToTop()}
style={[globalStyles.buttonTop, { marginTop: 30, width: "80%" }]}
>
<Text style={globalStyles.buttonText}>Back to Home </Text>
</TouchableOpacity>
</View>
<FooterText />
</View>
Loading

0 comments on commit f53d67b

Please sign in to comment.