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 ErrorDialog from "../../components/Dialog/ErrorDialog";
import {CommonActions} from "@react-navigation/native";
import {Linking} from "expo";
type Props = {
navigation: Object,
@ -26,7 +25,7 @@ type State = {
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 = /^.+@.+\..+$/;
@ -78,7 +77,10 @@ class LoginScreen extends React.Component<Props, State> {
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});

View file

@ -7,7 +7,6 @@ import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen";
import i18n from 'i18n-js';
import LogoutDialog from "../../components/Amicale/LogoutDialog";
import MaterialHeaderButtons, {Item} from "../../components/Custom/HeaderButton";
import {Linking} from "expo";
type Props = {
navigation: Object,
@ -158,7 +157,10 @@ class ProfileScreen extends React.Component<Props, State> {
<Button
icon="account-edit"
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}>
{i18n.t("profileScreen.editInformation")}
</Button>

View file

@ -2,17 +2,28 @@
import * as React from 'react';
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.
* This screen uses a webview to render the page
*/
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 (
<WebViewScreen
{...props}
url={URL}/>
url={URL + path}/>
);
};