From 0ecf95c097349b69d628671abf703003a9a0d18f Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Tue, 10 Oct 2023 14:22:02 +0300 Subject: [PATCH] fix: edit limit price (#2748) --- .../CreateOrder/EditLimitPrice.tsx | 10 +++-- .../ShowTokenActions/ClearQuantities.tsx | 3 +- .../ShowTokenActions/TopTokenActions.tsx | 3 +- .../Swap/common/AmountCard/AmountCard.json | 40 +++++++++---------- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditLimitPrice.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditLimitPrice.tsx index 53d342cf13..74ae20f445 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditLimitPrice.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditLimitPrice.tsx @@ -19,6 +19,7 @@ export const EditLimitPrice = () => { const {numberLocale} = useLanguage() const [text, setText] = React.useState('') const wallet = useSelectedWallet() + const inputRef = React.useRef(null) const {orderData, limitPriceChanged} = useSwap() const sellTokenInfo = useTokenInfo({wallet, tokenId: orderData.amounts.sell.tokenId}) @@ -33,7 +34,8 @@ export const EditLimitPrice = () => { React.useEffect(() => { if (orderData.type === 'limit') { - setText(Quantities.format(orderData.limitPrice ?? Quantities.zero, denomination, PRECISION)) + !inputRef?.current?.isFocused() && + setText(Quantities.format(orderData.limitPrice ?? Quantities.zero, denomination, PRECISION)) } else { setText( Quantities.format(orderData.selectedPoolCalculation?.prices.market ?? Quantities.zero, denomination, PRECISION), @@ -54,7 +56,7 @@ export const EditLimitPrice = () => { {disabled ? strings.marketPrice : strings.limitPrice} - + @@ -70,8 +72,9 @@ type AmountInputProps = { value?: string onChange(value: string): void editable: boolean + inputRef?: React.RefObject } -const AmountInput = ({onChange, value, editable}: AmountInputProps) => { +const AmountInput = ({onChange, value, editable, inputRef}: AmountInputProps) => { return ( { style={styles.amountInput} underlineColorAndroid="transparent" editable={editable} + ref={inputRef} /> ) } diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/ClearQuantities.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/ClearQuantities.tsx index 28c49f79e6..a5873c84c6 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/ClearQuantities.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/ClearQuantities.tsx @@ -1,6 +1,6 @@ import {useSwap} from '@yoroi/swap' import React from 'react' -import {StyleSheet, Text} from 'react-native' +import {Keyboard, StyleSheet, Text} from 'react-native' import {TouchableOpacity} from 'react-native-gesture-handler' import {COLORS} from '../../../../../../theme' @@ -13,6 +13,7 @@ export const ClearQuantities = () => { const {poolDefaulted} = useSwapTouched() const handleReset = () => { + Keyboard.dismiss() resetQuantities() poolDefaulted() } diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/TopTokenActions.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/TopTokenActions.tsx index 561123cbc4..d60ef48368 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/TopTokenActions.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/ShowTokenActions/TopTokenActions.tsx @@ -1,6 +1,6 @@ import {useSwap, useSwapPoolsByPair} from '@yoroi/swap' import React from 'react' -import {StyleSheet, View} from 'react-native' +import {Keyboard, StyleSheet, View} from 'react-native' import {TouchableOpacity} from 'react-native-gesture-handler' import {Icon} from '../../../../../../components' @@ -40,6 +40,7 @@ export const TopTokenActions = () => { } const handleRefresh = () => { + Keyboard.dismiss() refetch() } diff --git a/apps/wallet-mobile/translations/messages/src/features/Swap/common/AmountCard/AmountCard.json b/apps/wallet-mobile/translations/messages/src/features/Swap/common/AmountCard/AmountCard.json index 7fa3933302..51c7130421 100644 --- a/apps/wallet-mobile/translations/messages/src/features/Swap/common/AmountCard/AmountCard.json +++ b/apps/wallet-mobile/translations/messages/src/features/Swap/common/AmountCard/AmountCard.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Select token", "file": "src/features/Swap/common/AmountCard/AmountCard.tsx", "start": { - "line": 134, + "line": 135, "column": 15, - "index": 4170 + "index": 4171 }, "end": { - "line": 137, + "line": 138, "column": 3, - "index": 4253 + "index": 4254 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!Current Balance", "file": "src/features/Swap/common/AmountCard/AmountCard.tsx", "start": { - "line": 138, + "line": 139, "column": 18, - "index": 4273 + "index": 4274 }, "end": { - "line": 141, + "line": 142, "column": 3, - "index": 4362 + "index": 4363 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Not enough balance", "file": "src/features/Swap/common/AmountCard/AmountCard.tsx", "start": { - "line": 142, + "line": 143, "column": 20, - "index": 4384 + "index": 4385 }, "end": { - "line": 145, + "line": 146, "column": 3, - "index": 4478 + "index": 4479 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Not enough supply in the pool", "file": "src/features/Swap/common/AmountCard/AmountCard.tsx", "start": { - "line": 146, + "line": 147, "column": 19, - "index": 4499 + "index": 4500 }, "end": { - "line": 149, + "line": 150, "column": 3, - "index": 4603 + "index": 4604 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!! This pair is not available in any liquidity pool", "file": "src/features/Swap/common/AmountCard/AmountCard.tsx", "start": { - "line": 150, + "line": 151, "column": 10, - "index": 4615 + "index": 4616 }, "end": { - "line": 153, + "line": 154, "column": 3, - "index": 4730 + "index": 4731 } } ] \ No newline at end of file