Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hiding create/edit wallet modal #4055

Merged
merged 4 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/expanded-state/WalletProfileState.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function WalletProfileState({
navigate(Routes.CHANGE_WALLET_SHEET);
}
};
if (ios || actionType !== 'Create') {
if (actionType !== 'Create') {
callback();
} else {
setCallbackAfterObtainingSeedsFromKeychainOrError(callback);
Expand Down
8 changes: 5 additions & 3 deletions src/helpers/isKeyboardOpen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Keyboard } from 'react-native';
import { RNKeyboard } from 'react-native-keyboard-area';
let keyboardOpen = false;

Keyboard.addListener('keyboardDidShow', () => (keyboardOpen = true));
Keyboard.addListener('keyboardDidHide', () => (keyboardOpen = false));
RNKeyboard.addKeyboardListener(height => {
keyboardOpen = height > 0;
});

export default function isKeyboardOpen() {
return keyboardOpen;
}
12 changes: 10 additions & 2 deletions src/navigation/bottom-sheet/views/BottomSheetRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import BottomSheet, {
BottomSheetBackdropProps,
} from '@gorhom/bottom-sheet';
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import { View } from 'react-native';
import { Keyboard, View } from 'react-native';
import type { ViewStyle } from 'react-native';
import { isKeyboardOpen } from '../../../helpers';
import {
CONTAINER_HEIGHT,
DEFAULT_BACKDROP_COLOR,
Expand Down Expand Up @@ -119,7 +120,14 @@ const BottomSheetRoute = ({
//#region effects
useEffect(() => {
if (removing === true && ref.current) {
ref.current.close();
// close keyboard before closing the modal
if (isKeyboardOpen() && android) {
Keyboard.dismiss();

ref.current.close();
} else {
ref.current.close();
}
}
}, [removing]);
//#endregion
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/onNavigationStateChange.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export function onNavigationStateChange(currentState) {
routeName === Routes.ENS_SEARCH_SHEET ||
routeName === Routes.ENS_ASSIGN_RECORDS_SHEET ||
(routeName === Routes.MODAL_SCREEN &&
Navigation.getActiveRoute().params?.type === 'contact_profile')
(Navigation.getActiveRoute().params?.type === 'contact_profile' ||
Navigation.getActiveRoute().params?.type === 'wallet_profile'))
) {
AndroidKeyboardAdjust.setAdjustPan();
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/screens/PinAuthenticationScreen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRoute } from '@react-navigation/core';
import lang from 'i18n-js';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Keyboard } from 'react-native';
import RainbowLogo from '../assets/rainbows/light.png';
import { Centered, Column, ColumnWithMargins } from '../components/layout';
import { Numpad, PinValue } from '../components/numpad';
Expand Down Expand Up @@ -48,6 +49,10 @@ const PinAuthenticationScreen = () => {

const finished = useRef(false);

useEffect(() => {
Keyboard.dismiss();
}, []);

useEffect(() => {
// See if the user previously tried and aborted
// If that's the case, we need to update the default
Expand Down