Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login revamp test #39

Merged
merged 33 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dd5af2d
feat: install Gluestack UI library
artkolpakov Jan 16, 2024
d415ba7
yarn
solderq35 Jan 16, 2024
7a67cda
nice
FrankreedX Jan 16, 2024
7954c63
replaced gluestack with react native paper
FrankreedX Jan 16, 2024
642ce63
added db_spec
FrankreedX Jan 22, 2024
ec7145c
Rebase "solderq35/login-revamp-test" onto layout branch; remove ts, e…
solderq35 Jan 16, 2024
08e7296
jk now the light dark theme stuff is gone
solderq35 Jan 16, 2024
1b65e25
yarn
solderq35 Jan 16, 2024
941109e
fix dependency issues and update async storage
solderq35 Jan 16, 2024
c1c1e8d
jsx > js, match layout branch format
solderq35 Jan 16, 2024
868a4c3
gluestack
solderq35 Jan 16, 2024
3cbc7ed
update readme
solderq35 Jan 16, 2024
bda6593
save progress and then cut down on dependencies later
solderq35 Jan 16, 2024
264f541
simplify dependencies
solderq35 Jan 16, 2024
fc2a911
add web bundler, fix firestore dependency
solderq35 Jan 24, 2024
fd02c80
formatting
solderq35 Jan 24, 2024
e69a3d0
add back app.json expo router plugin
solderq35 Jan 24, 2024
821122a
reset to layout branch
solderq35 Feb 29, 2024
8db4543
add back signin and signup onto layout
solderq35 Feb 29, 2024
0bd7db3
add usecontext call, dismiss keyboard, alert popups, team search plac…
solderq35 Feb 29, 2024
2a64518
fix profile settings icon placement, add uid to usecontext, allow cli…
solderq35 Mar 1, 2024
e2e8363
setdoc on new user
solderq35 Mar 1, 2024
fb7a28e
manually fix some things to match layout cause I brain farted during …
solderq35 Mar 1, 2024
0c6db11
commit what I got before I implement user object email foreign key thing
solderq35 Mar 2, 2024
3c1bddd
update email stuff
solderq35 Mar 2, 2024
f83b71c
add password reset emails, add error handler to signout
solderq35 Mar 5, 2024
0b9337a
fix signout and password reset error handling
solderq35 Mar 5, 2024
c4a35b2
styling fixes, max width and container height
solderq35 Mar 5, 2024
ac24f4c
more styling fixes
solderq35 Mar 6, 2024
a57f8c1
update with latest changes after rebase
solderq35 Mar 9, 2024
7755f5c
simplify context user, remove unused functions, var rename
solderq35 Mar 9, 2024
22981a3
reset plan index
solderq35 Mar 9, 2024
50d08dd
rename var names
solderq35 Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPO_PUBLIC_TEST_UID=c0nEyjaOMhItMQTLMY0X
EXPO_PUBLIC_TEST_NAME=John Doe
[email protected]
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Info below subject to change
- [iOS](https://apps.apple.com/us/app/expo-go/id982107779)
- [Android](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en_US&gl=US)
- `yarn start`
- If on OSU school wifi (or any other wifi that doesn't support peer-to-peer), use `yarn start --tunnel`
- Run app, scan QR code on physical phone

### Running App on Android Emulator (Windows PC or MacOS)
Expand All @@ -58,15 +57,34 @@ Info below subject to change
- `C:\Users\<username>\AppData\Local\Android\Sdk\emulator\emulator -avd <emulated phone name> -feature -Vulkan`
- Example: `C:\Users\solde\AppData\Local\Android\Sdk\emulator\emulator -avd Pixel_3a_API_34_extension_level_7_x86_64 -feature -Vulkan`
- `yarn android` to run the app
- If on OSU school wifi (or any other wifi that doesn't support peer-to-peer), use `yarn android --tunnel`

### Running App in iOS Emulator (MacOS)

- Note that Expo Go will be automatically installed on the emulated mobile device for you
- Documentation: https://developer.apple.com/documentation/xcode/running-your-app-in-simulator-or-on-a-device
- Should be more straightforwards than Android, you shouldn't need to use command line to open iOS emulator
- `yarn ios` to run the app
- If on OSU school wifi (or any other wifi that doesn't support peer-to-peer), use `yarn ios --tunnel`

### WiFi / Tunneling

- In general, if running the app on a physical mobile device, the mobile device and the PC compiling the app should be on the same WiFi network
- If on OSU WiFi, or any other WiFi that disables peer-to-peer, use the `--tunnel` argument, e.g:
- `yarn start --tunnel`
- `yarn ios -tunnel`
- `yarn android --tunnel`
- Using a mobile hotspot is another potential solution, if the other WiFi networks nearby disable peer-to-peer

### Login Bypass

- `yarn test`
- Bypass login for testing purposes, will log you in as a dummy user "John Doe"
- If you logged out of app, reload / restart app to automatically log back in as dummy user
- Optional arguments:
- `--tunnel`
- For WiFi tunneling as described above
- `--ios` or `--android`
- For running app on iOS or Android emulator
- Note that arguments can be combined, e.g. `yarn test --android --tunnel`

### Formatting Script

Expand Down
13 changes: 13 additions & 0 deletions app/(auth)/_layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Stack } from "expo-router";

export default function RootLayoutNav() {
return (
<>
<Stack
screenOptions={{
headerShown: false,
}}
/>
</>
);
}
172 changes: 172 additions & 0 deletions app/(auth)/signin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { Link } from "expo-router";
import {
getAuth,
sendPasswordResetEmail,
signInWithEmailAndPassword,
} from "firebase/auth";
import { useState } from "react";
import {
Image,
Keyboard,
Pressable,
StyleSheet,
Text,
TextInput,
TouchableWithoutFeedback,
View,
} from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { currentAuthContext } from "~/context/Auth";
import { auth } from "~/firebaseConfig";

const BUTTON_WIDTH = 150;
const INPUT_WIDTH = 200;

export default function SignIn() {
const { signIn } = currentAuthContext();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

async function handleSignIn() {
try {
const userCredential = await signInWithEmailAndPassword(
auth,
email,
password,
);
console.log(userCredential.user);
signIn();
FrankreedX marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {
alert(e);
console.log(e);
}
}

async function handleForgotPassword() {
try {
if (email === "") {
throw "Please enter an email address for password reset";
}
sendPasswordResetEmail(getAuth(), email)
.then(() => {
alert("Password reset email sent");
})
.catch((e) => {
alert(e);
console.log(e);
});
} catch (e) {
// dual catch but had to handle empty email
alert(e);
console.log(e);
}
}

return (
<TouchableWithoutFeedback
// dismiss keyboard after tapping outside of search bar input
onPress={Keyboard.dismiss}
accessible={false}
>
<View style={styles.container}>
<Image
source={{
uri: "https://upload.wikimedia.org/wikipedia/en/thumb/1/1b/Oregon_State_Beavers_logo.svg/1200px-Oregon_State_Beavers_logo.svg.png",
resizeMode: "contain",
width: 131,
height: 75,
}}
style={[styles.image]}
FrankreedX marked this conversation as resolved.
Show resolved Hide resolved
/>
<Text style={[styles.title]}>Oregon State Golf</Text>
<KeyboardAwareScrollView
// allows opening links from search results without closing keyboard first
keyboardShouldPersistTaps="handled"
showsVerticalScrollIndicator={false}
>
<View style={[styles.inputView]}>
<Text style={[styles.placeholderText]}>Email</Text>
<TextInput
autoCapitalize="none"
autoComplete="email"
autoCorrect={false}
onChangeText={setEmail}
style={[styles.input]}
/>
<Text style={[styles.placeholderText]}>Password</Text>
<TextInput
autoCapitalize="none"
autoComplete="current-password"
autoCorrect={false}
secureTextEntry={true}
onChangeText={setPassword}
style={[styles.input]}
/>
<Pressable style={[styles.button]} onPress={handleForgotPassword}>
<Text style={[styles.forgotPassword]}>Forgot your password?</Text>
</Pressable>

<Pressable
style={[styles.button]}
onPress={handleSignIn}
backgroundColor={"#F24E1E"}
>
<Text style={styles.buttonText}>Login</Text>
</Pressable>
<Pressable style={[styles.button]} backgroundColor={"#F24E1E"}>
<Link asChild href={"/signup"}>
<Text style={styles.buttonText}>Sign Up</Text>
</Link>
</Pressable>
</View>
</KeyboardAwareScrollView>
</View>
</TouchableWithoutFeedback>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
marginTop: 100,
},
image: {
marginTop: 0,
},
title: {
fontSize: 32,
fontWeight: "bold",
marginTop: 5,
},
button: {
borderRadius: 12,
marginTop: 20,
marginHorizontal: (INPUT_WIDTH - BUTTON_WIDTH) / 2,
width: BUTTON_WIDTH,
},
buttonText: {
fontSize: 18,
color: "white",
paddingVertical: 8,
textAlign: "center",
},
input: {
marginVertical: 5,
paddingVertical: Platform.OS === "ios" ? 10 : 5, // padding and margins on ios look different than android?
backgroundColor: "white",
paddingHorizontal: 5,
width: INPUT_WIDTH,
maxWidth: INPUT_WIDTH,
},
placeholderText: {
marginTop: 5,
},
forgotPassword: {
alignSelf: "flex-start",
textDecorationLine: "underline",
},
inputView: {
marginTop: 20,
},
});
Loading
Loading