Parcourir la source

deep links + small fixes

Viktoriia il y a 2 mois
Parent
commit
6fea3122bf

+ 2 - 1
App.tsx

@@ -66,7 +66,8 @@ const linking = {
   prefixes: [API_HOST, 'nomadmania://'],
   config: {
     screens: {
-      publicProfileView: '/profile/:userId'
+      publicProfileView: '/profile/:userId',
+      inAppEvent: '/event/:url'
     }
   }
 };

+ 5 - 0
app.config.ts

@@ -112,6 +112,11 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
             scheme: 'https',
             host: 'nomadmania.com',
             pathPrefix: '/profile/'
+          },
+          {
+            scheme: 'https',
+            host: 'nomadmania.com',
+            pathPrefix: '/event/'
           }
         ],
         category: ['BROWSABLE', 'DEFAULT']

+ 32 - 1
src/contexts/NavigationContext.tsx

@@ -1,6 +1,6 @@
 import React, { createContext, useContext, useEffect, useState } from 'react';
 import { Linking } from 'react-native';
-import { useNavigation } from '@react-navigation/native';
+import { CommonActions, useNavigation } from '@react-navigation/native';
 import { NAVIGATION_PAGES } from 'src/types';
 import { storage, StoreType } from 'src/storage';
 
@@ -26,12 +26,43 @@ export const NavigationProvider = ({ children }: { children: React.ReactNode })
 
   const handleDeepLink = async (url?: string) => {
     const link = url || (await Linking.getInitialURL());
+
     if (link) {
       const { path } = parseURL(link);
       if (path.startsWith('/profile') && token) {
         const segments = path.split('/');
         const userId = segments[2];
         navigation.navigate(...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId }] as never));
+      } else if (path.startsWith('/event')) {
+        const segments = path.split('/');
+        const eventUrl = segments[2];
+
+        navigation.dispatch(
+          CommonActions.reset({
+            index: 1,
+            routes: [
+              {
+                name: 'DrawerApp',
+                state: {
+                  routes: [
+                    {
+                      name: NAVIGATION_PAGES.IN_APP_TRAVELS_TAB,
+                      state: {
+                        routes: [
+                          { name: NAVIGATION_PAGES.EVENTS },
+                          {
+                            name: NAVIGATION_PAGES.EVENT,
+                            params: { url: eventUrl }
+                          }
+                        ]
+                      }
+                    }
+                  ]
+                }
+              }
+            ]
+          })
+        );
       }
     }
     if (!initialUrlProcessed) {

+ 26 - 3
src/screens/InAppScreens/TravelsScreen/EventScreen/index.tsx

@@ -23,6 +23,7 @@ import { NAVIGATION_PAGES } from 'src/types';
 import { API_HOST, APP_VERSION } from 'src/constants';
 import { StoreType, storage } from 'src/storage';
 import { MaterialCommunityIcons } from '@expo/vector-icons';
+import * as Progress from 'react-native-progress';
 
 import ChevronLeft from 'assets/icons/chevron-left.svg';
 import MapSvg from 'assets/icons/travels-screens/map-location.svg';
@@ -109,6 +110,7 @@ const EventScreen = ({ route }: { route: any }) => {
   const [myTempFiles, setMyTempFiles] = useState<TempFile[]>([]);
   const [myFiles, setMyFiles] = useState<EventAttachments[]>([]);
   const [photos, setPhotos] = useState<(EventPhotos & { isSending?: boolean })[]>([]);
+  const [isUploading, setIsUploading] = useState(false);
 
   const [modalInfo, setModalInfo] = useState({
     visible: false,
@@ -213,6 +215,7 @@ const EventScreen = ({ route }: { route: any }) => {
         allowMultiSelection: true
       });
 
+      setIsUploading(true);
       for (const res of response) {
         let file: any = {
           uri: res.uri,
@@ -246,6 +249,7 @@ const EventScreen = ({ route }: { route: any }) => {
                 { ...result, type: 1, description: '', isSending: false },
                 ...prev
               ]);
+              setIsUploading(false);
             },
             onError: (error) => {
               console.error('Upload error:', error);
@@ -253,7 +257,11 @@ const EventScreen = ({ route }: { route: any }) => {
           }
         );
       }
-    } catch {}
+    } catch {
+      setIsUploading(false);
+    } finally {
+      setIsUploading(false);
+    }
   }, [token]);
 
   const handleUploadPhoto = useCallback(async () => {
@@ -600,7 +608,7 @@ const EventScreen = ({ route }: { route: any }) => {
         >
           <Image source={{ uri: photoUrl }} style={{ width: '100%', height: 220 }} />
 
-          <TouchableOpacity
+          {/* <TouchableOpacity
             onPress={() => {
               //     navigation.dispatch(
               //       CommonActions.reset({
@@ -626,7 +634,7 @@ const EventScreen = ({ route }: { route: any }) => {
             <View style={styles.chevronWrapper}>
               <MapSvg fill={Colors.WHITE} />
             </View>
-          </TouchableOpacity>
+          </TouchableOpacity> */}
 
           {registrationInfo && (
             <View
@@ -1051,6 +1059,21 @@ const EventScreen = ({ route }: { route: any }) => {
                   ) : null}
                 </View>
 
+                {isUploading && (
+                  <View
+                    style={{
+                      alignItems: 'center',
+                      justifyContent: 'center'
+                    }}
+                  >
+                    <Progress.CircleSnail
+                      borderWidth={0}
+                      color={Colors.DARK_BLUE}
+                      unfilledColor="rgba(0, 0, 0, 0.1)"
+                    />
+                  </View>
+                )}
+
                 {myTempFiles && myTempFiles.length
                   ? myTempFiles.map((file) => {
                       return (