KI-AGENT: iOS Share Target mit Upload-Strecke ergänzen
This commit is contained in:
@@ -1,17 +1,51 @@
|
||||
import { Stack } from 'expo-router';
|
||||
import { Href, Stack, useRouter } from 'expo-router';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { ShareIntentProvider, useShareIntentContext } from 'expo-share-intent';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import 'react-native-reanimated';
|
||||
|
||||
import { AuthProvider } from '@/src/providers/auth-provider';
|
||||
import { AuthProvider, useAuth } from '@/src/providers/auth-provider';
|
||||
|
||||
function ShareIntentRouter() {
|
||||
const router = useRouter();
|
||||
const { hasShareIntent } = useShareIntentContext();
|
||||
const { isBootstrapping, token } = useAuth();
|
||||
const isOpeningRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasShareIntent) {
|
||||
isOpeningRef.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isBootstrapping && token && !isOpeningRef.current) {
|
||||
isOpeningRef.current = true;
|
||||
router.push('/share-upload' as Href);
|
||||
}
|
||||
}, [hasShareIntent, isBootstrapping, router, token]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<Stack>
|
||||
<ShareIntentProvider>
|
||||
<AuthProvider>
|
||||
<ShareIntentRouter />
|
||||
<Stack>
|
||||
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="login" options={{ title: 'Login', headerBackVisible: false }} />
|
||||
<Stack.Screen name="tenant-select" options={{ title: 'Tenant auswählen', headerBackVisible: false }} />
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen
|
||||
name="share-upload"
|
||||
options={{
|
||||
title: 'In FEDEO hochladen',
|
||||
headerBackVisible: false,
|
||||
gestureEnabled: false,
|
||||
headerTintColor: '#111827',
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="project/[id]"
|
||||
options={{
|
||||
@@ -102,8 +136,9 @@ export default function RootLayout() {
|
||||
headerTintColor: '#111827',
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<StatusBar style="dark" />
|
||||
</AuthProvider>
|
||||
</Stack>
|
||||
<StatusBar style="dark" />
|
||||
</AuthProvider>
|
||||
</ShareIntentProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user