Skip to content

Conversation

@Catrya
Copy link
Member

@Catrya Catrya commented Feb 10, 2026

fix #434
Now, if someone tries to create a range order at a fixed price, it will not be allowed, and a message will appear for 5 seconds explaining why it remains at market price.
image

Summary by CodeRabbit

  • New Features

    • Range mode for orders: specify min/max amounts and toggle between range and fixed-price modes. UI prevents invalid mode switches and shows a temporary error when fixed price isn’t available for a range.
    • Amount input now activates range mode via user interaction for smoother workflow; price control surfaces the range-related error message.
  • Localization

    • Added/fixed translations: new fixed-price-vs-range message and clearer fiat amount range wording (English, Spanish, Italian).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Walkthrough

Adds range-order mode propagation and UI/validation to prevent selecting Fixed Price when a max amount is present. The parent screen tracks _isRangeMode, shows a temporary localized error, and AmountSection and PriceTypeSection communicate to block/indicate fixed-price selection for range orders.

Changes

Cohort / File(s) Summary
Order Screen Logic
lib/features/order/screens/add_order_screen.dart
Adds _isRangeMode, _fixedPriceRangeError, a Timer lifecycle, _onRangeModeChanged() and _showFixedPriceRangeError() to manage range-mode state, block immediate fixed-price toggles when range is active, and surface a temporary error message.
Amount Input Widget
lib/features/order/widgets/amount_section.dart
Adds final ValueChanged<bool>? onRangeModeChanged (constructor param) and invokes it on max focus/text changes and when min is cleared to notify parent of entering/exiting range mode.
Price Type Widget
lib/features/order/widgets/price_type_section.dart
Adds optional errorMessage parameter, refactors layout (Row→Column), and renders a styled error block when errorMessage is present; prevents/indicates fixed-price selection while range mode is active.
Localizations
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Adds fixedPriceDisabledForRange translations (EN/ES/IT) and updates wording for fiatAmountTooHigh / fiatAmountTooLow messages.

Sequence Diagram

sequenceDiagram
    actor User
    participant AmountSection as AmountSection
    participant AddOrderScreen as AddOrderScreen
    participant PriceTypeSection as PriceTypeSection

    User->>AmountSection: Focus max amount (first time)
    AmountSection->>AddOrderScreen: onRangeModeChanged(true)
    AddOrderScreen->>AddOrderScreen: set _isRangeMode = true
    AddOrderScreen->>PriceTypeSection: pass updated props (errorMessage / disabled state)

    User->>PriceTypeSection: Attempt toggle to Fixed
    PriceTypeSection->>AddOrderScreen: onToggle(request Fixed)
    AddOrderScreen->>AddOrderScreen: _showFixedPriceRangeError()
    AddOrderScreen->>PriceTypeSection: update errorMessage
    PriceTypeSection->>User: display fixedPriceDisabledForRange message

    User->>AmountSection: Clear max amount
    AmountSection->>AddOrderScreen: onRangeModeChanged(false)
    AddOrderScreen->>PriceTypeSection: clear errorMessage / allow Fixed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • grunch

Poem

"I'm a rabbit in the code-glade, hopping through min and max,
When ranges bloom I tap the brakes, and fixed price meets a flax.
A polite little message pops, then fades like morning dew—
I munch a carrot, nod approvingly, and bounce the bug adieu."

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (7 files):

