-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leon Si
committed
Apr 7, 2020
1 parent
a81f4fe
commit 047c803
Showing
8 changed files
with
80 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,19 +18,9 @@ import {Notifications} from 'expo'; | |
import * as Permissions from 'expo-permissions'; | ||
import * as SecureStore from 'expo-secure-store'; | ||
import RoleSelectionScreen from "./screens/RoleSelectionScreen"; | ||
import {Overlay} from 'react-native-elements'; | ||
|
||
const Drawer = createDrawerNavigator(); | ||
|
||
const userInfo = { | ||
name: "John Doe", | ||
email: "[email protected]", | ||
phone: "(416) 132-4634", | ||
timeout: "00:34", | ||
role: "Worker", | ||
description: "Worker for Walmart" | ||
}; | ||
|
||
function DrawerContent(props) { | ||
const {user, setUser} = useContext(UserContext); | ||
|
||
|
@@ -61,7 +51,13 @@ function DrawerContent(props) { | |
export default function App() { | ||
const [currentStore, setCurrentStore] = useState({name: "Walmart", id: 0}); | ||
const [groceryList, setGroceryList] = useState({}); | ||
const [user, setUser] = useState(null); | ||
const [user, setUser] = useState({ | ||
role: 'Worker', | ||
phoneNumber: '4161324634', | ||
email: '[email protected]', | ||
firstName: 'John', | ||
lastName: 'Doe' | ||
}); | ||
|
||
useEffect(() => { | ||
(async() => { | ||
|
@@ -71,6 +67,7 @@ export default function App() { | |
vibrate: [250], | ||
sound: true, | ||
}); | ||
|
||
await Notifications.createChannelAndroidAsync('activated', { | ||
name: 'Activated', | ||
}); | ||
|
@@ -98,7 +95,6 @@ export default function App() { | |
if (!id) return; | ||
const response = await fetch(`https://grocerserver.herokuapp.com/users/${id}`); | ||
const result = await response.json(); | ||
|
||
})(); | ||
}, []); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
import React, {useEffect, useState, useContext} from 'react'; | ||
import {View, Text, StyleSheet} from 'react-native'; | ||
import {Button} from 'react-native-elements'; | ||
import {Button, Input} from 'react-native-elements'; | ||
import StackWrapper from "../navigation/StackWrapper"; | ||
import * as SecureStore from 'expo-secure-store'; | ||
import UserContext from "../contexts/User"; | ||
|
||
function RoleSelectionScreen() { | ||
const [pushToken, setPushToken] = useState(''); | ||
const {user, setUser} = useContext(UserContext); | ||
const [firstName, setFirstName] = useState('John'); | ||
const [lastName, setLastName] = useState('Doe'); | ||
const [email, setEmail] = useState('[email protected]'); | ||
|
||
useEffect(() => { | ||
(async() => { | ||
setPushToken(await SecureStore.getItemAsync('pushToken')); | ||
})(); | ||
}, []); | ||
const {user, setUser} = useContext(UserContext); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.notice}> | ||
If you're looking to test role-specific features of our app, you | ||
need to select a role that you wish to test. If you're just looking | ||
for a general concept and overview, you can press the menu in the | ||
top left corner and navigate to all the screens, but keep in mind | ||
that specific features for those screens may not work if you haven't | ||
selected a role. | ||
need to select a role that you wish to test. Keep in mind | ||
that specific features for some screens may not work if you haven't | ||
selected the appropriate role. | ||
</Text> | ||
<Input | ||
containerStyle={styles.input} | ||
label="First Name" | ||
value={firstName} | ||
onChangeText={(text) => setFirstName(text)} | ||
/> | ||
<Input | ||
containerStyle={styles.input} | ||
value={lastName} | ||
onChangeText={(text) => setLastName(text)} | ||
label="Last Name" | ||
/> | ||
<Input | ||
containerStyle={styles.input} | ||
value={email} | ||
onChangeText={(text) => setEmail(text)} | ||
label="Email" | ||
/> | ||
<Button | ||
buttonStyle={styles.button} | ||
title="Become Shopper" | ||
title="Become Shopper/Requestor" | ||
onPress={async () => { | ||
const pushToken = await SecureStore.getItemAsync('pushToken'); | ||
const usersUrl = 'https://grocerserver.herokuapp.com/users'; | ||
|
@@ -39,32 +52,29 @@ function RoleSelectionScreen() { | |
}, | ||
body: JSON.stringify({ | ||
phoneNumber: '4161324634', | ||
email: '[email protected]', | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
email, | ||
firstName, | ||
lastName, | ||
role: 'Shopper', | ||
pushToken | ||
}) | ||
}); | ||
const result = await response.json(); | ||
setUser(result); | ||
await SecureStore.setItemAsync('userId', result._id); | ||
|
||
}} | ||
/> | ||
<Button | ||
buttonStyle={styles.button} | ||
title="Become Requestor" | ||
onPress={() => { | ||
|
||
}} | ||
/> | ||
<Button | ||
buttonStyle={styles.button} | ||
title="Become Worker" | ||
onPress={() => { | ||
setUser(null); | ||
}} | ||
/> | ||
<View style={{flex: -1, alignItems: 'center'}}> | ||
<Text style={{fontWeight: 'bold'}}>Current Role:</Text> | ||
<Text>{user ? "Shopper/Requestor" : "Worker"}</Text> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
@@ -79,8 +89,12 @@ const styles = StyleSheet.create({ | |
notice: { | ||
fontWeight: 'bold', | ||
textAlign: 'center' | ||
}, | ||
input: { | ||
marginVertical: 10 | ||
} | ||
}); | ||
|
||
export default StackWrapper(RoleSelectionScreen, { | ||
title: 'Change Role' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters