Fixed planning url link and added loading dialog on link scanned

This commit is contained in:
Arnaud Vergnet 2020-04-23 10:38:43 +02:00
parent f8363353c3
commit 2fc2db39c7
4 changed files with 30 additions and 6 deletions

6
App.js
View file

@ -1,7 +1,7 @@
// @flow
import * as React from 'react';
import {Platform, StatusBar, YellowBox} from 'react-native';
import {Platform, StatusBar, View, YellowBox} from 'react-native';
import LocaleManager from './src/managers/LocaleManager';
import AsyncStorageManager from "./src/managers/AsyncStorageManager";
import CustomIntroSlider from "./src/components/Overrides/CustomIntroSlider";
@ -18,10 +18,9 @@ import ConnectionManager from "./src/managers/ConnectionManager";
import URLHandler from "./src/utils/URLHandler";
import {setSafeBounceHeight} from "react-navigation-collapsible";
import {enableScreens} from 'react-native-screens';
import {View} from "react-native-animatable";
// Native optimizations https://reactnavigation.org/docs/react-native-screens
enableScreens();
enableScreens(true);
YellowBox.ignoreWarnings([ // collapsible headers cause this warning, just ignore as it is not an issue
@ -72,6 +71,7 @@ export default class App extends React.Component<Props, State> {
this.loadAssetsAsync().then(() => {
this.onLoadFinished();
});
// console.log(Linking.makeUrl('path/into/app', { hello: 'world', goodbye: 'now' }))
}
/**

View file

@ -11,6 +11,7 @@ type Props = {
title: string,
titleLoading: string,
message: string,
startLoading: boolean,
}
type State = {
@ -19,8 +20,16 @@ type State = {
class LoadingConfirmDialog extends React.PureComponent<Props, State> {
static defaultProps = {
title: '',
message: '',
onDismiss: () => {},
onAccept: () => {return Promise.resolve()},
startLoading: false,
}
state = {
loading: false,
loading: this.props.startLoading,
};
/**

View file

@ -10,6 +10,7 @@ import {Linking} from "expo";
import AlertDialog from "../../components/Dialogs/AlertDialog";
import i18n from 'i18n-js';
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
import LoadingConfirmDialog from "../../components/Dialogs/LoadingConfirmDialog";
type Props = {};
type State = {
@ -18,6 +19,7 @@ type State = {
dialogVisible: boolean,
dialogTitle: string,
dialogMessage: string,
loading: boolean,
};
class ScannerScreen extends React.Component<Props, State> {
@ -28,6 +30,7 @@ class ScannerScreen extends React.Component<Props, State> {
dialogVisible: false,
dialogTitle: "",
dialogMessage: "",
loading: false,
};
constructor() {
@ -46,7 +49,7 @@ class ScannerScreen extends React.Component<Props, State> {
if (!URLHandler.isUrlValid(data))
this.showErrorDialog();
else {
this.setState({scanned: true});
this.showOpeningDialog();
Linking.openURL(data);
}
};
@ -108,6 +111,13 @@ class ScannerScreen extends React.Component<Props, State> {
});
};
showOpeningDialog = () => {
this.setState({
loading: true,
scanned: true,
});
};
showErrorDialog() {
this.setState({
dialogVisible: true,
@ -166,6 +176,11 @@ class ScannerScreen extends React.Component<Props, State> {
title={this.state.dialogTitle}
message={this.state.dialogMessage}
/>
<LoadingConfirmDialog
visible={this.state.loading}
titleLoading={i18n.t("general.loading")}
startLoading={true}
/>
</View>
);
}

View file

@ -8,7 +8,7 @@ export default class URLHandler {
static EVENT_INFO_URL_PATH = "event";
static CLUB_INFO_ROUTE = "club-information";
static EVENT_INFO_ROUTE = "home-planning-information";
static EVENT_INFO_ROUTE = "planning-information";
onInitialURLParsed: Function;
onDetectURL: Function;