mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-04 12:18:10 +01:00
REF: Use Unlock screen for splash screen
This commit is contained in:
parent
a5b6752731
commit
1359c3b625
3 changed files with 26 additions and 51 deletions
|
@ -1,17 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import LottieView from 'lottie-react-native';
|
|
||||||
import * as NavigationService from './NavigationService';
|
|
||||||
import { StackActions } from '@react-navigation/native';
|
|
||||||
|
|
||||||
const LoadingScreen = () => {
|
|
||||||
const replaceStackNavigation = () => {
|
|
||||||
NavigationService.dispatch(StackActions.replace('UnlockWithScreenRoot'));
|
|
||||||
};
|
|
||||||
|
|
||||||
const onAnimationFinish = () => {
|
|
||||||
replaceStackNavigation();
|
|
||||||
};
|
|
||||||
|
|
||||||
return <LottieView source={require('./img/bluewalletsplash.json')} autoPlay loop={false} onAnimationFinish={onAnimationFinish} />;
|
|
||||||
};
|
|
||||||
export default LoadingScreen;
|
|
|
@ -75,7 +75,6 @@ import LNDViewInvoice from './screen/lnd/lndViewInvoice';
|
||||||
import LNDViewAdditionalInvoiceInformation from './screen/lnd/lndViewAdditionalInvoiceInformation';
|
import LNDViewAdditionalInvoiceInformation from './screen/lnd/lndViewAdditionalInvoiceInformation';
|
||||||
import LnurlPay from './screen/lnd/lnurlPay';
|
import LnurlPay from './screen/lnd/lnurlPay';
|
||||||
import LnurlPaySuccess from './screen/lnd/lnurlPaySuccess';
|
import LnurlPaySuccess from './screen/lnd/lnurlPaySuccess';
|
||||||
import LoadingScreen from './LoadingScreen';
|
|
||||||
import UnlockWith from './UnlockWith';
|
import UnlockWith from './UnlockWith';
|
||||||
import DrawerList from './screen/wallets/drawerList';
|
import DrawerList from './screen/wallets/drawerList';
|
||||||
import { isCatalyst, isTablet } from './blue_modules/environment';
|
import { isCatalyst, isTablet } from './blue_modules/environment';
|
||||||
|
@ -312,13 +311,6 @@ const ScanQRCodeRoot = () => (
|
||||||
</ScanQRCodeStack.Navigator>
|
</ScanQRCodeStack.Navigator>
|
||||||
);
|
);
|
||||||
|
|
||||||
const LoadingScreenStack = createStackNavigator();
|
|
||||||
const LoadingScreenRoot = () => (
|
|
||||||
<LoadingScreenStack.Navigator name="LoadingScreenRoot" mode="modal" screenOptions={{ headerShown: false }}>
|
|
||||||
<LoadingScreenStack.Screen name="LoadingScreen" component={LoadingScreen} />
|
|
||||||
</LoadingScreenStack.Navigator>
|
|
||||||
);
|
|
||||||
|
|
||||||
const UnlockWithScreenStack = createStackNavigator();
|
const UnlockWithScreenStack = createStackNavigator();
|
||||||
const UnlockWithScreenRoot = () => (
|
const UnlockWithScreenRoot = () => (
|
||||||
<UnlockWithScreenStack.Navigator name="UnlockWithScreenRoot" screenOptions={{ headerShown: false }}>
|
<UnlockWithScreenStack.Navigator name="UnlockWithScreenRoot" screenOptions={{ headerShown: false }}>
|
||||||
|
@ -424,8 +416,7 @@ const LappBrowserStackRoot = () => {
|
||||||
|
|
||||||
const InitStack = createStackNavigator();
|
const InitStack = createStackNavigator();
|
||||||
const InitRoot = () => (
|
const InitRoot = () => (
|
||||||
<InitStack.Navigator screenOptions={defaultScreenOptions} initialRouteName="LoadingScreenRoot">
|
<InitStack.Navigator screenOptions={defaultScreenOptions} initialRouteName="UnlockWithScreenRoot">
|
||||||
<InitStack.Screen name="LoadingScreenRoot" component={LoadingScreenRoot} options={{ headerShown: false, animationEnabled: false }} />
|
|
||||||
<InitStack.Screen
|
<InitStack.Screen
|
||||||
name="UnlockWithScreenRoot"
|
name="UnlockWithScreenRoot"
|
||||||
component={UnlockWithScreenRoot}
|
component={UnlockWithScreenRoot}
|
||||||
|
@ -479,7 +470,7 @@ const Navigation = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RootStack.Navigator mode="modal" screenOptions={defaultScreenOptions} initialRouteName="LoadingScreenRoot">
|
<RootStack.Navigator mode="modal" screenOptions={defaultScreenOptions} initialRouteName="UnlockWithScreenRoot">
|
||||||
{/* stacks */}
|
{/* stacks */}
|
||||||
<RootStack.Screen name="WalletsRoot" component={WalletsRoot} options={{ headerShown: false }} />
|
<RootStack.Screen name="WalletsRoot" component={WalletsRoot} options={{ headerShown: false }} />
|
||||||
<RootStack.Screen name="AddWalletRoot" component={AddWalletRoot} options={{ headerShown: false }} />
|
<RootStack.Screen name="AddWalletRoot" component={AddWalletRoot} options={{ headerShown: false }} />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import { View, Image, TouchableOpacity, StyleSheet, StatusBar, ActivityIndicator, useColorScheme } from 'react-native';
|
import { View, Image, TouchableOpacity, StyleSheet, StatusBar, ActivityIndicator, useColorScheme, LayoutAnimation } from 'react-native';
|
||||||
import { Icon } from 'react-native-elements';
|
import { Icon } from 'react-native-elements';
|
||||||
import Biometric from './class/biometrics';
|
import Biometric from './class/biometrics';
|
||||||
import LottieView from 'lottie-react-native';
|
import LottieView from 'lottie-react-native';
|
||||||
|
@ -44,6 +44,7 @@ const UnlockWith = () => {
|
||||||
const [biometricType, setBiometricType] = useState(false);
|
const [biometricType, setBiometricType] = useState(false);
|
||||||
const [isStorageEncryptedEnabled, setIsStorageEncryptedEnabled] = useState(false);
|
const [isStorageEncryptedEnabled, setIsStorageEncryptedEnabled] = useState(false);
|
||||||
const [isAuthenticating, setIsAuthenticating] = useState(false);
|
const [isAuthenticating, setIsAuthenticating] = useState(false);
|
||||||
|
const [animationDidFinish, setAnimationDidFinish] = useState(false);
|
||||||
const colorScheme = useColorScheme();
|
const colorScheme = useColorScheme();
|
||||||
|
|
||||||
const initialRender = async () => {
|
const initialRender = async () => {
|
||||||
|
@ -51,14 +52,8 @@ const UnlockWith = () => {
|
||||||
if (await Biometric.isBiometricUseCapableAndEnabled()) {
|
if (await Biometric.isBiometricUseCapableAndEnabled()) {
|
||||||
biometricType = await Biometric.biometricType();
|
biometricType = await Biometric.biometricType();
|
||||||
}
|
}
|
||||||
const storageIsEncrypted = await isStorageEncrypted();
|
|
||||||
setIsStorageEncryptedEnabled(storageIsEncrypted);
|
|
||||||
setBiometricType(biometricType);
|
setBiometricType(biometricType);
|
||||||
if (unlockOnComponentMount) {
|
|
||||||
if (!biometricType || storageIsEncrypted) {
|
|
||||||
unlockWithKey();
|
|
||||||
} else if (typeof biometricType === 'string') unlockWithBiometrics();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -126,21 +121,27 @@ const UnlockWith = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!biometricType && !isStorageEncryptedEnabled) {
|
const onAnimationFinish = async () => {
|
||||||
return <View />;
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
||||||
} else {
|
if (unlockOnComponentMount) {
|
||||||
|
const storageIsEncrypted = await isStorageEncrypted();
|
||||||
|
setIsStorageEncryptedEnabled(storageIsEncrypted);
|
||||||
|
if (!biometricType || storageIsEncrypted) {
|
||||||
|
unlockWithKey();
|
||||||
|
} else if (typeof biometricType === 'string') unlockWithBiometrics();
|
||||||
|
}
|
||||||
|
setAnimationDidFinish(true);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.root}>
|
<SafeAreaView style={styles.root}>
|
||||||
<StatusBar barStyle="default" />
|
<StatusBar barStyle="default" />
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<LottieView source={require('./img/bluewalletsplash.json')} progress={1} loop={false} />
|
<LottieView source={require('./img/bluewalletsplash.json')} autoPlay loop={false} onAnimationFinish={onAnimationFinish} />
|
||||||
<View style={styles.biometric}>
|
<View style={styles.biometric}>{animationDidFinish && <View style={styles.biometricRow}>{renderUnlockOptions()}</View>}</View>
|
||||||
<View style={styles.biometricRow}>{renderUnlockOptions()}</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UnlockWith;
|
export default UnlockWith;
|
||||||
|
|
Loading…
Add table
Reference in a new issue