Repository navigation
feat: group thousands in number fields with a configurable separator - #13
Merged
Merged
Conversation
FormInputTextField gets groupThousands and groupingSeparator for NUMBER fields, and FormInputPriceField gets groupingSeparator. Grouping is display only, so the stored value stays plain, and both options default to today's behaviour. The separator may not be a digit or a dot.
Document the new parameters on the TextFieldValue overload, remember the price field's transformation like the text field does, and test that the cursor stays next to the typed digit in a grouped field.
Merged
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.
Summary
FormInputTextField(both overloads) getsgroupThousands: Boolean = falseandgroupingSeparator: Char = ',', active only fortype = NUMBER.FormInputPriceFieldgetsgroupingSeparator: Char = ','. Grouping is display only: the stored value stays plain ("2000000") and the decimal mark stays.. Defaults keep today's output, so nothing changes for existing callers. The separator may not be a digit or.; a bad value throwsIllegalArgumentException.Rejected: following the system locale (needs expect/actual on four targets and locale decimal marks) and grouping by default for all NUMBER fields (changes quantity/weight fields in every consuming app).
Changes
ui/utils/PriceFormat.ktThousandsSeparatorTransformationvalidates the separatorui/FormInputTextField.ktgroupThousands,groupingSeparatoron both overloads; a callervisualTransformationstill winsui/FormInputPriceField.ktgroupingSeparatorapp/.../DemoSections.kt.claude/skills/use-forminput/*.mdAcceptance criteria
groupThousands = trueand value1234567shows1,234,567;onValueChangegives"1234567"2000000regroups after each keystroke and the cursor stays after the last digit1234567.891shows1,234,567.891groupingSeparator = ' 'shows1 234 567on price and number fields'.'or a digit as separator throwsIllegalArgumentExceptiongroupThousands = trueon a non-NUMBER field leaves the text unchangedvisualTransformationwins over groupingTest plan
./gradlew :forminput:jvmTest :forminput:compileAndroidMain -Pkotlin.native.ignoreDisabledTargets=true --rerun-tasks(218 tests, 0 failures)./gradlew :app:compileDebugKotlin2000000digit by digit, inserted and deleted mid-number, 13 digits in one call, letters rejected, rotation, background/return, font scale 1.6, no crashes in logcat. The price field was not driven on the device; the automated tests cover it.