11import React from 'react' ;
2- import { NavigationContainer } from '@react-navigation/native' ;
2+ import { NavigationContainer , LinkingOptions } from '@react-navigation/native' ;
33import { SafeAreaProvider } from 'react-native-safe-area-context' ;
44import { GestureHandlerRootView } from 'react-native-gesture-handler' ;
55import { BottomSheetModalProvider } from '@gorhom/bottom-sheet' ;
66import { AuthProvider , useAuth } from './src/context/AuthContext' ;
77import { ThemeProvider } from './src/context/ThemeContext' ;
88import AuthStack from './src/navigation/AuthStack' ;
99import MainTabs from './src/navigation/MainTabs' ;
10+ import SplashScreen from './src/screens/SplashScreen' ;
11+ import { DEEP_LINK_SCHEME } from './src/config' ;
1012
1113import { Linking , StyleSheet } from 'react-native' ;
1214
15+ // ── Deep Link Configuration ───────────────────────────────────────────────────
16+
17+ const linking : LinkingOptions < { } > = {
18+ prefixes : [ `${ DEEP_LINK_SCHEME } ://` ] ,
19+ config : {
20+ screens : {
21+ MainTabs : {
22+ screens : {
23+ Home : 'home' ,
24+ Scan : 'scan' ,
25+ } ,
26+ } ,
27+ DevCardView : 'u/:username' ,
28+ } ,
29+ } ,
30+ } ;
31+
32+ // ── App Content ───────────────────────────────────────────────────────────────
33+
1334function AppContent ( ) {
1435 const { isAuthenticated, isLoading, login } = useAuth ( ) ;
1536
1637 React . useEffect ( ( ) => {
1738 const handleDeepLink = ( event : { url : string } ) => {
18- console . log ( '--- DEEP LINK RECEIVED ---' ) ;
19- console . log ( 'URL:' , event . url ) ;
20- const url = new URL ( event . url ) ;
21- const hashParams = new URLSearchParams ( url . hash . replace ( / ^ # / , '' ) ) ;
22- const token = url . searchParams . get ( 'token' ) || hashParams . get ( 'token' ) ;
23- if ( token ) {
24- console . log ( 'Token found, logging in...' ) ;
25- login ( token ) ;
39+ try {
40+ const url = new URL ( event . url ) ;
41+ const hashParams = new URLSearchParams ( url . hash . replace ( / ^ # / , '' ) ) ;
42+ const token = url . searchParams . get ( 'token' ) || hashParams . get ( 'token' ) ;
43+ if ( token ) {
44+ login ( token ) ;
45+ }
46+ } catch ( error ) {
47+ console . error ( 'Deep link parse error:' , error ) ;
2648 }
2749 } ;
2850
@@ -38,16 +60,18 @@ function AppContent() {
3860 } , [ login ] ) ;
3961
4062 if ( isLoading ) {
41- return null ; // Splash screen could go here
63+ return < SplashScreen /> ;
4264 }
4365
4466 return (
45- < NavigationContainer >
67+ < NavigationContainer linking = { linking } >
4668 { isAuthenticated ? < MainTabs /> : < AuthStack /> }
4769 </ NavigationContainer >
4870 ) ;
4971}
5072
73+ // ── Root ───────────────────────────────────────────────────────────────────────
74+
5175export default function App ( ) {
5276 return (
5377 < GestureHandlerRootView style = { styles . gestureRoot } >
0 commit comments