Skip to content

feat: replace static premium indicator with editable input and dynamic slider range#454

Merged
grunch merged 2 commits intomainfrom
premiun-discount-range
Feb 13, 2026
Merged

feat: replace static premium indicator with editable input and dynamic slider range#454
grunch merged 2 commits intomainfrom
premiun-discount-range

Conversation

@Catrya
Copy link
Member

@Catrya Catrya commented Feb 12, 2026

fix #442
image
image

Summary by CodeRabbit

  • New Features

    • Premium section now has an editable input with synchronized real-time slider, formatting, and dynamic bounds validation
    • Added an "Edit" hint string in English, Spanish and Italian
  • UI/UX Improvements

    • Icon backgrounds can render as transparent when specified

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

This 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 premiumEditHint in English, Spanish, and Italian.

Changes

Cohort / File(s) Summary
Icon rendering
lib/features/order/widgets/form_section.dart
Icon background now conditional: if iconBackgroundColor is Colors.transparent the icon is rendered without the 36×36 circular container; otherwise the circular colored container is shown.
Premium input & slider (stateful)
lib/features/order/widgets/premium_section.dart
PremiumSection converted from StatelessWidgetStatefulWidget. Adds TextEditingController, FocusNode, debounce timer, editing flag, lifecycle methods, debounced input parsing/clamping/formatting, and synchronized slider ↔ text input with dynamic bounds and divisions.
Localization
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Added premiumEditHint translations: "Edit" (en), "Editar" (es), "Modifica" (it).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • grunch
  • mostronator
  • AndreaDiazCorreia

Poem

🐰 Hopping through pixels, I tweak and mend,

Icons lose circles—transparent trend.
Sliders hum softly, inputs debounce light,
Percentages settle, values sit right.
Translations whisper: Edit, Edit, Modifica.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing a static premium indicator with an editable input and dynamic slider range.
Linked Issues check ✅ Passed The changes implement dynamic slider bounds based on current value, allowing premium range beyond the fixed -10% to +10% limit as required by issue #442.
Out of Scope Changes check ✅ Passed All changes directly support the PR objective: editable input UI, dynamic slider bounds, conditional icon rendering, and localization strings for the edit hint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch premiun-discount-range

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
lib/features/order/widgets/premium_section.dart (1)

192-198: Add const to TextStyle.

This TextStyle has only compile-time constant arguments and should be const for consistency with the rest of the file (e.g., lines 123, 241, 246).

Suggested fix
         Text(
           S.of(context)!.premiumEditHint,
-          style: TextStyle(
+          style: const TextStyle(
             color: AppTheme.textSubtle,
             fontSize: 10,
           ),
         ),

As per coding guidelines, "Use const constructors where possible to optimize widget performance."


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

@grunch grunch requested a review from mostronator February 13, 2026 12:09
Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

solid! tACK

@grunch grunch merged commit e45a26a into main Feb 13, 2026
2 checks passed
@grunch grunch deleted the premiun-discount-range branch February 13, 2026 12:17
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.

Increase allowed premium/discount range when creating orders

2 participants