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