mirror of
https://github.com/fergalmoran/argon-react-native.git
synced 2025-12-24 02:09:51 +00:00
updates to App.js for fonts
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
107
App.js
107
App.js
@@ -1,6 +1,7 @@
|
|||||||
import React from "react";
|
import React, {useState} from "react";
|
||||||
import { Image } from "react-native";
|
import { Image } from "react-native";
|
||||||
import { AppLoading } from "expo";
|
import { AppLoading } from "expo";
|
||||||
|
import { useFonts } from '@use-expo/font';
|
||||||
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 { NavigationContainer } from "@react-navigation/native";
|
||||||
@@ -36,44 +37,86 @@ function cacheImages(images) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default props => {
|
||||||
state = {
|
const [isLoadingComplete, setLoading] = useState(false);
|
||||||
isLoadingComplete: false
|
let [fontsLoaded] = useFonts({
|
||||||
};
|
'ArgonExtra': require('./assets/font/argon.ttf'),
|
||||||
|
});
|
||||||
|
|
||||||
render() {
|
function _loadResourcesAsync() {
|
||||||
if (!this.state.isLoadingComplete) {
|
console.log('bro');
|
||||||
return (
|
return Promise.all([...cacheImages(assetImages)]);
|
||||||
<AppLoading
|
|
||||||
startAsync={this._loadResourcesAsync}
|
|
||||||
onError={this._handleLoadingError}
|
|
||||||
onFinish={this._handleFinishLoading}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<NavigationContainer>
|
|
||||||
<GalioProvider theme={argonTheme}>
|
|
||||||
<Block flex>
|
|
||||||
<Screens />
|
|
||||||
</Block>
|
|
||||||
</GalioProvider>
|
|
||||||
</NavigationContainer>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadResourcesAsync = async () => {
|
function _handleLoadingError(error) {
|
||||||
return Promise.all([...cacheImages(assetImages)]);
|
|
||||||
};
|
|
||||||
|
|
||||||
_handleLoadingError = error => {
|
|
||||||
// In this case, you might want to report the error to your error
|
// In this case, you might want to report the error to your error
|
||||||
// reporting service, for example Sentry
|
// reporting service, for example Sentry
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleFinishLoading = () => {
|
function _handleFinishLoading() {
|
||||||
this.setState({ isLoadingComplete: true });
|
setLoading(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(!fontsLoaded && !isLoadingComplete) {
|
||||||
|
return (
|
||||||
|
<AppLoading
|
||||||
|
startAsync={_loadResourcesAsync}
|
||||||
|
onError={_handleLoadingError}
|
||||||
|
onFinish={_handleFinishLoading}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if(fontsLoaded) {
|
||||||
|
return (
|
||||||
|
<NavigationContainer>
|
||||||
|
<GalioProvider theme={argonTheme}>
|
||||||
|
<Block flex>
|
||||||
|
<Screens />
|
||||||
|
</Block>
|
||||||
|
</GalioProvider>
|
||||||
|
</NavigationContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export default class App extends React.Component {
|
||||||
|
// state = {
|
||||||
|
// isLoadingComplete: false
|
||||||
|
// };
|
||||||
|
|
||||||
|
// render() {
|
||||||
|
// if (!this.state.isLoadingComplete) {
|
||||||
|
// return (
|
||||||
|
// <AppLoading
|
||||||
|
// startAsync={this._loadResourcesAsync}
|
||||||
|
// onError={this._handleLoadingError}
|
||||||
|
// onFinish={this._handleFinishLoading}
|
||||||
|
// />
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// return (
|
||||||
|
// <NavigationContainer>
|
||||||
|
// <GalioProvider theme={argonTheme}>
|
||||||
|
// <Block flex>
|
||||||
|
// <Screens />
|
||||||
|
// </Block>
|
||||||
|
// </GalioProvider>
|
||||||
|
// </NavigationContainer>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _loadResourcesAsync = async () => {
|
||||||
|
// return Promise.all([...cacheImages(assetImages)]);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// _handleLoadingError = error => {
|
||||||
|
// // In this case, you might want to report the error to your error
|
||||||
|
// // reporting service, for example Sentry
|
||||||
|
// console.warn(error);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// _handleFinishLoading = () => {
|
||||||
|
// this.setState({ isLoadingComplete: true });
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"@react-navigation/drawer": "5.0.0",
|
"@react-navigation/drawer": "5.0.0",
|
||||||
"@react-navigation/native": "5.0.0",
|
"@react-navigation/native": "5.0.0",
|
||||||
"@react-navigation/stack": "5.0.0",
|
"@react-navigation/stack": "5.0.0",
|
||||||
|
"@use-expo/font": "^2.0.0",
|
||||||
"expo": "^37.0.0",
|
"expo": "^37.0.0",
|
||||||
"expo-asset": "~8.1.5",
|
"expo-asset": "~8.1.5",
|
||||||
"expo-font": "~8.1.0",
|
"expo-font": "~8.1.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user