Skip to content

Commit

Permalink
Connecting fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
EuJinnLucaShow committed Aug 14, 2023
1 parent 9a60425 commit 4f0f168
Show file tree
Hide file tree
Showing 15 changed files with 451 additions and 3 deletions.
49 changes: 47 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import {
StyleSheet,
Expand All @@ -13,6 +13,11 @@ import {
Platform,
} from 'react-native';

import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';

SplashScreen.preventAutoHideAsync();

const wallpaper = require('./assets/images/wallpaper.png');

const initialState = {
Expand All @@ -21,19 +26,59 @@ const initialState = {
password: '',
};

const loadFonts = () => {
return Font.loadAsync({
Roboto: require('./assets/fonts/Roboto-Regular.ttf'),
});
};

export default function App() {
const [isShowKeyboard, setIsShowKeyboard] = useState(false);
const [state, setState] = useState(initialState);
const [appIsReady, setAppIsReady] = useState(false);

const keyboardHide = () => {
setIsShowKeyboard(false);
Keyboard.dismiss();
console.log(state);
setState(initialState);
};

useEffect(() => {
async function prepare() {
try {
// Pre-load fonts, make any API calls you need to do here
await loadFonts();
// await Font.loadAsync(Entypo.font);
} catch (e) {
console.warn(e);
} finally {
// Tell the application to render
setAppIsReady(true);
}
}

prepare();
}, []);

const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
// This tells the splash screen to hide immediately! If we call this after
// `setAppIsReady`, then we may see a blank screen while the app is
// loading its initial state and rendering its first pixels. So instead,
// we hide the splash screen once we know the root view has already
// performed layout.
await SplashScreen.hideAsync();
}
}, [appIsReady]);

if (!appIsReady) {
return null;
}

return (
<TouchableWithoutFeedback onPress={keyboardHide}>
<View style={styles.container}>
<View style={styles.container} onLayout={onLayoutRootView}>
<ImageBackground source={wallpaper} style={styles.image}>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
Expand Down
Binary file added assets/fonts/Roboto-Black.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-BlackItalic.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Bold.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-BoldItalic.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Italic.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Light.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-LightItalic.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Medium.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-MediumItalic.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-Thin.ttf
Binary file not shown.
Binary file added assets/fonts/Roboto-ThinItalic.ttf
Binary file not shown.
Loading

0 comments on commit 4f0f168

Please sign in to comment.