Page MenuHomePhabricator

D5912.diff
No OneTemporary

D5912.diff

diff --git a/native/navigation/app-navigator.react.js b/native/navigation/app-navigator.react.js
--- a/native/navigation/app-navigator.react.js
+++ b/native/navigation/app-navigator.react.js
@@ -17,6 +17,7 @@
import PushHandler from '../push/push-handler.react';
import { getPersistor } from '../redux/persist';
import { RootContext } from '../root-context';
+import { useLoadCommFonts } from '../themes/fonts';
import { waitForInteractions } from '../utils/timers';
import ActionResultModal from './action-result-modal.react';
import { createOverlayNavigator } from './overlay-navigator.react';
@@ -59,6 +60,8 @@
function AppNavigator(props: AppNavigatorProps): React.Node {
const { navigation } = props;
+ const fontsLoaded = useLoadCommFonts();
+
const rootContext = React.useContext(RootContext);
const storeLoadedFromLocalDatabase = useSelector(state => state.storeLoaded);
const setNavStateInitialized =
@@ -73,7 +76,7 @@
] = React.useState(splashScreenHasHidden);
React.useEffect(() => {
- if (localSplashScreenHasHidden) {
+ if (localSplashScreenHasHidden || !fontsLoaded) {
return;
}
splashScreenHasHidden = true;
@@ -85,7 +88,7 @@
setLocalSplashScreenHasHidden(true);
}
})();
- }, [localSplashScreenHasHidden]);
+ }, [localSplashScreenHasHidden, fontsLoaded]);
let pushHandler;
if (localSplashScreenHasHidden) {
diff --git a/native/package.json b/native/package.json
--- a/native/package.json
+++ b/native/package.json
@@ -66,6 +66,7 @@
"base-64": "^0.1.0",
"expo": "47.0.8",
"expo-dev-client": "~2.0.1",
+ "expo-font": "~11.0.1",
"expo-haptics": "~12.0.1",
"expo-image-manipulator": "~11.0.0",
"expo-media-library": "~15.0.0",
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -44,9 +44,9 @@
import { RootContext } from './root-context';
import Socket from './socket.react';
import { StaffContextProvider } from './staff/staff-context.provider.react';
+import { useLoadCommFonts } from './themes/fonts';
import { DarkTheme, LightTheme } from './themes/navigation';
import ThemeHandler from './themes/theme-handler.react';
-import './themes/fonts';
LogBox.ignoreLogs([
// react-native-reanimated
@@ -68,6 +68,10 @@
const navDispatchRef = React.useRef();
const navStateInitializedRef = React.useRef(false);
+ // We call this here to start the loading process
+ // We gate the UI on the fonts loading in AppNavigator
+ useLoadCommFonts();
+
const [navContext, setNavContext] = React.useState(null);
const updateNavContext = React.useCallback(() => {
if (
diff --git a/native/themes/fonts.js b/native/themes/fonts.js
--- a/native/themes/fonts.js
+++ b/native/themes/fonts.js
@@ -1,15 +1,34 @@
// @flow
-import FeatherIcon from '@expo/vector-icons/Feather';
-import FontAwesomeIcon from '@expo/vector-icons/FontAwesome';
-import IonIcon from '@expo/vector-icons/Ionicons';
-import MaterialCommunityIcon from '@expo/vector-icons/MaterialCommunityIcons';
+import EntypoIcon from '@expo/vector-icons/Entypo';
+import Feather from '@expo/vector-icons/Feather';
+import FontAwesome from '@expo/vector-icons/FontAwesome';
+import FontAwesome5 from '@expo/vector-icons/FontAwesome5';
+import Ionicons from '@expo/vector-icons/Ionicons'
+import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
import MaterialIcon from '@expo/vector-icons/MaterialIcons';
+import { useFonts } from 'expo-font';
-// This is only necessary on iOS if we switch to use_frameworks
-// We're keeping it here in case we ever do that again
-FeatherIcon.loadFont();
-FontAwesomeIcon.loadFont();
-IonIcon.loadFont();
-MaterialCommunityIcon.loadFont();
-MaterialIcon.loadFont();
+import SWMansionIcons from '../fonts/SWMansionIcons.ttf';
+import CommIcons from '../fonts/CommIcons.ttf';
+
+function useLoadCommFonts(): boolean {
+ const [fontsLoaded] = useFonts({
+ ...EntypoIcon.font,
+ ...Feather.font,
+ ...FontAwesome.font,
+ ...FontAwesome5.font,
+ ...Ionicons.font,
+ ...MaterialCommunityIcons.font,
+ ...MaterialIcon.font,
+ SWMansionIcons,
+ CommIcons,
+ });
+ // In production we bundle the fonts directly, so we don't need to wait
+ if (!__DEV__) {
+ return true;
+ }
+ return fontsLoaded;
+}
+
+export { useLoadCommFonts };
diff --git a/yarn.lock b/yarn.lock
--- a/yarn.lock
+++ b/yarn.lock
@@ -10159,7 +10159,7 @@
dependencies:
uuid "^3.4.0"
-expo-font@~11.0.1:
+expo-font@^11.0.1, expo-font@~11.0.1:
version "11.0.1"
resolved "https://registry.yarnpkg.com/expo-font/-/expo-font-11.0.1.tgz#0758ce4e505995d0193a33e3c4325b35bf1fb7f7"
integrity sha512-LGAIluWZfru0J0n87dzb6pwAB6TVMTEiLcsd/ktozzbn4DlN7SeQy40+ruU6bvAKCOGrnRneYbKSIOGkrd7oNg==

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 3:08 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582232
Default Alt Text
D5912.diff (4 KB)

Event Timeline