mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
REF: App entry
This commit is contained in:
parent
cf9ea0edca
commit
37a8704fec
32
App.tsx
32
App.tsx
@ -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
33
MasterView.tsx
Normal 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;
|
@ -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',
|
||||
|
21
index.js
21
index.js
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user