fix: align currency and calc widget with ios#884
Merged
Conversation
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
…onents/CalculatorCard.kt Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
jvsena42
reviewed
Apr 6, 2026
Collaborator
|
Most of the logic added to the |
2 tasks
Collaborator
Addressing in: |
ovitrif
approved these changes
May 7, 2026
Collaborator
There was a problem hiding this comment.
LGTM, but I found some issues in fiat input.
issuesFiat.mp4
- Delete key deletes all decimals
- Delete key when value is
0adds a decimal first - Can't add decimal if it shows only one
- Needs lots of taps on delete key when decimals are hidden
Issue seems to be that, while it doesn't show the 2nd decimal in cases like 1.9, the value is there: 1.90.
| 1 & 2 | 3 & 4 |
|---|---|
issuesFiat.mp4 |
issuesFiat2.mp4 |
Comment on lines
+74
to
+95
| internal fun sanitizeDecimalInput( | ||
| raw: String, | ||
| locale: Locale = Locale.getDefault(), | ||
| maxDecimalPlaces: Int? = null, | ||
| ): String { | ||
| val localDecimal = DecimalFormatSymbols.getInstance(locale).decimalSeparator | ||
| val normalized = if (localDecimal == ',') raw.replace(',', '.') else raw | ||
| val filtered = normalized.filter { it.isDigit() || it == '.' } | ||
| val dotIndex = filtered.indexOf('.') | ||
| val singleDot = if (dotIndex == -1) { | ||
| filtered | ||
| } else { | ||
| filtered.substring(0, dotIndex + 1) + | ||
| filtered.substring(dotIndex + 1).replace(".", "") | ||
| } | ||
| if (maxDecimalPlaces == null) return singleDot | ||
| val cappedDot = singleDot.indexOf('.') | ||
| if (cappedDot == -1) return singleDot | ||
| val fraction = singleDot.substring(cappedDot + 1) | ||
| if (fraction.length <= maxDecimalPlaces) return singleDot | ||
| return singleDot.substring(0, cappedDot + 1) + fraction.take(maxDecimalPlaces) | ||
| } |
Collaborator
There was a problem hiding this comment.
nit: would've been nice to add unit tests, even if it's low complexity, it's still logic.
Collaborator
|
I will add the fixes in my PR which also moves logic to viewmodel: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #881
Description
This PR:
Preview
Screen.Recording.2026-04-03.at.17.45.25.mov
QA Notes
1. Currency settings symbols
2. Calculator widget symbol truncation
Screen_recording_20260423_071500.webm
3. Calculator widget default value
Screen_recording_20260423_073524.webm
4. Calculator input behavior
Screen_recording_20260423_080014.webm
5. Calculator paste and clear edge cases
1000087188..........,,,,,)08into the empty fiat field in CLASSIC denomination and verify it behaves consistentlyScreen_recording_20260423_081652.webm