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 all 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
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 @@ -423,6 +425,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 @@ -1001,6 +1001,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 @@ -1035,4 +1037,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
Loading