forked from vergnet/application-amicale
fix no group selected screen
This commit is contained in:
parent
8506d3d81f
commit
c2fdda5588
3 changed files with 34 additions and 15 deletions
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Button, Subheading, useTheme } from 'react-native-paper';
|
import { Button, Subheading, useTheme } from 'react-native-paper';
|
||||||
import { StyleSheet, View } from 'react-native';
|
import { StyleSheet, View, ViewStyle } from 'react-native';
|
||||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import * as Animatable from 'react-native-animatable';
|
import * as Animatable from 'react-native-animatable';
|
||||||
|
@ -36,6 +36,7 @@ type Props = {
|
||||||
icon: string;
|
icon: string;
|
||||||
onPress: () => void;
|
onPress: () => void;
|
||||||
};
|
};
|
||||||
|
style?: ViewStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -147,7 +148,7 @@ function ErrorView(props: Props) {
|
||||||
const { button } = props;
|
const { button } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.outer}>
|
<View style={{ ...styles.outer, ...props.style }}>
|
||||||
<Animatable.View
|
<Animatable.View
|
||||||
style={{
|
style={{
|
||||||
...styles.outer,
|
...styles.outer,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View } from 'react-native';
|
import { StyleSheet, View } from 'react-native';
|
||||||
import GENERAL_STYLES from '../../constants/Styles';
|
import GENERAL_STYLES from '../../constants/Styles';
|
||||||
import Urls from '../../constants/Urls';
|
import Urls from '../../constants/Urls';
|
||||||
import DateManager from '../../managers/DateManager';
|
import DateManager from '../../managers/DateManager';
|
||||||
|
@ -15,6 +15,14 @@ type Props = {
|
||||||
onMessage: (event: { nativeEvent: { data: string } }) => void;
|
onMessage: (event: { nativeEvent: { data: string } }) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
error: {
|
||||||
|
position: 'absolute',
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Watch for changes in the calendar and call the remove alpha function to prevent invisible events
|
// Watch for changes in the calendar and call the remove alpha function to prevent invisible events
|
||||||
const OBSERVE_MUTATIONS_INJECTED =
|
const OBSERVE_MUTATIONS_INJECTED =
|
||||||
'function removeAlpha(node) {\n' +
|
'function removeAlpha(node) {\n' +
|
||||||
|
@ -99,19 +107,21 @@ const generateInjectedJS = (group: PlanexGroupType | undefined) => {
|
||||||
function PlanexWebview(props: Props) {
|
function PlanexWebview(props: Props) {
|
||||||
return (
|
return (
|
||||||
<View style={GENERAL_STYLES.flex}>
|
<View style={GENERAL_STYLES.flex}>
|
||||||
{!props.currentGroup ? (
|
|
||||||
<ErrorView
|
|
||||||
icon={'account-clock'}
|
|
||||||
message={i18n.t('screens.planex.noGroupSelected')}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<WebViewScreen
|
<WebViewScreen
|
||||||
url={Urls.planex.planning}
|
url={Urls.planex.planning}
|
||||||
initialJS={generateInjectedJS(props.currentGroup)}
|
initialJS={generateInjectedJS(props.currentGroup)}
|
||||||
injectJS={props.injectJS}
|
injectJS={props.injectJS}
|
||||||
onMessage={props.onMessage}
|
onMessage={props.onMessage}
|
||||||
showAdvancedControls={false}
|
showAdvancedControls={false}
|
||||||
|
showControls={props.currentGroup !== undefined}
|
||||||
/>
|
/>
|
||||||
|
{!props.currentGroup ? (
|
||||||
|
<ErrorView
|
||||||
|
icon={'account-clock'}
|
||||||
|
message={i18n.t('screens.planex.noGroupSelected')}
|
||||||
|
style={styles.error}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ type Props = {
|
||||||
injectJS?: string;
|
injectJS?: string;
|
||||||
customPaddingFunction?: null | ((padding: number) => string);
|
customPaddingFunction?: null | ((padding: number) => string);
|
||||||
showAdvancedControls?: boolean;
|
showAdvancedControls?: boolean;
|
||||||
|
showControls?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AnimatedWebView = Animated.createAnimatedComponent(WebView);
|
const AnimatedWebView = Animated.createAnimatedComponent(WebView);
|
||||||
|
@ -110,13 +111,20 @@ function WebViewScreen(props: Props) {
|
||||||
);
|
);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
|
if (props.showControls !== false) {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
headerRight: props.showAdvancedControls
|
headerRight: props.showAdvancedControls
|
||||||
? getAdvancedButtons
|
? getAdvancedButtons
|
||||||
: getBasicButton,
|
: getBasicButton,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [navigation, props.showAdvancedControls, navState?.url]);
|
}, [
|
||||||
|
navigation,
|
||||||
|
props.showAdvancedControls,
|
||||||
|
navState?.url,
|
||||||
|
props.showControls,
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.injectJS && props.injectJS !== currentInjectedJS) {
|
if (props.injectJS && props.injectJS !== currentInjectedJS) {
|
||||||
|
|
Loading…
Reference in a new issue