Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency Converter #1968

Merged
merged 18 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d55c28f
Currency Converter
shubhamkmr04 Feb 2, 2024
50887dd
CurrencyConverter: Error if the currency is disabled
shubhamkmr04 Feb 2, 2024
b7e8edd
List currencies on different view + shift the heading from the header…
shubhamkmr04 Feb 6, 2024
3113f3b
Saving currency codes + Using CURRENCY_KEYS array values in Add Curre…
shubhamkmr04 Feb 6, 2024
d9573f2
Currency Converter: Add ability to remove currencies
shubhamkmr04 Feb 6, 2024
15d5f8b
Added functionality to drag and drop the currency inputs
shubhamkmr04 Feb 7, 2024
b4d7618
CurrencyConverter: Added animation
shubhamkmr04 Feb 9, 2024
5daa530
CurrencyConverter: Added SATS as a currency
shubhamkmr04 Feb 9, 2024
b50b4f2
AddCurrencies: Added Search bar to search currencies + localize strings
shubhamkmr04 Feb 9, 2024
94d9b46
Adjusting Flags
shubhamkmr04 Feb 13, 2024
7e2e94a
Removed AddCurrencies and using SelectCurrency to add currencies for …
shubhamkmr04 Feb 15, 2024
160b88a
Merge branch 'master' into shubham/CurrencyConvertor
shubhamkmr04 Feb 16, 2024
12954a3
Saving reordered list in the storage
shubhamkmr04 Feb 19, 2024
9b8d2e7
Merge branch 'master' into shubham/CurrencyConvertor
shubhamkmr04 Feb 19, 2024
955c0a7
Apply formatting in amount + remove flags from placeholder and add in…
shubhamkmr04 Feb 20, 2024
e207327
Revamp handleInputChange func
shubhamkmr04 Feb 22, 2024
d7bdebc
Add Bitcoin icon in input and align all flags vertically
shubhamkmr04 Feb 25, 2024
6d05a81
Using react-native-svg to list country flags
shubhamkmr04 Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ import AddNotes from './views/AddNotes';
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';

Expand Down Expand Up @@ -419,6 +422,12 @@ const AppScenes = {
},
ContactQR: {
screen: ContactQR
},
CurrencyConverter: {
screen: CurrencyConverter
},
AddCurrencies: {
screen: AddCurrencies
}
};

Expand Down
12 changes: 12 additions & 0 deletions assets/images/SVG/bitcoin-icon.svg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we using this file anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not right now, but I am thinking of using it in placeholder for BTC and SAT inputs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add it then

shubhamkmr04 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@
"views.Settings.Attestations.invalidAttestation": "Invalid attestation",
"views.Settings.Nostr.addRelay": "Add relay",
"views.Settings.Nostr.relays": "Relays",
"views.Settings.CurrencyConverter.title": "Currency Converter",
"views.Settings.CurrencyConverter.enterAmountIn": "Enter amount in",
"views.LspExplanation.title": "What are these fees?",
"views.LspExplanation.text1": "Zeus is a self-custodial lightning wallet. In order to send or receive a lightning payment, you must open a lightning payment channel, which has a setup fee.",
"views.LspExplanation.text2": "Once the channel is set up, you'll only have to pay normal network fees until your channel exhausts its capacity.",
Expand All @@ -1021,4 +1023,4 @@
"views.Sweep.title": "Sweep on-chain wallet",
"views.Sweep.explainer": "Sweeping the on-chain wallet will send both the confirmed and unconfirmed balance to the destination address specified above.",
"pos.customItem": "Custom item"
}
}
156 changes: 156 additions & 0 deletions views/Settings/AddCurrencies.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this file or can we add in the functionality to SelectCurrency?

Copy link
Contributor Author

@shubhamkmr04 shubhamkmr04 Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'll figure out if we can without messing it up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added this functionality in SelectCurrency and removed AddCurrencies

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 = () => (
<View
style={{
height: 1,
backgroundColor: themeColor('separator')
}}
/>
);

render() {
const { navigation } = this.props;

const updatedCurrencyList = [
{
key: 'Bitcoin (BTC)',
value: 'BTC',
svg: <Bitcoin width={20} height={20} />
},
{
key: 'Satoshis (SAT)',
value: 'SAT',
svg: <Bitcoin width={20} height={20} />
},
...CURRENCY_KEYS
];

const { search } = this.state;
const filteredCurrencies = updatedCurrencyList.filter((currency) =>
currency.key.toLowerCase().includes(search.toLowerCase())
);

return (
<Screen>
<View style={{ flex: 1 }}>
<Header
leftComponent="Back"
centerComponent={{
text: 'Add Currencies',
style: {
color: themeColor('text'),
fontFamily: 'PPNeueMontreal-Book'
}
}}
navigation={navigation}
/>
<SearchBar
placeholder={localeString('general.search')}
onChangeText={this.updateSearch}
value={this.state.search}
inputStyle={{
color: themeColor('text')
}}
placeholderTextColor={themeColor('secondaryText')}
containerStyle={{
backgroundColor: 'transparent',
borderTopWidth: 0,
borderBottomWidth: 0
}}
inputContainerStyle={{
borderRadius: 15,
backgroundColor: themeColor('secondary')
}}
/>

<FlatList
data={filteredCurrencies}
renderItem={({ item }) => (
<TouchableOpacity
onPress={() => {
navigation.navigate('CurrencyConverter', {
selectedCurrency: item.value
});
}}
>
<View>
<View
style={{
margin: 16,
flex: 1,
flexDirection: 'row',
alignItems: 'center'
}}
>
{['BTC', 'SAT'].includes(
item.value
) && (
<View
style={{
marginRight: 6,
paddingLeft: 1
}}
>
{item.svg}
</View>
)}
<View>
<Text
style={{
color: themeColor('text'),
fontSize: 16,
fontFamily:
'PPNeueMontreal-Book'
}}
>
{item.key}
</Text>
</View>
</View>
</View>
</TouchableOpacity>
)}
keyExtractor={(item, index) => index.toString()}
ItemSeparatorComponent={this.renderSeparator}
/>
</View>
</Screen>
);
}
}
23 changes: 23 additions & 0 deletions views/Settings/Currency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,29 @@ export default class Currency extends React.Component<
color={themeColor('secondaryText')}
/>
</ListItem>
<ListItem
containerStyle={{
backgroundColor: 'transparent'
}}
onPress={() => navigation.navigate('CurrencyConverter')}
>
<ListItem.Content>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'PPNeueMontreal-Book'
}}
>
{localeString(
'views.Settings.CurrencyConverter.title'
)}
</ListItem.Title>
</ListItem.Content>
<Icon
name="keyboard-arrow-right"
color={themeColor('secondaryText')}
/>
</ListItem>
</View>
</Screen>
);
Expand Down
Loading
Loading