feat: replace static premium indicator with editable input and dynamic slider range#454
feat: replace static premium indicator with editable input and dynamic slider range#454
Conversation
WalkthroughThis PR makes FormSection icon background conditional (transparent vs circular), converts PremiumSection into a StatefulWidget with debounced text input, focus management, and dynamic slider/input synchronization, and adds a new localization key Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TextField
participant DebounceTimer
participant Parser
participant Slider
participant Parent
User->>TextField: type value / edit
TextField->>DebounceTimer: schedule debounced update
DebounceTimer->>Parser: parse, clamp, format value
Parser->>Slider: update slider position/value
Slider->>Parent: onChanged(value)
Parent->>TextField: propagate external value update
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/features/order/widgets/premium_section.dart`:
- Around line 154-156: The input formatter currently uses
FilteringTextInputFormatter.allow(RegExp(r'^-?\d{0,3}')) which uses a leading ^
anchor and causes user input loss; update the formatter in the TextField/widget
that sets inputFormatters (the array containing
FilteringTextInputFormatter.allow) to either remove the anchor and allow
individual digit/minus characters (e.g., use a pattern without ^ so the
formatter matches characters rather than only from position 0) and rely on the
existing _commitTextValue clamping, or replace it with a
TextInputFormatter.withFunction that tests the entire resulting string
(newValue.text) against RegExp(r'^-?\d{0,3}$') and returns oldValue when the
full-string match fails. Ensure you modify the formatter where
FilteringTextInputFormatter.allow(RegExp(r'^-?\d{0,3}')) is declared in
premium_section.dart.
🧹 Nitpick comments (1)
lib/features/order/widgets/premium_section.dart (1)
73-78: 2-second debounce may feel sluggish for a premium input.The debounce delay of 2 seconds before committing the text value is quite long. Users might expect faster feedback, especially since the slider and labels won't update until the debounce fires. Consider reducing to ~500-800ms for a snappier feel, or committing immediately when the input is a complete valid number.
fix #442


Summary by CodeRabbit
New Features
UI/UX Improvements