Skip to content

Commit df5f64a

Browse files
committedAug 1, 2024
iterating on auth screens
1 parent 7459983 commit df5f64a

File tree

8 files changed

+328
-84
lines changed

8 files changed

+328
-84
lines changed
 

‎apps/expo/app.config.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { ConfigContext, ExpoConfig } from "@expo/config";
22

33
export default ({ config }: ConfigContext): ExpoConfig => ({
44
...config,
5-
name: "scribeHC",
6-
slug: "scribehc",
5+
name: "hyper",
6+
slug: "hyper",
77
scheme: "expo",
88
version: "0.1.0",
99
orientation: "portrait",
@@ -19,15 +19,15 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
1919
},
2020
assetBundlePatterns: ["**/*"],
2121
ios: {
22-
bundleIdentifier: "com.scribehc.app",
22+
bundleIdentifier: "com.projecthyper.app",
2323
supportsTablet: true,
2424
usesAppleSignIn: true,
2525
config: {
2626
usesNonExemptEncryption: false,
2727
},
2828
},
2929
android: {
30-
package: "com.scribehc.app",
30+
package: "com.projecthyper.app",
3131
adaptiveIcon: {
3232
foregroundImage: "./assets/icon.png",
3333
backgroundColor: "#18181A",
@@ -47,10 +47,10 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
4747
origin: false,
4848
},
4949
eas: {
50-
projectId: "bd3c6023-6da8-4e0d-8a0a-16c6eabd4cb7",
50+
projectId: "914f340a-b357-48a8-8536-3c4b68dfcdad",
5151
},
5252
},
53-
owner: "scribe-hc",
53+
owner: "project-hyper",
5454
plugins: [
5555
"expo-router",
5656
"expo-secure-store",
@@ -78,5 +78,17 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
7878
"Allow $(PRODUCT_NAME) to access your microphone.",
7979
},
8080
],
81+
[
82+
"react-native-vision-camera",
83+
{
84+
cameraPermissionText: "$(PRODUCT_NAME) needs access to your Camera.",
85+
86+
// optionally, if you want to record audio:
87+
enableMicrophonePermission: true,
88+
microphonePermissionText:
89+
"$(PRODUCT_NAME) needs access to your Microphone.",
90+
enableCodeScanner: true,
91+
},
92+
],
8193
],
8294
});

‎apps/expo/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@react-navigation/drawer": "^6.7.2",
3434
"@react-navigation/native": "^6.1.18",
3535
"@shopify/flash-list": "1.7.0",
36+
"@shopify/react-native-skia": "^1.3.9",
3637
"@supabase/auth-helpers-react": "catalog:supabase",
3738
"@supabase/supabase-js": "catalog:supabase",
3839
"@tanstack/react-query": "catalog:",
@@ -75,6 +76,7 @@
7576
"react-native": "~0.74.4",
7677
"react-native-avoid-softinput": "^5.0.0",
7778
"react-native-gesture-handler": "~2.18.0",
79+
"react-native-graph": "^1.1.0",
7880
"react-native-ios-context-menu": "^2.5.1",
7981
"react-native-ios-utilities": "^4.4.5",
8082
"react-native-keyboard-controller": "^1.12.7",
@@ -88,11 +90,13 @@
8890
"react-native-screens": "~3.33.0",
8991
"react-native-svg": "15.4.0",
9092
"react-native-url-polyfill": "^2.0.0",
93+
"react-native-vision-camera": "^4.5.1",
9194
"react-native-web": "~0.19.12",
9295
"superjson": "catalog:",
9396
"tailwind-merge": "^2.4.0",
9497
"tailwindcss": "catalog:tailwind",
9598
"tailwindcss-animate": "catalog:tailwind",
99+
"victory-native": "^41.0.2",
96100
"zeego": "^1.10.0",
97101
"zustand": "^4.5.4"
98102
},

‎apps/expo/src/app/(auth)/reset-password.tsx

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
import React from "react";
1+
import { useState } from "react";
22
import { Keyboard, ScrollView, TouchableWithoutFeedback } from "react-native";
33
import { AvoidSoftInputView } from "react-native-avoid-softinput";
44
import { SafeAreaView } from "react-native-safe-area-context";
55

