Skip to content

Commit

Permalink
Merge pull request #1968 from shubhamkmr04/shubham/CurrencyConvertor
Browse files Browse the repository at this point in the history
Currency Converter
  • Loading branch information
kaloudis authored Feb 27, 2024
2 parents 43a3618 + 6d05a81 commit 1fd5c73
Show file tree
Hide file tree
Showing 7 changed files with 729 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ 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';

// POS
import Order from './views/Order';

Expand Down Expand Up @@ -428,6 +430,9 @@ const AppScenes = {
ContactQR: {
screen: ContactQR
},
CurrencyConverter: {
screen: CurrencyConverter
},
ChannelsSettings: {
screen: ChannelsSettings
},
Expand Down
6 changes: 6 additions & 0 deletions assets/images/SVG/bitcoin-icon.svg
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 @@ -1017,6 +1017,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.enterAmount": "Enter amount",
"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 Down Expand Up @@ -1051,4 +1053,4 @@
"time.1H": "1H",
"time.1D": "1D",
"time.1W": "1W"
}
}
19 changes: 10 additions & 9 deletions stores/FiatStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export default class FiatStore {
@observable public loading = false;
@observable public error = false;

@observable public numberWithCommas = (x: string | number) =>
x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');

@observable public numberWithDecimals = (x: string | number) =>
this.numberWithCommas(x).replace(/[,.]/g, (y: string) =>
y === ',' ? '.' : ','
);
private sourceOfCurrentFiatRates: string | undefined;

getFiatRatesToken: any;
Expand All @@ -34,17 +41,11 @@ export default class FiatStore {
this.settingsStore = settingsStore;
}

numberWithCommas = (x: string | number) =>
x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');

numberWithDecimals = (x: string | number) =>
this.numberWithCommas(x).replace(/[,.]/g, (y: string) =>
y === ',' ? '.' : ','
);

// Resource below may be helpful for formatting
// https://fastspring.com/blog/how-to-format-30-currencies-from-countries-all-over-the-world/
symbolLookup = (symbol: string): CurrencyDisplayRules => {
@observable public symbolLookup = (
symbol: string
): CurrencyDisplayRules => {
const symbolPairs: any = {
USD: {
symbol: '$',
Expand Down
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

0 comments on commit 1fd5c73

Please sign in to comment.