Browse Source

Moved loading screen in own component

Arnaud Vergnet 4 years ago
parent
commit
5e35086a9c

+ 3
- 29
components/Amicale/AuthenticatedScreen.js View File

@@ -1,11 +1,11 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {View} from "react-native";
5
-import {ActivityIndicator, withTheme} from 'react-native-paper';
4
+import {withTheme} from 'react-native-paper';
6 5
 import ConnectionManager, {ERROR_TYPE} from "../../managers/ConnectionManager";
7 6
 import NetworkErrorComponent from "../Custom/NetworkErrorComponent";
8 7
 import i18n from 'i18n-js';
8
+import BasicLoadingScreen from "../Custom/BasicLoadingScreen";
9 9
 
10 10
 type Props = {
11 11
     navigation: Object,
@@ -71,32 +71,6 @@ class AuthenticatedScreen extends React.Component<Props, State> {
71 71
         this.setState({loading: false});
72 72
     }
73 73
 
74
-    /**
75
-     * Gets the loading indicator
76
-     *
77
-     * @return {*}
78
-     */
79
-    getRenderLoading() {
80
-        return (
81
-            <View style={{
82
-                backgroundColor: this.colors.background,
83
-                position: 'absolute',
84
-                top: 0,
85
-                right: 0,
86
-                width: '100%',
87
-                height: '100%',
88
-                flex: 1,
89
-                alignItems: 'center',
90
-                justifyContent: 'center'
91
-            }}>
92
-                <ActivityIndicator
93
-                    animating={true}
94
-                    size={'large'}
95
-                    color={this.colors.primary}/>
96
-            </View>
97
-        );
98
-    }
99
-
100 74
     getErrorRender() {
101 75
         let message;
102 76
         let icon;
@@ -128,7 +102,7 @@ class AuthenticatedScreen extends React.Component<Props, State> {
128 102
     render() {
129 103
         return (
130 104
             this.state.loading
131
-                ? this.getRenderLoading()
105
+                ? <BasicLoadingScreen/>
132 106
                 : (this.data !== undefined
133 107
                 ? this.props.renderFunction(this.data)
134 108
                 : this.getErrorRender())

+ 35
- 0
components/Custom/BasicLoadingScreen.js View File

@@ -0,0 +1,35 @@
1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {ActivityIndicator, withTheme} from 'react-native-paper';
5
+import {View} from "react-native";
6
+
7
+/**
8
+ * Component used to display a header button
9
+ *
10
+ * @param props Props to pass to the component
11
+ * @return {*}
12
+ */
13
+function BasicLoadingScreen(props) {
14
+    const {colors} = props.theme;
15
+    return (
16
+        <View style={{
17
+            backgroundColor: colors.background,
18
+            position: 'absolute',
19
+            top: 0,
20
+            right: 0,
21
+            width: '100%',
22
+            height: '100%',
23
+            flex: 1,
24
+            alignItems: 'center',
25
+            justifyContent: 'center'
26
+        }}>
27
+            <ActivityIndicator
28
+                animating={true}
29
+                size={'large'}
30
+                color={colors.primary}/>
31
+        </View>
32
+    );
33
+}
34
+
35
+export default withTheme(BasicLoadingScreen);

+ 3
- 20
components/Screens/WebViewScreen.js View File

@@ -1,10 +1,10 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {View} from 'react-native';
5 4
 import WebView from "react-native-webview";
6
-import {ActivityIndicator, withTheme} from 'react-native-paper';
5
+import {withTheme} from 'react-native-paper';
7 6
 import HeaderButton from "../Custom/HeaderButton";
7
+import BasicLoadingScreen from "../Custom/BasicLoadingScreen";
8 8
 
9 9
 type Props = {
10 10
     navigation: Object,
@@ -88,24 +88,7 @@ class WebViewScreen extends React.PureComponent<Props> {
88 88
      * @return {*}
89 89
      */
90 90
     getRenderLoading() {
91
-        return (
92
-            <View style={{
93
-                backgroundColor: this.colors.background,
94
-                position: 'absolute',
95
-                top: 0,
96
-                right: 0,
97
-                width: '100%',
98
-                height: '100%',
99
-                flex: 1,
100
-                alignItems: 'center',
101
-                justifyContent: 'center'
102
-            }}>
103
-                <ActivityIndicator
104
-                    animating={true}
105
-                    size={'large'}
106
-                    color={this.colors.primary}/>
107
-            </View>
108
-        );
91
+        return <BasicLoadingScreen/>;
109 92
     }
110 93
 
111 94
     render() {

Loading…
Cancel
Save