6+
import type { ResetPasswordFormProps } from "~/components/auth/reset-password-form";
67
import { ResetPasswordForm } from "~/components/auth/reset-password-form";
78

89
export default function ResetPasswordScreen() {
10+
const { signIn } = useSignIn();
11+
const [successfulCreation, setSuccessfulCreation] = useState(false);
12+
const [isLoading, setIsLoading] = useState(false);
13+
const [error, setError] = useState("");
14+
15+
const onSubmit: ResetPasswordFormProps["onSubmit"] = async (data) => {
16+
setIsLoading(true);
17+
try {
18+
await signIn!.create({
19+
strategy: "reset_password_email_code",
20+
identifier: data.email,
21+
});
22+
setSuccessfulCreation(true);
23+
setError("");
24+
} catch (err: unknown) {
25+
setError(err.errors[0].message);
26+
} finally {
27+
setIsLoading(false);
28+
}
29+
};
30+
31+
const onVerificationSuccess = () => {
32+
setSuccessfulCreation(false);
33+
// Add any additional logic needed after successful verification
34+
};
35+
936
return (
1037
<SafeAreaView edges={["left", "right", "bottom"]} style={{ flex: 1 }}>
1138
<AvoidSoftInputView style={{ flex: 1 }}>
@@ -20,7 +47,13 @@ export default function ResetPasswordScreen() {
2047
showsVerticalScrollIndicator={true}
2148
className="flex-1 bg-secondary px-4 py-8"
2249
>
23-
<ResetPasswordForm />
50+
<ResetPasswordForm
51+
onSubmit={onSubmit}
52+
isLoading={isLoading}
53+
error={error}
54+
successfulCreation={successfulCreation}
55+
onVerificationSuccess={onVerificationSuccess}
56+
/>
2457
</ScrollView>
2558
</TouchableWithoutFeedback>
2659
</AvoidSoftInputView>

‎apps/expo/src/app/(auth)/signup.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@ export default function SignUpScreen() {
1919
const { isLoading: isLoadingSession } = useSessionContext();
2020
const supabase = useSupabaseClient();
2121
const [isLoading, setIsLoading] = useState(false);
22+
const [pendingVerification, setPendingVerification] = useState(false);
2223

2324
const onSubmit: SignUpFormProps["onSubmit"] = async (data) => {
24-
if (isLoadingSession) {
25+
if (!isLoaded) {
2526
return;
2627
}
2728

2829
setIsLoading(true);
2930
try {
30-
const { error } = await supabase.auth.signInWithPassword({
31-
email: data.email,
31+
await signUp.create({
32+
emailAddress: data.email,
3233
password: data.password,
3334
});
3435

35-
if (error) {
36-
Alert.alert("Error", error.message);
37-
}
36+
console.log("signup create done");
37+
38+
// Send the email for verification
39+
await signUp.prepareEmailAddressVerification({ strategy: "email_code" });
40+
41+
console.log("signup email sent");
42+
43+
// change the UI to our pending section
44+
setPendingVerification(true);
3845
} catch (err: unknown) {
3946
console.error(JSON.stringify(err, null, 2));
4047
} finally {

‎apps/expo/src/components/auth/reset-password-form.tsx

+18-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, { useState } from "react";
1+
import type { SubmitHandler } from "react-hook-form";
22
import { View } from "react-native";
33
import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated";
4-
import { useSignIn } from "@clerk/clerk-expo";
54
import { zodResolver } from "@hookform/resolvers/zod";
65
import { Controller, FormProvider, useForm } from "react-hook-form";
76

@@ -16,31 +15,28 @@ import { Text } from "~/components/ui/text";
1615
import { Loader2 } from "~/lib/icons/loader-2";
1716
import { cn } from "~/lib/utils";
1817

19-
const ResetPasswordForm = () => {
20-
const { signIn } = useSignIn();
21-
const [successfulCreation, setSuccessfulCreation] = useState(false);
22-
const [error, setError] = useState("");
18+
export interface ResetPasswordFormProps {
19+
onSubmit: SubmitHandler<RequestPasswordReset>;
20+
isLoading: boolean;
21+
error: string;
22+
successfulCreation: boolean;
23+
onVerificationSuccess: () => void;
24+
}
2325

26+
const ResetPasswordForm: React.FC<ResetPasswordFormProps> = ({
27+
onSubmit,
28+
isLoading,
29+
error,
30+
successfulCreation,
31+
onVerificationSuccess,
32+
}) => {
2433
const form = useForm<RequestPasswordReset>({
2534
resolver: zodResolver(RequestPasswordResetSchema),
2635
defaultValues: {
2736
email: "",
2837
},
2938
});
3039

31-
const onSubmit = async (data: RequestPasswordReset) => {
32-
try {
33-
await signIn!.create({
34-
strategy: "reset_password_email_code",
35-
identifier: data.email,
36-
});
37-
setSuccessfulCreation(true);
38-
setError("");
39-
} catch (err: unknown) {
40-
setError(err.errors[0].message);
41-
}
42-
};
43-
4440
return (
4541
<View className="flex-1 justify-center gap-8">
4642
<Text className="text-3xl font-bold">Reset Password</Text>
@@ -88,9 +84,9 @@ const ResetPasswordForm = () => {
8884
<Button
8985
size={"lg"}
9086
onPress={form.handleSubmit(onSubmit)}
91-
disabled={form.formState.isSubmitting}
87+
disabled={isLoading}
9288
>
93-
{form.formState.isSubmitting ? (
89+
{isLoading ? (
9490
<View className="flex-row items-center justify-center gap-3">
9591
<Loader2
9692
size={24}
@@ -114,9 +110,7 @@ const ResetPasswordForm = () => {
114110
)}
115111

116112
{successfulCreation && (
117-
<ResetPasswordVerificationForm
118-
onSuccess={() => setSuccessfulCreation(false)}
119-
/>
113+
<ResetPasswordVerificationForm onSuccess={onVerificationSuccess} />
120114
)}
121115
</View>
122116
);

‎apps/expo/src/components/auth/signin-form.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { Loader2 } from "~/lib/icons/loader-2";
1919
import { cn } from "~/lib/utils";
2020

2121
export interface SignInFormProps {
22-
onSubmit?: SubmitHandler<SignIn>;
22+
onSubmit: SubmitHandler<SignIn>;
2323
isLoading: boolean;
2424
}
2525

26-
const SignInForm = ({ onSubmit = () => {}, isLoading }: SignInFormProps) => {
26+
const SignInForm = ({ onSubmit, isLoading }: SignInFormProps) => {
2727
const [showPassword, setShowPassword] = useState(false);
2828

2929
const form = useForm<SignIn>({

‎apps/expo/src/components/auth/signup-form.tsx

+6-31
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ import { EyeOff } from "~/lib/icons/eye-off";
1919
import { Loader2 } from "~/lib/icons/loader-2";
2020
import { cn } from "~/lib/utils";
2121

22-
const SignUpForm = () => {
23-
const { signUp, isLoaded } = useSignUp();
24-
const [isLoading, setIsLoading] = useState(false);
22+
export interface SignUpFormProps {
23+
onSubmit: SubmitHandler<SignUp>;
24+
isLoading: boolean;
25+
}
26+
27+
const SignUpForm = ({ onSubmit, isLoading }: SignUpFormProps) => {
2528
const [pendingVerification, setPendingVerification] = useState(false);
2629
const [showPassword, setShowPassword] = useState(false);
2730

@@ -33,34 +36,6 @@ const SignUpForm = () => {
3336
},
3437
});
3538

36-
const onSubmit: SubmitHandler<SignUp> = async (data) => {
37-
if (!isLoaded) {
38-
return;
39-
}
40-
41-
setIsLoading(true);
42-
try {
43-
await signUp.create({
44-
emailAddress: data.email,
45-
password: data.password,
46-
});
47-
48-
console.log("signup create done");
49-
50-
// Send the email for verification
51-
await signUp.prepareEmailAddressVerification({ strategy: "email_code" });
52-
53-
console.log("signup email sent");
54-
55-
// change the UI to our pending section
56-
setPendingVerification(true);
57-
} catch (err: unknown) {
58-
console.error(JSON.stringify(err, null, 2));
59-
} finally {
60-
setIsLoading(false);
61-
}
62-
};
63-
6439
const handleVerificationSuccess = () => {
6540
console.log("handleVerificationSuccess");
6641
};

0 commit comments

Comments
 (0)
Failed to load comments.