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

Get currency information from Paisa's own database instead of the intl library #139

Closed
EzeKoren opened this issue Mar 22, 2023 · 4 comments
Assignees
Labels
currency Adding currency to app

Comments

@EzeKoren
Copy link
Contributor

EzeKoren commented Mar 22, 2023

Currently Paisa has a list of country models, where it could reference any listed country's currency's name, symbol, code, and more.

https://github.com/RetroMusicPlayer/Paisa/blob/078de31ded9c45574aa3fa605fdd7f71a69c07f3/lib/src/data/currencies/models/country_model.dart#L561-L573

Upon loading up the app for the first time, however, it will use Flutter's NumberFormat.compactSimpleCurrency() library (documented here), which doesn't contain all the necessary information, nor the information for all the countries supported by Paisa, like for example Argentina (the country I live in and I made the PR for yesterday).

I overlooked this issue when I made my PR, and for that I apologize.

The solution I believe would be the best, would be for the list in currency-model.dart to be replaced by the one in country-model.dart. That way, not only many more countries would be added, but also it would be easier to add new ones not already present, not to mention streamlining the process of adding new currencies not supported by the built in NumberFormat library. This would also open the door to the possibility of letting the user add their own custom currency.

Thank you for taking your time to read this, by opening this PR I hope I can help make this amazing app grow by making it just a little better. Cheers!

@EzeKoren EzeKoren changed the title Get currency information from your own database instead of the intl library Get currency information from Paisa's own database instead of the intl library Mar 22, 2023
@EzeKoren
Copy link
Contributor Author

More info:

https://github.com/RetroMusicPlayer/Paisa/blob/078de31ded9c45574aa3fa605fdd7f71a69c07f3/lib/src/presentation/login/widgets/local_grid_view_widget.dart#L51-L53

When a locale unavailable in the locale list (I.E. Argentina, locale code es_AR) is passed onto this function, after failing to find it, the library will try to trim the locale to just the language (in this case es), which works well for languages but not so much for country information and currencies, since it will return completely wrong information.

The problem was reported on my PR #118, as well as PR #104 by @chardinson.

@h4h13
Copy link
Owner

h4h13 commented Mar 24, 2023

The problem is that thousands of separation and decimal separation

Some countries will have dot separation and some have comma separation

@h4h13 h4h13 self-assigned this Mar 24, 2023
@h4h13 h4h13 added the currency Adding currency to app label Mar 24, 2023
@h4h13 h4h13 added this to the Currency milestone Mar 24, 2023
@EzeKoren
Copy link
Contributor Author

That's information already available in the country_model.dart file under the thousands_separator and decimal_separator variables. The first option that comes to mind is to convert the amount of money to a string before displaying it to the user, and replacing both separators with whatever is declared in the country model.

@h4h13
Copy link
Owner

h4h13 commented Mar 25, 2023

I'm still not know how to use those parameters to custom build currency formatter

@h4h13 h4h13 closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
currency Adding currency to app
Projects
None yet
Development

No branches or pull requests

2 participants