Browse Source

Open amicale links in the webview

Arnaud Vergnet 4 years ago
parent
commit
50334fb609

+ 5
- 3
src/screens/Amicale/LoginScreen.js View File

@@ -7,7 +7,6 @@ import ConnectionManager from "../../managers/ConnectionManager";
7 7
 import i18n from 'i18n-js';
8 8
 import ErrorDialog from "../../components/Dialog/ErrorDialog";
9 9
 import {CommonActions} from "@react-navigation/native";
10
-import {Linking} from "expo";
11 10
 
12 11
 type Props = {
13 12
     navigation: Object,
@@ -26,7 +25,7 @@ type State = {
26 25
 
27 26
 const ICON_AMICALE = require('../../../assets/amicale.png');
28 27
 
29
-const RESET_PASSWORD_LINK = "https://www.amicale-insat.fr/password/reset";
28
+const RESET_PASSWORD_PATH = "password/reset";
30 29
 
31 30
 const emailRegex = /^.+@.+\..+$/;
32 31
 
@@ -78,7 +77,10 @@ class LoginScreen extends React.Component<Props, State> {
78 77
 
79 78
     handleSuccess = () => this.props.navigation.navigate(this.nextScreen);
80 79
 
81
-    onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_LINK);
80
+    onResetPasswordClick = () => this.props.navigation.navigate('amicale-website', {
81
+        screen: 'amicale-website',
82
+        params: {path: RESET_PASSWORD_PATH}
83
+    });
82 84
 
83 85
     validateEmail = () => this.setState({isEmailValidated: true});
84 86
 

+ 4
- 2
src/screens/Amicale/ProfileScreen.js View File

@@ -7,7 +7,6 @@ import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen";
7 7
 import i18n from 'i18n-js';
8 8
 import LogoutDialog from "../../components/Amicale/LogoutDialog";
9 9
 import MaterialHeaderButtons, {Item} from "../../components/Custom/HeaderButton";
10
-import {Linking} from "expo";
11 10
 
12 11
 type Props = {
13 12
     navigation: Object,
@@ -158,7 +157,10 @@ class ProfileScreen extends React.Component<Props, State> {
158 157
                         <Button
159 158
                             icon="account-edit"
160 159
                             mode="contained"
161
-                            onPress={() => Linking.openURL(this.data.link)}
160
+                            onPress={() => this.props.navigation.navigate('amicale-website', {
161
+                                screen: 'amicale-website',
162
+                                params: {path: this.data.link}
163
+                            })}
162 164
                             style={styles.editButton}>
163 165
                             {i18n.t("profileScreen.editInformation")}
164 166
                         </Button>

+ 13
- 2
src/screens/Websites/AmicaleWebsiteScreen.js View File

@@ -2,17 +2,28 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import WebViewScreen from "../../components/Screens/WebViewScreen";
5
+import {CommonActions} from "@react-navigation/native";
5 6
 
6
-const URL = 'https://amicale-insat.fr/';
7
+const URL = 'https://www.amicale-insat.fr/';
7 8
 /**
8 9
  * Class defining the app's available rooms screen.
9 10
  * This screen uses a webview to render the page
10 11
  */
11 12
 export const AmicaleWebsiteScreen = (props: Object) => {
13
+    let path = '';
14
+    if (props.route.params !== undefined) {
15
+        if (props.route.params.path !== undefined && props.route.params.path !== null) {
16
+            path = props.route.params.path;
17
+            path = path.replace(URL, '');
18
+            // reset params to prevent infinite loop
19
+            props.navigation.dispatch(CommonActions.setParams({path: null}));
20
+        }
21
+    }
22
+    console.log(path);
12 23
     return (
13 24
         <WebViewScreen
14 25
             {...props}
15
-            url={URL}/>
26
+            url={URL + path}/>
16 27
     );
17 28
 };
18 29
 

Loading…
Cancel
Save