REF: App entry

This commit is contained in:
Marcos Rodriguez Velez 2024-05-14 17:03:47 -04:00
parent cf9ea0edca
commit 37a8704fec
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
4 changed files with 54 additions and 36 deletions

32
App.tsx
View File

@ -1,27 +1,17 @@
import 'react-native-gesture-handler'; // should be on top
import React, { Suspense, lazy, useEffect } from 'react';
import { NativeModules, Platform, UIManager, useColorScheme, LogBox } from 'react-native';
import React, { useEffect } from 'react';
import { NativeModules, Platform, useColorScheme } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { navigationRef } from './NavigationService';
import { BlueDefaultTheme, BlueDarkTheme } from './components/themes';
import { NavigationProvider } from './components/NavigationProvider';
import MainRoot from './navigation';
import { useStorage } from './blue_modules/storage-context';
import Biometric from './class/biometrics';
const CompanionDelegates = lazy(() => import('./components/CompanionDelegates'));
import { BlueStorageProvider } from './blue_modules/storage-context';
import MasterView from './MasterView';
import { SettingsProvider } from './components/Context/SettingsContext';
const { SplashScreen } = NativeModules;
LogBox.ignoreLogs(['Require cycle:', 'Battery state `unknown` and monitoring disabled, this is normal for simulators and tvOS.']);
if (Platform.OS === 'android') {
if (UIManager.setLayoutAnimationEnabledExperimental) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
}
const App = () => {
const { walletsInitialized } = useStorage();
const colorScheme = useColorScheme();
useEffect(() => {
@ -35,13 +25,11 @@ const App = () => {
<NavigationContainer ref={navigationRef} theme={colorScheme === 'dark' ? BlueDarkTheme : BlueDefaultTheme}>
<NavigationProvider>
<SafeAreaProvider>
<Biometric />
<MainRoot />
{walletsInitialized && (
<Suspense>
<CompanionDelegates />
</Suspense>
)}
<BlueStorageProvider>
<SettingsProvider>
<MasterView />
</SettingsProvider>
</BlueStorageProvider>
</SafeAreaProvider>
</NavigationProvider>
</NavigationContainer>

33
MasterView.tsx Normal file
View File

@ -0,0 +1,33 @@
import 'react-native-gesture-handler'; // should be on top
import React, { Suspense, lazy, useEffect } from 'react';
import { NativeModules, Platform } from 'react-native';
import MainRoot from './navigation';
import { useStorage } from './blue_modules/storage-context';
import Biometric from './class/biometrics';
const CompanionDelegates = lazy(() => import('./components/CompanionDelegates'));
const { SplashScreen } = NativeModules;
const MasterView = () => {
const { walletsInitialized } = useStorage();
useEffect(() => {
if (Platform.OS === 'ios') {
// Call hide to setup the listener on the native side
SplashScreen?.addObserver();
}
}, []);
return (
<>
<Biometric />
<MainRoot />
{walletsInitialized && (
<Suspense>
<CompanionDelegates />
</Suspense>
)}
</>
);
};
export default MasterView;

View File

@ -1,6 +1,6 @@
import 'react-native-gesture-handler'; // should be on top
import React, { useEffect, useRef, useCallback, lazy, Suspense } from 'react';
import { AppState, NativeModules, NativeEventEmitter, Linking, Platform, UIManager, LogBox, AppStateStatus } from 'react-native';
import { AppState, NativeModules, NativeEventEmitter, Linking, Platform, UIManager, AppStateStatus } from 'react-native';
import { CommonActions } from '@react-navigation/native';
import { navigationRef } from '../NavigationService';
import { Chain } from '../models/bitcoinUnits';
@ -24,8 +24,6 @@ const WatchConnectivity = lazy(() => import('../WatchConnectivity'));
// @ts-ignore: NativeModules.EventEmitter is not typed
const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.EventEmitter) : undefined;
LogBox.ignoreLogs(['Require cycle:', 'Battery state `unknown` and monitoring disabled, this is normal for simulators and tvOS.']);
const ClipboardContentType = Object.freeze({
BITCOIN: 'BITCOIN',
LIGHTNING: 'LIGHTNING',

View File

@ -1,12 +1,9 @@
import './shim.js';
import React, { useEffect } from 'react';
import { AppRegistry } from 'react-native';
import { AppRegistry, LogBox, Platform, UIManager } from 'react-native';
import App from './App';
import { BlueStorageProvider } from './blue_modules/storage-context';
import A from './blue_modules/analytics';
import { SettingsProvider } from './components/Context/SettingsContext';
import { restoreSavedPreferredFiatCurrencyAndExchangeFromStorage } from './blue_modules/currency';
if (!Error.captureStackTrace) {
@ -14,19 +11,21 @@ if (!Error.captureStackTrace) {
Error.captureStackTrace = () => {};
}
LogBox.ignoreLogs(['Require cycle:', 'Battery state `unknown` and monitoring disabled, this is normal for simulators and tvOS.']);
if (Platform.OS === 'android') {
if (UIManager.setLayoutAnimationEnabledExperimental) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
}
const BlueAppComponent = () => {
useEffect(() => {
restoreSavedPreferredFiatCurrencyAndExchangeFromStorage();
A(A.ENUM.INIT);
}, []);
return (
<BlueStorageProvider>
<SettingsProvider>
<App />
</SettingsProvider>
</BlueStorageProvider>
);
return <App />;
};
AppRegistry.registerComponent('BlueWallet', () => BlueAppComponent);