Skip to content

Commit

Permalink
fix(mobile): Topup QA fixes (#849)
Browse files Browse the repository at this point in the history
* fix(mobile): Topup QA fixes

* fix merge bug
  • Loading branch information
voloshinskii authored May 15, 2024
1 parent 114c556 commit 2664134
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/mobile/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const defaultConfig: Partial<AppConfigVars> = {
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,

Expand Down
40 changes: 33 additions & 7 deletions packages/mobile/src/core/BatterySend/BatterySend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -114,6 +115,7 @@ export const BatterySend: React.FC<BatterySendProps> = ({ route }) => {
});

const handleContinue = useCallback(async () => {
Keyboard.dismiss();
const parsedAmount = parseLocaleNumber(amount.value);

const commentCell = beginCell()
Expand Down Expand Up @@ -172,7 +174,7 @@ export const BatterySend: React.FC<BatterySendProps> = ({ route }) => {
const scrollRef = useRef<AnimatedScrollView>();

const handleAmountInputFocus = async () => {
await delay(300);
await delay(100);
scrollRef.current?.scrollToEnd();
};

Expand Down Expand Up @@ -231,6 +233,16 @@ export const BatterySend: React.FC<BatterySendProps> = ({ 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;
Expand Down Expand Up @@ -282,16 +294,26 @@ export const BatterySend: React.FC<BatterySendProps> = ({ route }) => {

const renderFlashIcon = useCallback(
(size: 'small' | 'large') => (
<Icon
size={size === 'small' ? 16 : 36}
name={'ic-flash-16'}
color="iconSecondary"
/>
<View
style={[
styles.flashIconContainer,
{
height: size === 'small' ? 24 : 36,
},
]}
>
<Icon
size={size === 'small' ? 16 : 36}
name={'ic-flash-16'}
color="iconSecondary"
/>
</View>
),
[],
);

const handleOpenSelectRechargeMethod = useCallback(() => {
Keyboard.dismiss();
openSelectRechargeMethodModal(
selectedJettonMaster,
(selected: string | undefined) => {
Expand Down Expand Up @@ -464,4 +486,8 @@ const styles = Steezy.create(({ colors }) => ({
alignItems: 'center',
backgroundColor: colors.buttonSecondaryBackground,
},
flashIconContainer: {
alignItems: 'center',
justifyContent: 'center',
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
16 changes: 14 additions & 2 deletions packages/mobile/src/shared/components/AmountInput/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,26 @@ const AmountInputComponent: React.FC<Props> = (props) => {
<S.FakeInput style={fakeInputStyle}>{value}</S.FakeInput>
</View>
</S.FakeInputWrap>
<S.AmountCode>{mainCurrencyCode}</S.AmountCode>
{typeof mainCurrencyCode === 'string' ? (
<S.AmountCode>{mainCurrencyCode}</S.AmountCode>
) : (
mainCurrencyCode
)}
</S.AmountContainer>
{isFiatAvailable ? (
<>
<S.SecondaryAmountContainer onPress={handleToggleFiat}>
<Text color="foregroundSecondary" numberOfLines={1}>
{secondaryAmount} {secondaryCurrencyCode}
{secondaryAmount}
</Text>
<Text> </Text>
{typeof secondaryCurrencyCode === 'string' ? (
<Text numberOfLines={1} color={'foregroundSecondary'}>
{secondaryCurrencyCode}
</Text>
) : (
secondaryCurrencyCode
)}
</S.SecondaryAmountContainer>
{!hideSwap ? (
<S.SwapButtonContainer>
Expand Down
53 changes: 32 additions & 21 deletions packages/shared/components/RefillBattery/RechargeMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,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 () => {
Expand All @@ -58,13 +65,15 @@ export const RechargeMethods = memo(() => {
return (
<View>
<List indent={false}>
<List.Item
chevron
leftContent={<TonIcon showDiamond />}
title={t('battery.other_ways.by_crypto.title', { symbol: 'TON' })}
onPress={handleRechargeBattery(false)}
subtitle={formatter.format(balances.ton, { currency: 'TON' })}
/>
{hasTonBalance && (
<List.Item
chevron
leftContent={<TonIcon showDiamond />}
title={t('battery.other_ways.by_crypto.title', { symbol: 'TON' })}
onPress={handleRechargeBattery(false)}
subtitle={formatter.format(balances.ton, { currency: 'TON' })}
/>
)}
{filteredJettonBalances.map((jettonBalance) => (
<List.Item
chevron
Expand All @@ -82,18 +91,20 @@ export const RechargeMethods = memo(() => {
})}
/>
))}
<List.Item
onPress={handleRechargeBattery(true)}
leftContent={
<Image
style={styles.icon.static}
source={require('@tonkeeper/uikit/assets/battery/gift.png')}
/>
}
title={t('battery.other_ways.gift.title')}
subtitle={t('battery.other_ways.gift.subtitle')}
chevron
/>
{hasAnyBalance && (
<List.Item
onPress={handleRechargeBattery(true)}
leftContent={
<Image
style={styles.icon.static}
source={require('@tonkeeper/uikit/assets/battery/gift.png')}
/>
}
title={t('battery.other_ways.gift.title')}
subtitle={t('battery.other_ways.gift.subtitle')}
chevron
/>
)}
{!isPromoDisabled && (
<List.Item
leftContent={
Expand Down
5 changes: 2 additions & 3 deletions packages/uikit/src/components/KeyboardSpacer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { memo } from 'react';

import Animated, { useAnimatedStyle } from 'react-native-reanimated';
import { useReanimatedKeyboardHeight, } from '../utils/keyboard';
import Animated, { useAnimatedKeyboard, useAnimatedStyle } from 'react-native-reanimated';

interface KeyboardSpacerProps {}

export const KeyboardSpacer = memo<KeyboardSpacerProps>((props) => {
const { height } = useReanimatedKeyboardHeight();
const { height } = useAnimatedKeyboard();

const style = useAnimatedStyle(() => ({
height: height.value,
Expand Down

0 comments on commit 2664134

Please sign in to comment.