Skip to content

Conversation

@afossmaker
Copy link

Details in the commit message.

… user's locale

=============================== RECAP ============================================
1. Canceled localization of numbers done on the data layer in order to :
    a. Localize only the text displayed to the user from the UI layer
    b. Keep business logic language independent
    ------------ Tasks done ------------
    - Updated FormattingEvaluator::evaluate to not localize the returned result
    - Updated EventHandler to insert a "." instead of a localized decimal separator for CalculatorEvent.Decimal
2. Created the NumberFormatter class in the UI layer to hold number formatting logic based on the user's locale (ui/components/NumberFormatter.kt)
3. Formatted the numbers displayed by the calculator screen and the converter screen
4. Added a few UI ajustement to both the calculator screen and the converter screen
    ------------ Tasks done ------------
    - Added to the converter screen a custom keypad that have a localized decimal separator and supports hexadecimal digits if base conversion is needed
    - Updated the layout of the converter screen to acomodate the custom keypad
    - Added ConverterViewModel to hold the user's input from the converter screen as a state
    - Updated CalculatorViewModel::setExpression to place the displayText's cursor at the end after updating its value to make it ready to receive new inputs
    - Added the user's locale to the calculator screen's keypad to make sure the decimal separator matches the user's locale
Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

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

Thanks for your interest in the app.

I don't want to attack you, but seeing this code, I just want to let you know that we do NOT accept any AI-generated code here. If this code was indeed AI-generated, I unfortunately can't merge these changes.

  1. The hexadecimal number input is not related to this PR (number format localization) and thus should be in a different PR
  2. Relying on regular expressions for the number formatting looks like a very bad idea and the "99 digits" assumption doesn't make any sense. If we want to do localization, we should use a library for this instead of re-inventing the wheel.
  3. The ConverterViewModel logic should be moved to the already existing CalculatorViewModel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants