forked from vergnet/application-amicale
Fixed planning url link and added loading dialog on link scanned
This commit is contained in:
parent
f8363353c3
commit
2fc2db39c7
4 changed files with 30 additions and 6 deletions
6
App.js
6
App.js
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
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 LocaleManager from './src/managers/LocaleManager';
|
||||||
import AsyncStorageManager from "./src/managers/AsyncStorageManager";
|
import AsyncStorageManager from "./src/managers/AsyncStorageManager";
|
||||||
import CustomIntroSlider from "./src/components/Overrides/CustomIntroSlider";
|
import CustomIntroSlider from "./src/components/Overrides/CustomIntroSlider";
|
||||||
|
@ -18,10 +18,9 @@ import ConnectionManager from "./src/managers/ConnectionManager";
|
||||||
import URLHandler from "./src/utils/URLHandler";
|
import URLHandler from "./src/utils/URLHandler";
|
||||||
import {setSafeBounceHeight} from "react-navigation-collapsible";
|
import {setSafeBounceHeight} from "react-navigation-collapsible";
|
||||||
import {enableScreens} from 'react-native-screens';
|
import {enableScreens} from 'react-native-screens';
|
||||||
import {View} from "react-native-animatable";
|
|
||||||
|
|
||||||
// Native optimizations https://reactnavigation.org/docs/react-native-screens
|
// 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
|
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.loadAssetsAsync().then(() => {
|
||||||
this.onLoadFinished();
|
this.onLoadFinished();
|
||||||
});
|
});
|
||||||
|
// console.log(Linking.makeUrl('path/into/app', { hello: 'world', goodbye: 'now' }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,7 @@ type Props = {
|
||||||
title: string,
|
title: string,
|
||||||
titleLoading: string,
|
titleLoading: string,
|
||||||
message: string,
|
message: string,
|
||||||
|
startLoading: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -19,8 +20,16 @@ type State = {
|
||||||
|
|
||||||
class LoadingConfirmDialog extends React.PureComponent<Props, State> {
|
class LoadingConfirmDialog extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
title: '',
|
||||||
|
message: '',
|
||||||
|
onDismiss: () => {},
|
||||||
|
onAccept: () => {return Promise.resolve()},
|
||||||
|
startLoading: false,
|
||||||
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
loading: false,
|
loading: this.props.startLoading,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {Linking} from "expo";
|
||||||
import AlertDialog from "../../components/Dialogs/AlertDialog";
|
import AlertDialog from "../../components/Dialogs/AlertDialog";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
|
import LoadingConfirmDialog from "../../components/Dialogs/LoadingConfirmDialog";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -18,6 +19,7 @@ type State = {
|
||||||
dialogVisible: boolean,
|
dialogVisible: boolean,
|
||||||
dialogTitle: string,
|
dialogTitle: string,
|
||||||
dialogMessage: string,
|
dialogMessage: string,
|
||||||
|
loading: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScannerScreen extends React.Component<Props, State> {
|
class ScannerScreen extends React.Component<Props, State> {
|
||||||
|
@ -28,6 +30,7 @@ class ScannerScreen extends React.Component<Props, State> {
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
dialogTitle: "",
|
dialogTitle: "",
|
||||||
dialogMessage: "",
|
dialogMessage: "",
|
||||||
|
loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -46,7 +49,7 @@ class ScannerScreen extends React.Component<Props, State> {
|
||||||
if (!URLHandler.isUrlValid(data))
|
if (!URLHandler.isUrlValid(data))
|
||||||
this.showErrorDialog();
|
this.showErrorDialog();
|
||||||
else {
|
else {
|
||||||
this.setState({scanned: true});
|
this.showOpeningDialog();
|
||||||
Linking.openURL(data);
|
Linking.openURL(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -108,6 +111,13 @@ class ScannerScreen extends React.Component<Props, State> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
showOpeningDialog = () => {
|
||||||
|
this.setState({
|
||||||
|
loading: true,
|
||||||
|
scanned: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
showErrorDialog() {
|
showErrorDialog() {
|
||||||
this.setState({
|
this.setState({
|
||||||
dialogVisible: true,
|
dialogVisible: true,
|
||||||
|
@ -166,6 +176,11 @@ class ScannerScreen extends React.Component<Props, State> {
|
||||||
title={this.state.dialogTitle}
|
title={this.state.dialogTitle}
|
||||||
message={this.state.dialogMessage}
|
message={this.state.dialogMessage}
|
||||||
/>
|
/>
|
||||||
|
<LoadingConfirmDialog
|
||||||
|
visible={this.state.loading}
|
||||||
|
titleLoading={i18n.t("general.loading")}
|
||||||
|
startLoading={true}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default class URLHandler {
|
||||||
static EVENT_INFO_URL_PATH = "event";
|
static EVENT_INFO_URL_PATH = "event";
|
||||||
|
|
||||||
static CLUB_INFO_ROUTE = "club-information";
|
static CLUB_INFO_ROUTE = "club-information";
|
||||||
static EVENT_INFO_ROUTE = "home-planning-information";
|
static EVENT_INFO_ROUTE = "planning-information";
|
||||||
|
|
||||||
onInitialURLParsed: Function;
|
onInitialURLParsed: Function;
|
||||||
onDetectURL: Function;
|
onDetectURL: Function;
|
||||||
|
|
Loading…
Reference in a new issue