⚔️ docs/MULTI_MOSTRO_SUPPORT.md (content)
⚔️ lib/features/order/screens/add_order_screen.dart (content)
⚔️ lib/features/order/widgets/amount_section.dart (content)
⚔️ lib/features/order/widgets/price_type_section.dart (content)
⚔️ lib/l10n/intl_en.arb (content)
⚔️ lib/l10n/intl_es.arb (content)
⚔️ lib/l10n/intl_it.arb (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (5 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 objective: preventing the combination of fixed price with range orders during order creation.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #434 requirements: prevents fixed price selection for range orders, displays explanatory error message, and prevents invalid submissions.
Out of Scope Changes check ✅ Passed All changes are directly related to the range/fixed price conflict resolution; translation updates and UI modifications are integral to implementing the feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 range_fixed_price
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch range_fixed_price
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


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: 4

🤖 Fix all issues with AI agents
In `@lib/features/order/screens/add_order_screen.dart`:
- Around line 103-114: The _showFixedPriceRangeError function can start
overlapping timers that clear a newer message early; add a Timer field (e.g.,
_fixedPriceRangeErrorTimer) to the widget, cancel it if non-null and active at
the start of _showFixedPriceRangeError, then create a new
Timer(Duration(seconds:5)) that clears _fixedPriceRangeError inside the mounted
check and assigns null to the timer when it fires; ensure you import dart:async
and cancel the timer in dispose() as well.

In `@lib/l10n/intl_en.arb`:
- Around line 1366-1367: Remove the non-placeholder metadata entry named
"@_comment_range_fixed_price" and leave only the plain localization key
"fixedPriceDisabledForRange" (do not add any `@-prefixed` metadata for it),
ensuring ARB metadata blocks are present only for keys with placeholders; locate
and delete the "@_comment_range_fixed_price" entry near the
"fixedPriceDisabledForRange" key.

In `@lib/l10n/intl_es.arb`:
- Around line 1342-1343: Remove the stray ARB metadata entry named
"@_comment_range_fixed_price" and keep only the actual message key
"fixedPriceDisabledForRange"; locate the pair ("@_comment_range_fixed_price" and
"fixedPriceDisabledForRange") and delete the metadata line so that only the
translation string remains, and ensure any remaining `@-prefixed` metadata is used
only for keys that have placeholders.

In `@lib/l10n/intl_it.arb`:
- Around line 1397-1399: Remove the metadata-only entry
`@_comment_range_fixed_price` from the ARB file because metadata (`@-prefixed`)
should only accompany parameterized keys; keep the user-facing key
fixedPriceDisabledForRange (and its value) intact and delete the separate
"@_comment_range_fixed_price" line so only parameterized strings retain metadata
blocks.

Copy link
Collaborator

@mostronator mostronator left a comment

Choose a reason for hiding this comment

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

✅ Approved — Clean fix for #434

What it does

Prevents users from selecting fixed price when creating range orders. Shows a temporary error message (5s auto-dismiss) explaining why.

Review

  • Logic is correct: _onRangeModeChanged properly resets to market rate and clears sats amount when switching to range mode while on fixed price
  • Good UX: Error message auto-dismisses with timer, properly cancelled in dispose()
  • Proper propagation: AmountSection notifies parent of range mode changes via callback
  • i18n complete: All 3 languages have the new fixedPriceDisabledForRange string
  • No regressions: The toggle in PriceTypeSection now shows error message inline with Column layout

Minor suggestion (non-blocking)

  • Consider using a SnackBar instead of inline error text for consistency with the rest of the app pattern, but the current approach works well too.

Good contribution! 👍

@grunch
Copy link
Member

grunch commented Feb 11, 2026

@Catrya please fix conflicts

# Conflicts:
#	lib/l10n/intl_en.arb
#	lib/l10n/intl_es.arb
#	lib/l10n/intl_it.arb
Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia left a comment

Choose a reason for hiding this comment

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

No esta duplicando la evaluacion de _isRangeMode? veo que en add_order_screen tiene su boolean y que tambien esta en AmountSection, no estaria redundando ahi? de resto lo probe y anda bien, la pregunta es solo curiosidad

@Catrya
Copy link
Member Author

Catrya commented Feb 12, 2026

No esta duplicando la evaluacion de _isRangeMode? veo que en add_order_screen tiene su boolean y que tambien esta en AmountSection, no estaria redundando ahi? de resto lo probe y anda bien, la pregunta es solo curiosidad

No es redundancia, rastrean cosas distintas: en AmountSection el _isRangeMode indica si el usuario interactuó con el campo max (estado de UI), mientras que en AddOrderScreen refleja si la orden es de rango (_isRangeMode && hasMax), que es lo que llega por el callback.

Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia left a comment

Choose a reason for hiding this comment

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

tACK

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.

utACK

@grunch grunch merged commit 4a95801 into main Feb 12, 2026
2 checks passed
@grunch grunch deleted the range_fixed_price branch February 12, 2026 19:25
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.

Prevent selecting Fixed Price when creating a range order

4 participants