mirror of
https://github.com/fergalmoran/argon-react-native.git
synced 2025-12-22 09:19:26 +00:00
first render fixed
This commit is contained in:
44
App.js
44
App.js
@@ -1,11 +1,16 @@
|
||||
import React from 'react';
|
||||
import { Image } from 'react-native';
|
||||
import { AppLoading } from 'expo';
|
||||
import { Asset } from 'expo-asset';
|
||||
import { Block, GalioProvider } from 'galio-framework';
|
||||
import React from "react";
|
||||
import { Image } from "react-native";
|
||||
import { AppLoading } from "expo";
|
||||
import { Asset } from "expo-asset";
|
||||
import { Block, GalioProvider } from "galio-framework";
|
||||
import { NavigationContainer } from "@react-navigation/native";
|
||||
|
||||
import Screens from './navigation/Screens';
|
||||
import { Images, articles, argonTheme } from './constants';
|
||||
// Before rendering any navigation stack
|
||||
import { enableScreens } from "react-native-screens";
|
||||
enableScreens();
|
||||
|
||||
import Screens from "./navigation/Screens";
|
||||
import { Images, articles, argonTheme } from "./constants";
|
||||
|
||||
// cache app images
|
||||
const assetImages = [
|
||||
@@ -23,7 +28,7 @@ articles.map(article => assetImages.push(article.image));
|
||||
|
||||
function cacheImages(images) {
|
||||
return images.map(image => {
|
||||
if (typeof image === 'string') {
|
||||
if (typeof image === "string") {
|
||||
return Image.prefetch(image);
|
||||
} else {
|
||||
return Asset.fromModule(image).downloadAsync();
|
||||
@@ -33,11 +38,11 @@ function cacheImages(images) {
|
||||
|
||||
export default class App extends React.Component {
|
||||
state = {
|
||||
isLoadingComplete: false,
|
||||
}
|
||||
isLoadingComplete: false
|
||||
};
|
||||
|
||||
render() {
|
||||
if(!this.state.isLoadingComplete) {
|
||||
if (!this.state.isLoadingComplete) {
|
||||
return (
|
||||
<AppLoading
|
||||
startAsync={this._loadResourcesAsync}
|
||||
@@ -47,19 +52,19 @@ export default class App extends React.Component {
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<GalioProvider theme={argonTheme}>
|
||||
<Block flex>
|
||||
<Screens />
|
||||
</Block>
|
||||
</GalioProvider>
|
||||
<NavigationContainer>
|
||||
<GalioProvider theme={argonTheme}>
|
||||
<Block flex>
|
||||
<Screens />
|
||||
</Block>
|
||||
</GalioProvider>
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_loadResourcesAsync = async () => {
|
||||
return Promise.all([
|
||||
...cacheImages(assetImages),
|
||||
]);
|
||||
return Promise.all([...cacheImages(assetImages)]);
|
||||
};
|
||||
|
||||
_handleLoadingError = error => {
|
||||
@@ -71,5 +76,4 @@ export default class App extends React.Component {
|
||||
_handleFinishLoading = () => {
|
||||
this.setState({ isLoadingComplete: true });
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import { withNavigation } from '@react-navigation/compat';
|
||||
import PropTypes from 'prop-types';
|
||||
import { StyleSheet, Dimensions, Image, TouchableWithoutFeedback } from 'react-native';
|
||||
import { Block, Text, theme } from 'galio-framework';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import { withNavigation } from '@react-navigation/compat';
|
||||
import { TouchableOpacity, StyleSheet, Platform, Dimensions } from 'react-native';
|
||||
import { Button, Block, NavBar, Text, theme } from 'galio-framework';
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ export default function OnboardingStack(props) {
|
||||
<Stack.Navigator mode="card" headerMode="none">
|
||||
<Stack.Screen
|
||||
name="Onboarding"
|
||||
component={Pro}
|
||||
component={Onboarding}
|
||||
option={{
|
||||
headerTransparent: true
|
||||
}}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Onboarding extends React.Component {
|
||||
<Button
|
||||
style={styles.button}
|
||||
color={argonTheme.COLORS.SECONDARY}
|
||||
onPress={() => navigation.navigate("Home")}
|
||||
onPress={() => navigation.navigate("App")}
|
||||
textStyle={{ color: argonTheme.COLORS.BLACK }}
|
||||
>
|
||||
Get Started
|
||||
|
||||
Reference in New Issue
Block a user