Skip to content

Instantly share code, notes, and snippets.

@hroland
Created August 10, 2019 13:29
Show Gist options
  • Select an option

  • Save hroland/8fe9bafd84b01796f9d8cb27057cc4f6 to your computer and use it in GitHub Desktop.

Select an option

Save hroland/8fe9bafd84b01796f9d8cb27057cc4f6 to your computer and use it in GitHub Desktop.

Revisions

  1. hroland created this gist Aug 10, 2019.
    58 changes: 58 additions & 0 deletions expo app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    import { AppLoading } from 'expo';
    import { Asset } from 'expo-asset';
    import * as Font from 'expo-font';
    import React, { useState } from 'react';
    import { Platform, StatusBar, StyleSheet, View } from 'react-native';
    import { Ionicons, Feather, MaterialCommunityIcons } from '@expo/vector-icons';

    import AppNavigator from './navigation/AppNavigator';

    export default function App(props) {
    const [isLoadingComplete, setLoadingComplete] = useState(false);

    if (!isLoadingComplete && !props.skipLoadingScreen) {
    return (
    <AppLoading
    startAsync={loadResourcesAsync}
    onError={handleLoadingError}
    onFinish={() => handleFinishLoading(setLoadingComplete)}
    />
    );
    } else {
    return (
    <View style={styles.container}>
    {Platform.OS === 'ios' && <StatusBar barStyle="default" />}
    <AppNavigator />
    </View>
    );
    }
    }

    async function loadResourcesAsync() {
    await Promise.all([
    Asset.loadAsync([
    ]),
    Font.loadAsync({
    ...Ionicons.font,
    ...Feather.font,
    ...MaterialCommunityIcons.font,
    }),
    ]);
    }

    function handleLoadingError(error) {
    // In this case, you might want to report the error to your error reporting
    // service, for example Sentry
    console.warn(error);
    }

    function handleFinishLoading(setLoadingComplete) {
    setLoadingComplete(true);
    }

    const styles = StyleSheet.create({
    container: {
    flex: 1,
    backgroundColor: '#fff',
    },
    });