Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import { SafeAreaView } from "react-native-safe-area-context";
import { PrivyProvider } from '@privy-io/react-auth';

const PRIVY_APP_ID = process.env.EXPO_PUBLIC_PRIVY_APP_ID || '';

export default function RootLayout() {
return (
<SafeAreaView style={{ flex: 1 }}>
<StatusBar style="dark" />
<Stack />
</SafeAreaView>
<PrivyProvider appId={PRIVY_APP_ID}>
<SafeAreaView style={{ flex: 1 }}>
<StatusBar style="dark" />
<Stack />
</SafeAreaView>
</PrivyProvider>
);
}
56 changes: 26 additions & 30 deletions app/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
ActivityIndicator,
Alert,
Expand All @@ -12,51 +12,47 @@ import {
View
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { usePrivy } from '@privy-io/react-auth';

export default function AuthScreen() {
const router = useRouter();
const [authMethod, setAuthMethod] = useState('email'); // 'email' or 'wallet'
const { login, ready, authenticated } = usePrivy();
const [authMethod, setAuthMethod] = useState<'email' | 'wallet'>('email');
const [email, setEmail] = useState('');
const [loading, setLoading] = useState(false);

console.log('AuthScreen rendering...'); // Debug log

useEffect(() => {
if (ready && authenticated) {
router.push('/home');
}
}, [ready, authenticated]);

const handleEmailAuth = async () => {
if (!email.trim() || !email.includes('@')) {
Alert.alert('Invalid Email', 'Please enter a valid email address');
return;
}

setLoading(true);

try {
// In a real app, we would use Privy SDK to authenticate
// For demo purposes, we'll simulate authentication with a timeout
setTimeout(() => {
setLoading(false);
// Navigate to the main app
router.push('/home');
}, 1500);
await login();
} catch (error) {
setLoading(false);
Alert.alert('Authentication Error', 'Failed to authenticate. Please try again.');
} finally {
setLoading(false);
}
};

const handleWalletAuth = async (walletType: string) => {
const handleWalletAuth = async () => {
setLoading(true);

try {
// In a real app, we would use Privy SDK or WalletConnect for mobile
// For demo purposes, we'll simulate wallet connection with a timeout
setTimeout(() => {
setLoading(false);
// Navigate to the main app
router.push('/home');
}, 1500);
await login();
} catch (error) {
setLoading(false);
Alert.alert('Wallet Connection Error', 'Failed to connect wallet. Please try again.');
} finally {
setLoading(false);
}
};

Expand Down Expand Up @@ -138,9 +134,9 @@ export default function AuthScreen() {
</Text>

<View style={styles.walletOptions}>
<TouchableOpacity
<TouchableOpacity
style={styles.walletOption}
onPress={() => handleWalletAuth('metamask')}
onPress={handleWalletAuth}
disabled={loading}
>
<Image
Expand All @@ -150,9 +146,9 @@ export default function AuthScreen() {
<Text style={styles.walletName}>MetaMask</Text>
</TouchableOpacity>

<TouchableOpacity
<TouchableOpacity
style={styles.walletOption}
onPress={() => handleWalletAuth('walletconnect')}
onPress={handleWalletAuth}
disabled={loading}
>
<Image
Expand All @@ -162,9 +158,9 @@ export default function AuthScreen() {
<Text style={styles.walletName}>WalletConnect</Text>
</TouchableOpacity>

<TouchableOpacity
<TouchableOpacity
style={styles.walletOption}
onPress={() => handleWalletAuth('coinbase')}
onPress={handleWalletAuth}
disabled={loading}
>
<Image
Expand Down
12 changes: 11 additions & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"lint": "expo lint"
"lint": "npx expo lint"
},
"dependencies": {
"@expo/vector-icons": "^14.1.0",
Expand Down Expand Up @@ -36,7 +36,8 @@
"react-native-safe-area-context": "5.4.0",
"react-native-screens": "~4.11.1",
"react-native-web": "~0.20.0",
"react-native-webview": "13.13.5"
"react-native-webview": "13.13.5",
"@privy-io/react-auth": "^0.13.2"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand Down