From 2fc2db39c729ad17a1abb1e7f61ef85ab14f0a8c Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 23 Apr 2020 10:38:43 +0200 Subject: [PATCH] Fixed planning url link and added loading dialog on link scanned --- App.js | 6 +++--- src/components/Dialogs/LoadingConfirmDialog.js | 11 ++++++++++- src/screens/Home/ScannerScreen.js | 17 ++++++++++++++++- src/utils/URLHandler.js | 2 +- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/App.js b/App.js index 57c77e3..8f470e4 100644 --- a/App.js +++ b/App.js @@ -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 { this.loadAssetsAsync().then(() => { this.onLoadFinished(); }); + // console.log(Linking.makeUrl('path/into/app', { hello: 'world', goodbye: 'now' })) } /** diff --git a/src/components/Dialogs/LoadingConfirmDialog.js b/src/components/Dialogs/LoadingConfirmDialog.js index 8c7d48a..922bc7c 100644 --- a/src/components/Dialogs/LoadingConfirmDialog.js +++ b/src/components/Dialogs/LoadingConfirmDialog.js @@ -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 { + static defaultProps = { + title: '', + message: '', + onDismiss: () => {}, + onAccept: () => {return Promise.resolve()}, + startLoading: false, + } + state = { - loading: false, + loading: this.props.startLoading, }; /** diff --git a/src/screens/Home/ScannerScreen.js b/src/screens/Home/ScannerScreen.js index f75b864..2e36a34 100644 --- a/src/screens/Home/ScannerScreen.js +++ b/src/screens/Home/ScannerScreen.js @@ -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 { @@ -28,6 +30,7 @@ class ScannerScreen extends React.Component { dialogVisible: false, dialogTitle: "", dialogMessage: "", + loading: false, }; constructor() { @@ -46,7 +49,7 @@ class ScannerScreen extends React.Component { 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 { }); }; + showOpeningDialog = () => { + this.setState({ + loading: true, + scanned: true, + }); + }; + showErrorDialog() { this.setState({ dialogVisible: true, @@ -166,6 +176,11 @@ class ScannerScreen extends React.Component { title={this.state.dialogTitle} message={this.state.dialogMessage} /> + ); } diff --git a/src/utils/URLHandler.js b/src/utils/URLHandler.js index a6e73c2..481317d 100644 --- a/src/utils/URLHandler.js +++ b/src/utils/URLHandler.js @@ -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;