Skip to content

Commit

Permalink
Added displayname screen, not used yet
Browse files Browse the repository at this point in the history
  • Loading branch information
dyland88 committed Nov 16, 2024
1 parent e27f97b commit 3e1285a
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 52 deletions.
50 changes: 0 additions & 50 deletions client/app/components/auth/AuthButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,6 @@ import {
ImageSourcePropType,
} from "react-native";

// Migrated to SettingsScree.tsx

// import { appSignOut } from "../../services/AuthStore";
// interface SignOutButtonProps {}
// export const SignOutButton: React.FC<SignOutButtonProps> = () => {
// const [loading, setLoading] = useState(false);

// const handleSignOut = async () => {
// Alert.alert(
// "Confirm Sign Out",
// "Are you sure you want to sign out?",
// [
// {
// text: "Cancel",
// style: "cancel",
// },
// {
// text: "Sign Out",
// onPress: async () => {
// setLoading(true);
// const response = await appSignOut();
// setLoading(false);

// if (response?.user === null) {
// console.log("Sign out successful");
// } else if (response?.error) {
// console.log(response.error);
// Alert.alert(
// "Sign Out Failed",
// "An error occurred during sign out. Please try again.",
// );
// }
// },
// },
// ],
// { cancelable: false },
// );
// };

// return (
// <TouchableOpacity
// style={styles.sign_out_button}
// onPress={handleSignOut}
// disabled={loading}>
// <Text style={styles.button_text}>Sign Out</Text>
// </TouchableOpacity>

// );
// };

export const ExternalAuthButton: React.FC<{
onPress?: () => void;
companyName: string;
Expand Down
16 changes: 14 additions & 2 deletions client/app/components/common/CustomInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export const WelcomeEmailInput: React.FC<ChatInputProps> = ({
);
};

// Maybe will put LogInEmailInput & LogInPasswordInput two together into a single component

export const EmailInput: React.FC<ChatInputProps & { invalid: boolean }> = ({
value,
onChangeText,
Expand All @@ -43,6 +41,20 @@ export const EmailInput: React.FC<ChatInputProps & { invalid: boolean }> = ({
);
};

export const DisplayNameInput: React.FC<
ChatInputProps & { invalid: boolean }
> = ({ value, onChangeText, invalid }) => {
return (
<TextInput
style={[styles.loginInput, invalid && styles.invalidLoginInput]}
placeholder="Display Name"
multiline={false}
value={value}
onChangeText={onChangeText}
/>
);
};

export const PasswordInput: React.FC<ChatInputProps & { invalid: boolean }> = ({
value,
onChangeText,
Expand Down
2 changes: 2 additions & 0 deletions client/app/navigation/AuthNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SignUpScreen from "../screens/auth/SignUpScreen";
import WelcomeScreen from "../screens/auth/WelcomeScreen";
import EmailVerificationScreen from "../screens/auth/EmailVerificationScreen";
import { NavigationContainer } from "@react-navigation/native";
import DisplayNameScreen from "@app/screens/auth/DisplayNameScreen";

const Stack = createStackNavigator();

Expand All @@ -23,6 +24,7 @@ const AuthNavigator = () => {
name="Email Verification"
component={EmailVerificationScreen}
/>
{/* <Stack.Screen name="Display Name" component={DisplayNameScreen} /> */}
</Stack.Navigator>
</NavigationContainer>
);
Expand Down
131 changes: 131 additions & 0 deletions client/app/screens/auth/DisplayNameScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import React, { useState, useRef } from "react";
import {
View,
Text,
StyleSheet,
Dimensions,
TouchableWithoutFeedback,
Keyboard,
TextInput,
TouchableOpacity,
} from "react-native";
import LargeTextButton from "../../components/auth/LargeTextButton";
import { DisplayNameInput } from "@app/components/common/CustomInputs";

const DisplayNameScreen = ({ navigation }: any) => {
const [input, setInput] = useState("");
const [errorMessage, setErrorMessage] = useState("");
const hiddenInputRef = useRef<TextInput>(null);

const handlePress = () => {
hiddenInputRef.current?.focus();
};

const handleChangeText = (text: string) => {
setInput(text);
setErrorMessage("");
};

const handleSubmit = () => {
if (!input || input.length == 0) {
setErrorMessage("Please enter a display name");
return;
}
navigation.navigate("Home");
};

return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={styles.main_container}>
<View style={styles.header_container}>
<Text style={styles.header_text}>Just one more step!</Text>
<Text style={styles.subheader_text}>
Pick a display name other people will see
</Text>
</View>

<DisplayNameInput
value={input}
onChangeText={handleChangeText}
invalid={errorMessage !== ""}
/>

<View style={styles.button_container}>
<LargeTextButton onPress={handleSubmit} buttonText="Submit" />
</View>

{errorMessage ? (
<Text style={styles.errorText}>{errorMessage}</Text>
) : null}
</View>
</TouchableWithoutFeedback>
);
};

const styles = StyleSheet.create({
main_container: {
display: "flex",
height: "100%",
width: "100%",
justifyContent: "flex-start",
alignItems: "center",
paddingHorizontal: Dimensions.get("window").width * 0.11,
paddingVertical: Dimensions.get("window").height * 0.01,
backgroundColor: "white",
gap: Dimensions.get("window").height * 0.029,
},
input_container: {
display: "flex",
width: "100%",
justifyContent: "center",
alignItems: "center",
},
boxContainer: {
flexDirection: "row",
justifyContent: "space-between",
width: "80%",
},
box: {
width: 40,
height: 50,
borderWidth: 1,
borderColor: "#000",
justifyContent: "center",
alignItems: "center",
borderRadius: 5,
},
boxText: {
fontSize: 24,
fontWeight: "bold",
},
button_container: {
display: "flex",
justifyContent: "space-around",
alignItems: "center",
width: "100%",
},
header_container: {
display: "flex",
justifyContent: "center",
alignItems: "flex-start",
width: "100%",
marginBottom: Dimensions.get("window").height * 0.019,
marginTop: Dimensions.get("window").height * 0.17,
},
header_text: {
fontFamily: "Quicksand-Bold",
fontSize: 37,
marginBottom: Dimensions.get("window").height * 0.01,
},
subheader_text: {
fontFamily: "Quicksand-Medium",
fontSize: 20,
},
errorText: {
color: "red",
marginTop: 10,
fontSize: 13,
},
});

export default DisplayNameScreen;
1 change: 1 addition & 0 deletions client/app/screens/auth/SignUpScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const SignUpScreen = ({ navigation }: any) => {

const handleGoogleSignUp = async () => {
console.log("Google Sign Up");
navigation.navigate("Display Name");
};

const handleFacebookSignIn = async () => {
Expand Down

0 comments on commit 3e1285a

Please sign in to comment.