Open amicale links in the webview

This commit is contained in:
Arnaud Vergnet 2020-04-12 12:46:55 +02:00
parent a5dfa4f021
commit 50334fb609
3 changed files with 22 additions and 7 deletions

View file

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

View file

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

View file

@ -2,17 +2,28 @@
import * as React from 'react'; import * as React from 'react';
import WebViewScreen from "../../components/Screens/WebViewScreen"; import WebViewScreen from "../../components/Screens/WebViewScreen";
import {CommonActions} from "@react-navigation/native";
const URL = 'https://amicale-insat.fr/'; const URL = 'https://www.amicale-insat.fr/';
/** /**
* Class defining the app's available rooms screen. * Class defining the app's available rooms screen.
* This screen uses a webview to render the page * This screen uses a webview to render the page
*/ */
export const AmicaleWebsiteScreen = (props: Object) => { export const AmicaleWebsiteScreen = (props: Object) => {
let path = '';
if (props.route.params !== undefined) {
if (props.route.params.path !== undefined && props.route.params.path !== null) {
path = props.route.params.path;
path = path.replace(URL, '');
// reset params to prevent infinite loop
props.navigation.dispatch(CommonActions.setParams({path: null}));
}
}
console.log(path);
return ( return (
<WebViewScreen <WebViewScreen
{...props} {...props}
url={URL}/> url={URL + path}/>
); );
}; };