-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
65 lines (44 loc) · 1.5 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useState } from 'react';
import { Button, Text, View } from 'react-native';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import * as SplashScreen from "expo-splash-screen";
import styles from "./App.scss";
const fetchFonts = async () => {
try {
await SplashScreen.preventAutoHideAsync();
return await Font.loadAsync({
'MontserratRegular': require("./src/assets/fonts/Montserrat-Regular.otf"),
'MontserratLight': require("./src/assets/fonts/Montserrat-Light.otf"),
'MontserratSemiBold': require("./src/assets/fonts/Montserrat-SemiBold.otf"),
'MontserratBold': require("./src/assets/fonts/Montserrat-Bold.otf"),
});
} catch (e) {
console.warn(e);
await SplashScreen.hideAsync();
}
}
export default function App() {
const [fontLoaded, setFontLoaded] = useState(false);
const [defaultBackground, setDefaultBackGround] = useState(true);
if (!fontLoaded) {
return <AppLoading
startAsync={fetchFonts}
onFinish={() => {
setFontLoaded(true);
}}
onError={console.warn}
/>
}
const classes: any = [styles.container];
if (!defaultBackground) {
classes.push(styles['containerAlt']);
}
return (
<View className={classes}>
<Text className={styles.text}>Open up App.tsx</Text>
<Text className={styles.textAlt}>start working on your app!</Text>
<Button title="Change BG" onPress={() => setDefaultBackGround(prevSate => !prevSate)} />
</View>
);
}