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(mobile): fix interactions while closing modal #778

Merged
merged 1 commit into from
Mar 26, 2024
Merged
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
fix(mobile): fix interactions while closing modal
sorokin0andrey committed Mar 26, 2024
commit 701dddc66a9a55b261c38717fa7d0fb39da8a84b
17 changes: 12 additions & 5 deletions packages/shared/modals/AddWalletModal.tsx
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import { tk } from '@tonkeeper/mobile/src/wallet';
import { useUnlockVault } from '@tonkeeper/mobile/src/core/ModalContainer/NFTOperations/useUnlockVault';
import { getLastEnteredPasscode } from '@tonkeeper/mobile/src/store/wallet/sagas';
import { config } from '@tonkeeper/mobile/src/config';
import { InteractionManager } from 'react-native';

interface AddWalletModalProps {
isTonConnect?: boolean;
@@ -89,7 +90,9 @@ export const AddWalletModal = memo<AddWalletModalProps>(({ isTonConnect }) => {
<List.Item
onPress={() => {
nav.goBack();
nav.navigate('ImportWalletStack');
InteractionManager.runAfterInteractions(() => {
nav.navigate('ImportWalletStack');
});
}}
leftContentStyle={styles.iconContainer}
leftContent={<Icon name="ic-key-28" color="accentBlue" />}
@@ -104,7 +107,9 @@ export const AddWalletModal = memo<AddWalletModalProps>(({ isTonConnect }) => {
<List.Item
onPress={() => {
nav.goBack();
nav.navigate('AddWatchOnlyStack');
InteractionManager.runAfterInteractions(() => {
nav.navigate('AddWatchOnlyStack');
});
}}
leftContentStyle={styles.iconContainer}
leftContent={<Icon name="ic-magnifying-glass-28" color="accentBlue" />}
@@ -120,9 +125,11 @@ export const AddWalletModal = memo<AddWalletModalProps>(({ isTonConnect }) => {
<List.Item
onPress={() => {
nav.goBack();
nav.navigate('ImportWalletStack', {
screen: 'ImportWallet',
params: { testnet: true },
InteractionManager.runAfterInteractions(() => {
nav.navigate('ImportWalletStack', {
screen: 'ImportWallet',
params: { testnet: true },
});
});
}}
leftContentStyle={styles.iconContainer}
12 changes: 11 additions & 1 deletion packages/uikit/src/containers/Modal/SheetModal/SheetModal.tsx
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import { useTheme } from '../../../styles';

import { useSheetInternal } from '@tonkeeper/router';
import { Easing, ReduceMotion, useReducedMotion } from 'react-native-reanimated';
import { Handle, InteractionManager } from 'react-native';

export type SheetModalRef = BottomSheetModal;

@@ -64,10 +65,15 @@ export const SheetModal = memo(
return initialState === 'closed' ? -1 : 0;
}, []);

const interactionHandle = useRef<Handle | null>(null);

useEffect(() => {
delegateMethods({
present: () => bottomSheetRef.current?.snapToIndex(0),
close: () => bottomSheetRef.current?.close(),
close: () => {
interactionHandle.current = InteractionManager.createInteractionHandle();
bottomSheetRef.current?.close();
},
});
}, []);

@@ -83,6 +89,10 @@ export const SheetModal = memo(
);

const handleClose = useCallback(async () => {
if (interactionHandle.current !== null) {
InteractionManager.clearInteractionHandle(interactionHandle.current);
interactionHandle.current = null;
}
if (ignoreOnClose) {
return;
}