From 70103fe44045bdf9701dd6d4a39e0b671daeb291 Mon Sep 17 00:00:00 2001 From: Max Voloshinskii Date: Wed, 15 May 2024 03:39:43 +0300 Subject: [PATCH 1/2] fix(mobile): Topup QA fixes --- .../src/core/BatterySend/BatterySend.tsx | 40 +++++++++++--- .../AmountInput/AmountInput.style.ts | 3 ++ .../components/AmountInput/AmountInput.tsx | 16 +++++- .../RefillBattery/RechargeMethods.tsx | 53 +++++++++++-------- .../uikit/src/components/KeyboardSpacer.tsx | 5 +- 5 files changed, 84 insertions(+), 33 deletions(-) diff --git a/packages/mobile/src/core/BatterySend/BatterySend.tsx b/packages/mobile/src/core/BatterySend/BatterySend.tsx index 9916d043f..e6f4db182 100644 --- a/packages/mobile/src/core/BatterySend/BatterySend.tsx +++ b/packages/mobile/src/core/BatterySend/BatterySend.tsx @@ -17,7 +17,7 @@ import { AddressInput } from '$core/Send/steps/AddressStep/components'; import { SendAmount, SendRecipient } from '$core/Send/Send.interface'; import { AmountInput } from '$shared/components'; import { TextInput } from 'react-native-gesture-handler'; -import { asyncDebounce, parseLocaleNumber } from '$utils'; +import { asyncDebounce, isTransferOp, parseLocaleNumber, parseTonLink } from '$utils'; import { Address, AmountFormatter, ContractService, delay } from '@tonkeeper/core'; import TonWeb from 'tonweb'; import { formatter } from '$utils/formatter'; @@ -41,6 +41,7 @@ import { compareAddresses } from '$utils/address'; import { AnimatedScrollView } from 'react-native-reanimated/lib/typescript/reanimated2/component/ScrollView'; import { BatteryPackItem } from '$core/BatterySend/components'; import { t } from '@tonkeeper/shared/i18n'; +import { Keyboard } from 'react-native'; let dnsAbortController: null | AbortController = null; @@ -114,6 +115,7 @@ export const BatterySend: React.FC = ({ route }) => { }); const handleContinue = useCallback(async () => { + Keyboard.dismiss(); const parsedAmount = parseLocaleNumber(amount.value); const commentCell = beginCell() @@ -172,7 +174,7 @@ export const BatterySend: React.FC = ({ route }) => { const scrollRef = useRef(); const handleAmountInputFocus = async () => { - await delay(300); + await delay(100); scrollRef.current?.scrollToEnd(); }; @@ -231,6 +233,16 @@ export const BatterySend: React.FC = ({ route }) => { } try { + const link = parseTonLink(value); + + if (link.match && isTransferOp(link.operation) && Address.isValid(link.address)) { + if (link.query.bin) { + return false; + } + + value = link.address; + } + if (dnsAbortController) { dnsAbortController.abort(); dnsAbortController = null; @@ -282,16 +294,26 @@ export const BatterySend: React.FC = ({ route }) => { const renderFlashIcon = useCallback( (size: 'small' | 'large') => ( - + + + ), [], ); const handleOpenSelectRechargeMethod = useCallback(() => { + Keyboard.dismiss(); openSelectRechargeMethodModal( selectedJettonMaster, (selected: string | undefined) => { @@ -464,4 +486,8 @@ const styles = Steezy.create(({ colors }) => ({ alignItems: 'center', backgroundColor: colors.buttonSecondaryBackground, }, + flashIconContainer: { + alignItems: 'center', + justifyContent: 'center', + }, })); diff --git a/packages/mobile/src/shared/components/AmountInput/AmountInput.style.ts b/packages/mobile/src/shared/components/AmountInput/AmountInput.style.ts index 322c9b967..cc9c786fe 100644 --- a/packages/mobile/src/shared/components/AmountInput/AmountInput.style.ts +++ b/packages/mobile/src/shared/components/AmountInput/AmountInput.style.ts @@ -104,6 +104,9 @@ export const SecondaryAmountContainer = styled.TouchableOpacity.attrs({ border: 1.5px solid ${({ theme }) => theme.colors.backgroundTertiary}; border-radius: ${ns(100)}px; margin-top: ${ns(8)}px; + flex-direction: row; + align-items: center; + justify-content: center; `; export const SwapButtonContainer = styled.View` diff --git a/packages/mobile/src/shared/components/AmountInput/AmountInput.tsx b/packages/mobile/src/shared/components/AmountInput/AmountInput.tsx index ba7e4cd72..cc4476784 100644 --- a/packages/mobile/src/shared/components/AmountInput/AmountInput.tsx +++ b/packages/mobile/src/shared/components/AmountInput/AmountInput.tsx @@ -297,14 +297,26 @@ const AmountInputComponent: React.FC = (props) => { {value} - {mainCurrencyCode} + {typeof mainCurrencyCode === 'string' ? ( + {mainCurrencyCode} + ) : ( + mainCurrencyCode + )} {isFiatAvailable ? ( <> - {secondaryAmount} {secondaryCurrencyCode} + {secondaryAmount} + + {typeof secondaryCurrencyCode === 'string' ? ( + + {secondaryCurrencyCode} + + ) : ( + secondaryCurrencyCode + )} {!hideSwap ? ( diff --git a/packages/shared/components/RefillBattery/RechargeMethods.tsx b/packages/shared/components/RefillBattery/RechargeMethods.tsx index 23d8a0129..bda927fe6 100644 --- a/packages/shared/components/RefillBattery/RechargeMethods.tsx +++ b/packages/shared/components/RefillBattery/RechargeMethods.tsx @@ -34,14 +34,21 @@ export const RechargeMethods = memo(() => { reload(); }, []); + const hasTonBalance = balances.ton !== '0'; + const hasJettonBalances = !!filteredJettonBalances.length; + const hasAnyBalance = hasTonBalance && hasJettonBalances; + const handleRechargeBattery = useCallback( (withAddressSelect?: boolean, jettonMaster?: string) => async () => { nav.navigate(AppStackRouteNames.BatterySend, { recipient: withAddressSelect ? undefined : tk.wallet.address.ton.friendly, - jettonMaster, + jettonMaster: + jettonMaster ?? hasTonBalance + ? undefined + : filteredJettonBalances[0]?.jettonAddress, }); }, - [], + [filteredJettonBalances, hasTonBalance], ); const handleNavigateToPromo = useCallback(async () => { @@ -55,13 +62,15 @@ export const RechargeMethods = memo(() => { return ( - } - title={t('battery.other_ways.by_crypto.title', { symbol: 'TON' })} - onPress={handleRechargeBattery(false)} - subtitle={formatter.format(balances.ton, { currency: 'TON' })} - /> + {hasTonBalance && ( + } + title={t('battery.other_ways.by_crypto.title', { symbol: 'TON' })} + onPress={handleRechargeBattery(false)} + subtitle={formatter.format(balances.ton, { currency: 'TON' })} + /> + )} {filteredJettonBalances.map((jettonBalance) => ( { })} /> ))} - - } - title={t('battery.other_ways.gift.title')} - subtitle={t('battery.other_ways.gift.subtitle')} - chevron - /> + {hasAnyBalance && ( + + } + title={t('battery.other_ways.gift.title')} + subtitle={t('battery.other_ways.gift.subtitle')} + chevron + /> + )} ((props) => { - const { height } = useReanimatedKeyboardHeight(); + const { height } = useAnimatedKeyboard(); const style = useAnimatedStyle(() => ({ height: height.value, From 18d1d9f13904494e68e0a3687f8bacdc9699b8ba Mon Sep 17 00:00:00 2001 From: Max Voloshinskii Date: Wed, 15 May 2024 03:42:38 +0300 Subject: [PATCH 2/2] fix merge bug --- packages/mobile/src/config/index.ts | 2 +- .../components/RefillBattery/RechargeMethods.tsx | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/mobile/src/config/index.ts b/packages/mobile/src/config/index.ts index 193587102..32d7802cd 100644 --- a/packages/mobile/src/config/index.ts +++ b/packages/mobile/src/config/index.ts @@ -111,7 +111,7 @@ const defaultConfig: Partial = { disable_battery_send: false, disable_battery_iap_module: Platform.OS === 'android', // Enable for iOS, disable for Android disable_battery_promo_module: true, - disable_battery_crypto_recharge_module: true, + disable_battery_crypto_recharge_module: false, disable_signer: true, disable_ledger: true, diff --git a/packages/shared/components/RefillBattery/RechargeMethods.tsx b/packages/shared/components/RefillBattery/RechargeMethods.tsx index 4809904ca..64b6f3ac5 100644 --- a/packages/shared/components/RefillBattery/RechargeMethods.tsx +++ b/packages/shared/components/RefillBattery/RechargeMethods.tsx @@ -105,18 +105,6 @@ export const RechargeMethods = memo(() => { chevron /> )} - - } - title={t('battery.other_ways.gift.title')} - subtitle={t('battery.other_ways.gift.subtitle')} - chevron - /> {!isPromoDisabled && (