From 7e2e94a3bbfef81b5d73fa84ef8bac840d6de773 Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 15 Feb 2024 20:56:14 +0530 Subject: [PATCH] Removed AddCurrencies and using SelectCurrency to add currencies for conversion --- Navigation.ts | 4 - views/Settings/AddCurrencies.tsx | 156 --------------------------- views/Settings/CurrencyConverter.tsx | 16 ++- views/Settings/SelectCurrency.tsx | 50 ++++++--- 4 files changed, 44 insertions(+), 182 deletions(-) delete mode 100644 views/Settings/AddCurrencies.tsx diff --git a/Navigation.ts b/Navigation.ts index 468c9e5bf..3d59f9794 100644 --- a/Navigation.ts +++ b/Navigation.ts @@ -104,7 +104,6 @@ import Contacts from './views/Settings/Contacts'; import AddContact from './views/Settings/AddContact'; import ContactDetails from './views/ContactDetails'; import CurrencyConverter from './views/Settings/CurrencyConverter'; -import AddCurrencies from './views/Settings/AddCurrencies'; // POS import Order from './views/Order'; @@ -425,9 +424,6 @@ const AppScenes = { }, CurrencyConverter: { screen: CurrencyConverter - }, - AddCurrencies: { - screen: AddCurrencies } }; diff --git a/views/Settings/AddCurrencies.tsx b/views/Settings/AddCurrencies.tsx deleted file mode 100644 index 93768b679..000000000 --- a/views/Settings/AddCurrencies.tsx +++ /dev/null @@ -1,156 +0,0 @@ -import * as React from 'react'; -import { SearchBar } from 'react-native-elements'; - -import Screen from '../../components/Screen'; -import Header from '../../components/Header'; -import { themeColor } from '../../utils/ThemeUtils'; - -import { FlatList, Text, TouchableOpacity, View } from 'react-native'; - -import { CURRENCY_KEYS } from '../../stores/SettingsStore'; -import { localeString } from '../../utils/LocaleUtils'; - -import Bitcoin from '../../assets/images/SVG/bitcoin-icon.svg'; - -interface AddCurrenciesProps { - navigation: any; -} - -interface AddCurrenciesState { - search: string; -} - -export default class AddCurrencies extends React.Component< - AddCurrenciesProps, - AddCurrenciesState -> { - constructor(props: AddCurrenciesProps) { - super(props); - this.state = { - search: '' - }; - } - - updateSearch = (query: string) => { - this.setState({ search: query }); - }; - - renderSeparator = () => ( - - ); - - render() { - const { navigation } = this.props; - - const updatedCurrencyList = [ - { - key: 'Bitcoin (BTC)', - value: 'BTC', - svg: - }, - { - key: 'Satoshis (SAT)', - value: 'SAT', - svg: - }, - ...CURRENCY_KEYS - ]; - - const { search } = this.state; - const filteredCurrencies = updatedCurrencyList.filter((currency) => - currency.key.toLowerCase().includes(search.toLowerCase()) - ); - - return ( - - -
- - - ( - { - navigation.navigate('CurrencyConverter', { - selectedCurrency: item.value - }); - }} - > - - - {['BTC', 'SAT'].includes( - item.value - ) && ( - - {item.svg} - - )} - - - {item.key} - - - - - - )} - keyExtractor={(item, index) => index.toString()} - ItemSeparatorComponent={this.renderSeparator} - /> - - - ); - } -} diff --git a/views/Settings/CurrencyConverter.tsx b/views/Settings/CurrencyConverter.tsx index 12e7f12a8..d551f396d 100644 --- a/views/Settings/CurrencyConverter.tsx +++ b/views/Settings/CurrencyConverter.tsx @@ -346,7 +346,11 @@ export default class CurrencyConverter extends React.Component< const AddButton = () => ( navigation.navigate('AddCurrencies')} + onPress={() => + navigation.navigate('SelectCurrency', { + currencyConverter: true + }) + } accessibilityLabel={localeString('general.add')} > - - - + fiatEnabled && ( + + + + + ) } centerComponent={{ text: localeString( diff --git a/views/Settings/SelectCurrency.tsx b/views/Settings/SelectCurrency.tsx index cc48bb73c..580678e23 100644 --- a/views/Settings/SelectCurrency.tsx +++ b/views/Settings/SelectCurrency.tsx @@ -78,6 +78,11 @@ export default class SelectCurrency extends React.Component< this.state; const { updateSettings, getSettings }: any = SettingsStore; + const currencyConverter = navigation.getParam( + 'currencyConverter', + null + ); + return ( @@ -128,22 +133,32 @@ export default class SelectCurrency extends React.Component< backgroundColor: 'transparent' }} onPress={async () => { - await updateSettings({ - fiat: item.value - }).then(() => { - getSettings(); - navigation.navigate('Currency', { - refresh: true + if (currencyConverter) { + navigation.navigate( + 'CurrencyConverter', + { + selectedCurrency: item.value + } + ); + } else { + await updateSettings({ + fiat: item.value + }).then(() => { + getSettings(); + navigation.navigate('Currency', { + refresh: true + }); }); - }); + } }} > {(selectedCurrency === item.value || (!selectedCurrency && - item.value === DEFAULT_FIAT)) && ( - - - - )} + item.value === DEFAULT_FIAT)) && + !currencyConverter && ( + + + + )} )} keyExtractor={(item, index) => `${item.host}-${index}`}