MCPcopy
hub / github.com/BlueWallet/BlueWallet / UnlockWith

Function UnlockWith

screen/UnlockWith.tsx:82–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82const UnlockWith: React.FC = () => {
83 const [state, dispatch] = useReducer(reducer, initialState);
84 const isUnlockingWallets = useRef(false);
85 const keyboardOffset = useRef(new Animated.Value(0)).current;
86 const passwordInputRef = useRef<PasswordInputHandle>(null);
87 const passwordResolveRef = useRef<((password: string | undefined) => void) | null>(null);
88 const { setWalletsInitialized, isStorageEncrypted, startAndDecrypt } = useStorage();
89 const { deviceBiometricType, isBiometricUseCapableAndEnabled, isBiometricUseEnabled } = useBiometrics();
90
91 useEffect(() => {
92 setWalletsInitialized(false);
93 }, [setWalletsInitialized]);
94
95 useEffect(() => {
96 const windowHeight = Dimensions.get('window').height;
97
98 const animateToKeyboardPosition = (event: any, fallbackDuration = 220) => {
99 const keyboardTop = event?.endCoordinates?.screenY ?? windowHeight;
100 const keyboardHeight = Math.max(0, windowHeight - keyboardTop);
101 const target = -Math.min(Math.max(keyboardHeight * 0.28, 0), 96);
102
103 Animated.timing(keyboardOffset, {
104 toValue: target,
105 duration: event?.duration ?? fallbackDuration,
106 easing: Easing.out(Easing.cubic),
107 useNativeDriver: true,
108 }).start();
109 };
110
111 const resetPosition = (event?: any) => {
112 Animated.timing(keyboardOffset, {
113 toValue: 0,
114 duration: event?.duration ?? 220,
115 easing: Easing.out(Easing.cubic),
116 useNativeDriver: true,
117 }).start();
118 };
119
120 const subscriptions =
121 Platform.OS === 'ios'
122 ? [
123 Keyboard.addListener('keyboardWillChangeFrame', animateToKeyboardPosition),
124 Keyboard.addListener('keyboardWillHide', resetPosition),
125 ]
126 : [Keyboard.addListener('keyboardDidShow', animateToKeyboardPosition), Keyboard.addListener('keyboardDidHide', resetPosition)];
127
128 return () => {
129 subscriptions.forEach(sub => sub.remove());
130 };
131 }, [keyboardOffset]);
132
133 const successfullyAuthenticated = useCallback(() => {
134 setWalletsInitialized(true);
135 isUnlockingWallets.current = false;
136 }, [setWalletsInitialized]);
137
138 const unlockUsingBiometrics = useCallback(async () => {
139 if (isUnlockingWallets.current || state.isAuthenticating) return;

Callers

nothing calls this directly

Calls 11

useStorageFunction · 0.90
useBiometricsFunction · 0.90
unlockWithBiometricsFunction · 0.90
dispatchFunction · 0.85
startAndDecryptFunction · 0.85
triggerHapticFeedbackFunction · 0.85
startUnlockFunction · 0.85
renderUnlockOptionsFunction · 0.85
addListenerMethod · 0.65
getMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected