Browse Source

Prevent flickering on start

Arnaud Vergnet 4 years ago
parent
commit
b85dab627a
1 changed files with 23 additions and 7 deletions
  1. 23
    7
      App.js

+ 23
- 7
App.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {Platform, StatusBar, YellowBox} from 'react-native';
4
+import {Platform, StatusBar, View, YellowBox} from 'react-native';
5 5
 import LocaleManager from './src/managers/LocaleManager';
6 6
 import AsyncStorageManager from "./src/managers/AsyncStorageManager";
7 7
 import CustomIntroSlider from "./src/components/Overrides/CustomIntroSlider";
@@ -17,6 +17,7 @@ import Update from "./src/constants/Update";
17 17
 import ConnectionManager from "./src/managers/ConnectionManager";
18 18
 import URLHandler from "./src/utils/URLHandler";
19 19
 import {setSafeBounceHeight} from "react-navigation-collapsible";
20
+import * as Animatable from 'react-native-animatable';
20 21
 
21 22
 YellowBox.ignoreWarnings([ // collapsible headers cause this warning, just ignore as it is not an issue
22 23
     'Non-serializable values were found in the navigation state',
@@ -173,7 +174,6 @@ export default class App extends React.Component<Props, State> {
173 174
             showUpdate: this.storageManager.preferences.updateNumber.current !== Update.number.toString(),
174 175
             showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && this.storageManager.preferences.showAprilFoolsStart.current === '1',
175 176
         });
176
-        SplashScreen.hide();
177 177
     }
178 178
 
179 179
     /**
@@ -191,11 +191,27 @@ export default class App extends React.Component<Props, State> {
191 191
         } else {
192 192
             return (
193 193
                 <PaperProvider theme={this.state.currentTheme}>
194
-                    <NavigationContainer theme={this.state.currentTheme} ref={this.navigatorRef}>
195
-                        <Stack.Navigator headerMode="none">
196
-                            <Stack.Screen name="Root" component={this.createDrawerNavigator}/>
197
-                        </Stack.Navigator>
198
-                    </NavigationContainer>
194
+                    <View style={{
195
+                        flex: 1,
196
+                        backgroundColor: ThemeManager.getCurrentTheme().colors.background
197
+                    }}>
198
+                        <Animatable.View
199
+                            style={{flex: 1,}}
200
+                            animation={"fadeIn"}
201
+                            duration={1000}
202
+                            useNativeDriver
203
+                            onAnimationBegin={() => {
204
+                                // delay the hiding even 1ms is enough to prevent flickering
205
+                                setTimeout(() => SplashScreen.hide(), 1);
206
+                            }}
207
+                        >
208
+                            <NavigationContainer theme={this.state.currentTheme} ref={this.navigatorRef}>
209
+                                <Stack.Navigator headerMode="none">
210
+                                    <Stack.Screen name="Root" component={this.createDrawerNavigator}/>
211
+                                </Stack.Navigator>
212
+                            </NavigationContainer>
213
+                        </Animatable.View>
214
+                    </View>
199 215
                 </PaperProvider>
200 216
             );
201 217
         }

Loading…
Cancel
Save