-
Notifications
You must be signed in to change notification settings - Fork 76
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
Allow decimal input in AddTransaction page. #111
Allow decimal input in AddTransaction page. #111
Conversation
Add custom formatter to fix various inconsistencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! From what I can see now it is working as expected. Unfortunately I currently have an issue with the simulator on iOS so I would wait for someone else to look at it and the code
I noticed that it's possible to add a period after a comma, but not the other way around (as it should be). Entering We should put agree on some rules for which symbol to use as the decimal separator. In some places (e.g. home page) we use the comma, while in others (e.g. transactions and graph page) the period. Since the app is in English, we should stick with the period everywhere. I think the user should not be allowed to enter the comma (which should be use as the thousands separator) to prevent them from adding it in the wrong place (e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entering a comma after a period is not allowed, as it's supposed to be. However, it is possible to add a period after a comma, but this results in some weird behavior. For example 12,34.56
becomes 12.34
and 12,3.45
becomes 12.30
.
I guess the best fix would be to use the period as decimal separator across the whole app and prevent the user from entering a comma, which should be added automatically as thousands separator.
Hi @GBergatto, As a side note: I've also opened an issue regarding the decimal separator. In my opinion it shouldn't be hardcoded, instead we should support the default decimal separator of the configured app language (if we plan to support other languages other than English). |
@rcasula Samsung A33 |
@GBergatto I've pushed a possible fix in order to accept only the decimal separator. Can you try and let me know if it works correctly? |
Hello, and thank you! |
Definitely a critical issue, never noticed before.
Let me better check on that though |
Hi, That said, we should consider retrieving the decimal separator from the phone's or app locale. What do you think? |
In this case, OS and keyboard locales are both italian.
I think that in this stage, the app should determine dates and numbers formats itself, independently on how the device is configured: We're developing mobile + desktop, on Apple, Android, Windows and Linux... handle all systems settings could allocate too much effort for a small team eager to release a first Alpha.. |
That's definitely the best way to do it, but I think it's too complex for the stage we're at. For now, I think we should use the dot as decimal separator, as that's the default in English. |
This seems quite counter intuitive to me. I would stick with the English default of dot for decimal separator and comma as thousands separator. |
@GBergatto |
@GBergatto @mikev-cw As for the user input I would only allow the decimal separator and the numbers. This way is easier and maintainable. How would that sounds? EDIT The solution could be not so easy as we initially thought 😅 |
@GBergatto @mikev-cw I've pushed a fix, can you try it please? It's really a shame that this is the only solution I've found, so simple thing yet so hard. Do you know a better solution other than replacing the comma with a period? |
…her chars than decimals and separators
I've just tested it on my Samsung phone. The keyboard I get has both comma and period. From what I can tell, it work pretty well. The only issue is that prices are currently displayed with a comma as separator on the home page. So, when editing a price the comma gets transformed into a dot and then back into a comma. As you @rcasula said, this solution is very strict. Instead of processing the number as it's being written and preventing the user from adding certain chars, we could validate the string only when the "add transaction" button is pressed and display an error message if the format is invalid. We would still need a way to guarantee that the format entered by the user is consistent with his locale. For example, if the user has set the app to use the dot as separator, he shouldn't enter values with a comma. |
Yes, you are correct. Still feels hacky to me and I don't really like it. The user input though.. that's the real issue. I was not able to find a way to know which device region the user has set, without that we can't know if it has the dot or the comma as the decimal separator. |
By comparing these two questions on stackoverflow, I wrote this function that should return a string containing the decimal separator of your locale. I've tested it on my phone and it seems to work.
|
I've tried it, it works fine for simple cases, but not for the cases we were discussing earlier. |
Works good on Android sim. Not tried iPhone sim. ...seems that a simple task managed to be a huge task... 🤣 |
I was experiencing the same thing when trying to edit the amount of a transaction. I'm working on turning the modal to add/edit transactions into a page and now it seems to work. However, I get this warning in my console when I edit the amount
I'll learn more about Riverpod to see if I can come up with a solution. Also, prices are currently using the comma as separator. So, when you go to edit one, the comma is replaced with a dot while editing but then replaced again with a comma by |
Hi @mikev-cw and @GBergatto , I suggest to separate the issues in two separate PRs: this one, regarding the user input, and the other one, regarding the user facing number formatting.
Are you sure? I've tested on a physical iPhone with both locale and region set to Italian: Keyboard shows comma, but when pressing it its being replaced with a period.
Indeed.... We are still on-time to revert back to native, just saying... 😌 (joking) |
@rcasula Double checked: dot on iOS simulator, comma on phisical device (iOS 16.6 on iPhone 13 Pro). |
Checked with @rcasula: i was building on an old commit... Damn! Sorry guys for time wasting. |
Add custom formatter to fix various inconsistencies
This PR fixes #95