Skip to content

Commit

Permalink
chore(bridge): hide keyboard when bottom sheet active & solve typescr…
Browse files Browse the repository at this point in the history
…ipt issues
  • Loading branch information
ArturHoncharuk committed Dec 10, 2024
1 parent 9162578 commit 8cd4742
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/features/bridge/context/Bridge.Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createContextSelector } from '@utils/createContextSelector';
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
Config as BridgeConfigModel,
BridgeDataState,
FeeData,
Token
} from '@lib/bridgeSDK/models/types';
Expand Down Expand Up @@ -45,7 +46,8 @@ export const BridgeContext = () => {
const [destination, setDestination] = useState(DEFAULT_ETH_NETWORK);
const networkNativeToken = Config.NETWORK_NATIVE_COIN[from.id];

const [selectedBridgeData, setSelectedBridgeData] = useState(null);
const [selectedBridgeData, setSelectedBridgeData] =
useState<BridgeDataState | null>(null);
const [selectedTokenPairs, setSelectedTokenPairs] = useState<Token[] | null>(
null
);
Expand Down
12 changes: 6 additions & 6 deletions src/features/bridge/templates/BridgeForm/BridgeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useRef,
useState
} from 'react';
import { styles } from './styles';
import { Keyboard, LayoutChangeEvent, View, ViewStyle } from 'react-native';
import {
KeyboardDismissingView,
Spacer,
Expand All @@ -17,13 +17,14 @@ import Animated, {
useSharedValue,
withTiming
} from 'react-native-reanimated';
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { useTranslation } from 'react-i18next';
import { styles } from './styles';
import { BottomSheetRef } from '@components/composite';
import { useBridgeContextData } from '@features/bridge/context';
import { useKeyboardHeight } from '@hooks';
import { DEVICE_HEIGHT } from '@constants/variables';
import { PrimaryButton } from '@components/modular';
import { View, ViewStyle } from 'react-native';
import { scale, verticalScale } from '@utils/scaling';
import { isAndroid } from '@utils/isPlatform';
import { COLORS } from '@constants/colors';
Expand All @@ -34,15 +35,13 @@ import { parseUnits } from 'ethers/lib/utils';
import { BottomSheetBridgePreview } from '@features/bridge/templates/BottomSheetBridgePreview/BottomSheetBridgePreview';
import { getFeeData } from '@features/bridge/utils/getBridgeFee';
import { FeeData } from '@lib/bridgeSDK/models/types';
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { NumberUtils } from '@utils/number';
import {
DEFAULT_TRANSACTION,
EMPTY_FEE_DATA
} from '@features/bridge/constants';
import { getAllBridgeTokenBalance } from '@lib';
import { useWalletStore } from '@entities/wallet';
import { LayoutChangeEvent } from 'react-native/Libraries/Types/CoreEventTypes';

export const BridgeForm = () => {
const { wallet: selectedWallet } = useWalletStore();
Expand Down Expand Up @@ -169,6 +168,7 @@ export const BridgeForm = () => {
}, [setProcessingTransaction]);

const goToPreview = useCallback(async () => {
Keyboard.dismiss();
setDefaultOptions();
const isMax =
amountToBridge ===
Expand Down Expand Up @@ -240,7 +240,7 @@ export const BridgeForm = () => {
setSelectedBridgeData({
// @ts-ignore
...selectedBridgeData,
pairs
...pairs
});
});
}
Expand Down Expand Up @@ -352,7 +352,7 @@ export const BridgeForm = () => {
<Animated.View style={[margin]}>
<PrimaryButton onPress={goToPreview} disabled={disabledButton}>
{templateDataLoader ? (
<Spinner customSize={15} />
<Spinner />
) : (
<Text color={disabledButton ? COLORS.brand300 : COLORS.neutral0}>
{error ? t('bridge.insufficient.funds') : t('common.review')}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/bridgeSDK/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { BigNumber, BigNumberish, ethers } from 'ethers';
import { AccountDBModel } from '@database';
import { CryptoCurrencyCode } from '@appTypes';

export type BridgeDataState = {
from: string;
destination: string;
bridgeConfig: unknown;
ownerAddress?: string;
pairs: Token[][];
};

export type BridgeNetwork = 'eth' | 'bsc';
export type Network = BridgeNetwork | 'amb';
export type RelayUrls = { [net in BridgeNetwork]: string };
Expand Down

0 comments on commit 8cd4742

Please sign in to comment.