Arnaud Vergnet 3 years ago
parent
commit
a56d2978e1

+ 2
- 0
App.js View File

@@ -17,6 +17,7 @@ import ConnectionManager from "./src/managers/ConnectionManager";
17 17
 import URLHandler from "./src/utils/URLHandler";
18 18
 import {setSafeBounceHeight} from "react-navigation-collapsible";
19 19
 import {enableScreens} from 'react-native-screens';
20
+import SplashScreen from 'react-native-splash-screen'
20 21
 
21 22
 // Native optimizations https://reactnavigation.org/docs/react-native-screens
22 23
 enableScreens(true);
@@ -175,6 +176,7 @@ export default class App extends React.Component<Props, State> {
175 176
             showUpdate: this.storageManager.preferences.updateNumber.current !== Update.number.toString(),
176 177
             showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && this.storageManager.preferences.showAprilFoolsStart.current === '1',
177 178
         });
179
+        SplashScreen.hide();
178 180
     }
179 181
 
180 182
     /**

+ 8
- 0
android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java View File

@@ -1,5 +1,6 @@
1 1
 package fr.amicaleinsat.application;
2 2
 
3
+import android.os.Bundle;
3 4
 import com.facebook.react.ReactActivity;
4 5
 import com.facebook.react.ReactActivityDelegate;
5 6
 import com.facebook.react.ReactRootView;
@@ -7,6 +8,8 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
7 8
 import android.content.Intent;
8 9
 import android.content.res.Configuration;
9 10
 
11
+import org.devio.rn.splashscreen.SplashScreen;
12
+
10 13
 public class MainActivity extends ReactActivity {
11 14
 
12 15
     // Added automatically by Expo Config
@@ -18,6 +21,11 @@ public class MainActivity extends ReactActivity {
18 21
         sendBroadcast(intent);
19 22
     }
20 23
 
24
+   @Override
25
+    protected void onCreate(Bundle savedInstanceState) {
26
+        SplashScreen.show(this);
27
+        super.onCreate(savedInstanceState);
28
+    }
21 29
 
22 30
     /**
23 31
      * Returns the name of the main component registered from JavaScript.

+ 0
- 1
android/app/src/main/java/fr/amicaleinsat/application/generated/BasePackageList.java View File

@@ -21,7 +21,6 @@ public class BasePackageList {
21 21
         new expo.modules.permissions.PermissionsPackage(),
22 22
         new expo.modules.securestore.SecureStorePackage(),
23 23
         new expo.modules.sqlite.SQLitePackage(),
24
-        new expo.modules.updates.UpdatesPackage(),
25 24
         new expo.modules.webbrowser.WebBrowserPackage()
26 25
     );
27 26
   }

BIN
android/app/src/main/res/drawable-xxhdpi/launch_screen.png View File


+ 12
- 0
android/app/src/main/res/layout/launch_screen.xml View File

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+                android:orientation="vertical" android:layout_width="match_parent"
4
+                android:layout_height="match_parent">
5
+
6
+    <ImageView
7
+        android:layout_width="match_parent"
8
+        android:layout_height="match_parent"
9
+        android:background="@color/colorPrimary"
10
+        android:scaleType="fitCenter"
11
+        android:src="@drawable/launch_screen" />
12
+</RelativeLayout>

+ 1
- 0
android/app/src/main/res/values/colors.xml View File

@@ -4,4 +4,5 @@
4 4
   <color name="navigationBarColor">#121212</color>
5 5
   <color name="colorPrimaryDark">#be1522</color>
6 6
   <color name="colorPrimary">#be1522</color>
7
+  <color name="primary_dark">#be1522</color>
7 8
 </resources>

+ 10
- 0
ios/Campus/AppDelegate.m View File

@@ -14,10 +14,20 @@
14 14
 #import <UMReactNativeAdapter/UMNativeModulesProxy.h>
15 15
 #import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
16 16
 
17
+#import <React/RCTLinkingManager.h>
18
+
17 19
 @implementation AppDelegate
18 20
 
19 21
 @synthesize window = _window;
20 22
 
23
+- (BOOL)application:(UIApplication *)application
24
+   openURL:(NSURL *)url
25
+   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
26
+{
27
+  return [RCTLinkingManager application:application openURL:url options:options];
28
+}
29
+
30
+
21 31
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
22 32
 {
23 33
   self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];

+ 1
- 0
ios/Podfile View File

@@ -43,4 +43,5 @@ target 'Campus' do
43 43
 
44 44
   # react-native-cli autolinking
45 45
   use_native_modules!
46
+
46 47
 end

+ 10
- 9
package.json View File

@@ -18,21 +18,13 @@
18 18
     ]
19 19
   },
20 20
   "dependencies": {
21
-    "expo": "^37.0.0",
22
-    "react": "~16.9.0",
23
-    "react-dom": "16.9.0",
24
-    "react-native": "~0.61.5",
25
-    "react-native-gesture-handler": "~1.6.0",
26
-    "react-native-reanimated": "~1.7.0",
27
-    "react-native-screens": "~2.2.0",
28
-    "react-native-unimodules": "~0.9.0",
29
-    "react-native-web": "~0.11.7",
30 21
     "@expo/vector-icons": "^10.0.0",
31 22
     "@react-native-community/masked-view": "0.1.6",
32 23
     "@react-navigation/bottom-tabs": "^5.1.1",
33 24
     "@react-navigation/drawer": "^5.1.1",
34 25
     "@react-navigation/native": "^5.0.9",
35 26
     "@react-navigation/stack": "^5.1.1",
27
+    "expo": "^37.0.0",
36 28
     "expo-barcode-scanner": "~8.1.0",
37 29
     "expo-camera": "latest",
38 30
     "expo-linear-gradient": "~8.1.0",
@@ -40,17 +32,26 @@
40 32
     "expo-permissions": "~8.1.0",
41 33
     "expo-secure-store": "~8.1.0",
42 34
     "i18n-js": "^3.3.0",
35
+    "react": "~16.9.0",
36
+    "react-dom": "16.9.0",
37
+    "react-native": "~0.61.5",
43 38
     "react-native-animatable": "^1.3.3",
44 39
     "react-native-app-intro-slider": "^4.0.0",
45 40
     "react-native-appearance": "~0.3.3",
46 41
     "react-native-autolink": "^3.0.0",
47 42
     "react-native-calendars": "^1.260.0",
48 43
     "react-native-collapsible": "^1.5.2",
44
+    "react-native-gesture-handler": "~1.6.0",
49 45
     "react-native-image-modal": "^1.0.6",
50 46
     "react-native-modalize": "^1.3.6",
51 47
     "react-native-paper": "^3.8.0",
48
+    "react-native-reanimated": "~1.7.0",
52 49
     "react-native-render-html": "^4.1.2",
53 50
     "react-native-safe-area-context": "0.7.3",
51
+    "react-native-screens": "~2.2.0",
52
+    "react-native-splash-screen": "^3.2.0",
53
+    "react-native-unimodules": "~0.9.0",
54
+    "react-native-web": "~0.11.7",
54 55
     "react-native-webview": "8.1.1",
55 56
     "react-navigation-collapsible": "^5.5.0",
56 57
     "react-navigation-header-buttons": "^3.0.5"

+ 39
- 11
src/utils/URLHandler.js View File

@@ -1,9 +1,11 @@
1 1
 // @flow
2 2
 
3
-import {Linking} from 'expo';
3
+import {Linking} from 'react-native';
4 4
 
5 5
 export default class URLHandler {
6 6
 
7
+    static SCHEME = "campus-insat://";
8
+
7 9
     static CLUB_INFO_URL_PATH = "club";
8 10
     static EVENT_INFO_URL_PATH = "event";
9 11
 
@@ -20,21 +22,47 @@ export default class URLHandler {
20 22
 
21 23
     listen() {
22 24
         Linking.addEventListener('url', this.onUrl);
23
-        Linking.parseInitialURLAsync().then(this.onInitialUrl);
25
+        Linking.getInitialURL().then(this.onInitialUrl);
24 26
     }
25 27
 
26
-    onUrl = ({url}: Object) => {
27
-        let data = URLHandler.getUrlData(Linking.parse(url));
28
-        if (data !== null)
29
-            this.onDetectURL(data);
28
+    onUrl = ({url}: { url: string }) => {
29
+        if (url != null) {
30
+            let data = URLHandler.getUrlData(URLHandler.parseUrl(url));
31
+            if (data !== null)
32
+                this.onDetectURL(data);
33
+        }
30 34
     };
31 35
 
32
-    onInitialUrl = ({path, queryParams}: Object) => {
33
-        let data = URLHandler.getUrlData({path, queryParams});
34
-        if (data !== null)
35
-            this.onInitialURLParsed(data);
36
+    onInitialUrl = (url: ?string) => {
37
+        if (url != null) {
38
+            let data = URLHandler.getUrlData(URLHandler.parseUrl(url));
39
+            if (data !== null)
40
+                this.onInitialURLParsed(data);
41
+        }
36 42
     };
37 43
 
44
+    static parseUrl(url: string) {
45
+        let params = {};
46
+        let path = "";
47
+        let temp = url.replace(URLHandler.SCHEME, "");
48
+        if (temp != null) {
49
+            let array = temp.split("?");
50
+            if (array != null && array.length > 0) {
51
+                path = array[0];
52
+            }
53
+            if (array != null && array.length > 1) {
54
+                let tempParams = array[1].split("&");
55
+                for (let i = 0; i < tempParams.length; i++) {
56
+                    let paramsArray = tempParams[i].split("=");
57
+                    if (paramsArray.length > 1) {
58
+                        params[paramsArray[0]] = paramsArray[1];
59
+                    }
60
+                }
61
+            }
62
+        }
63
+        return {path: path, queryParams: params};
64
+    }
65
+
38 66
     static getUrlData({path, queryParams}: Object) {
39 67
         let data = null;
40 68
         if (path !== null) {
@@ -47,7 +75,7 @@ export default class URLHandler {
47 75
     }
48 76
 
49 77
     static isUrlValid(url: string) {
50
-        return this.getUrlData(Linking.parse(url)) !== null;
78
+        return this.getUrlData(URLHandler.parseUrl(url)) !== null;
51 79
     }
52 80
 
53 81
     static isClubInformationLink(path: string) {

Loading…
Cancel
Save