Skip to content

feat: display premium/discount in order details and omit 0%#232

Merged
grunch merged 1 commit into
mainfrom
improve-order-details
Jul 25, 2025
Merged

feat: display premium/discount in order details and omit 0%#232
grunch merged 1 commit into
mainfrom
improve-order-details

Conversation

@Catrya

@Catrya Catrya commented Jul 24, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Enhanced display of market price and premium/discount information for orders and trades, now clearly indicating when a premium or discount is present.
  • Style
    • Improved button appearance in the payment methods confirmation dialog with increased padding and minimum height for better usability.
  • Bug Fixes
    • Ensured premium values of zero are no longer redundantly displayed, resulting in a cleaner interface.

@coderabbitai

coderabbitai Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refine how market price and premium information are displayed in order-related widgets and screens. Conditional logic is enhanced to display premium percentages only when non-zero, and premium formatting is unified and clarified across order and trade detail screens. Button styling in the payment methods section is also updated for consistent sizing.

Changes

File(s) Change Summary
lib/features/home/widgets/order_list_item.dart Refined conditional rendering: market price label now only shows premium percentage if premium is non-zero.
lib/features/order/screens/take_order_screen.dart, lib/features/trades/screens/trade_detail_screen.dart Unified and expanded logic for displaying priceText with premium formatting; now shows premium only when non-zero.
lib/features/order/widgets/payment_methods_section.dart Updated ElevatedButton style to include explicit padding and minimum height for improved touch target and spacing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OrderWidget
    participant TradeDetailScreen

    User->>OrderWidget: View order list/take order
    OrderWidget->>OrderWidget: Check order amount & premium
    alt Premium is zero or null
        OrderWidget->>OrderWidget: Show "at market price"
    else Premium is non-zero
        OrderWidget->>OrderWidget: Show "at market price (+/-X%)"
    end

    User->>TradeDetailScreen: View trade detail
    TradeDetailScreen->>TradeDetailScreen: Check order amount & premium
    alt Premium is zero or null
        TradeDetailScreen->>TradeDetailScreen: Show "at market price"
    else Premium is non-zero
        TradeDetailScreen->>TradeDetailScreen: Show "at market price (+/-X%)"
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • grunch

Poem

In the land of code where orders gleam,
A rabbit hops with a premium theme.
If zero, it hides, if not, it shows—
A plus or minus, as logic goes.
Buttons plump for every paw,
These tidy tweaks deserve applause! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-order-details

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/features/trades/screens/trade_detail_screen.dart (1)

114-131: Consider extracting premium formatting logic into a helper method.

Both sections use identical premium formatting logic. Consider extracting this into a private helper method to reduce code duplication and improve maintainability.

String _formatPremiumText(BuildContext context, num premium) {
  final premiumValue = premium.toDouble();
  
  if (premiumValue == 0) {
    return S.of(context)!.atMarketPrice;
  } else {
    final isPremiumPositive = premiumValue >= 0;
    final premiumDisplay = isPremiumPositive
        ? '(+$premiumValue%)'
        : '($premiumValue%)';
    return '${S.of(context)!.atMarketPrice} $premiumDisplay';
  }
}

Also applies to: 184-203

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0e7396 and 18e6015.

📒 Files selected for processing (4)
  • lib/features/home/widgets/order_list_item.dart (1 hunks)
  • lib/features/order/screens/take_order_screen.dart (1 hunks)
  • lib/features/order/widgets/payment_methods_section.dart (1 hunks)
  • lib/features/trades/screens/trade_detail_screen.dart (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
lib/**/*.dart

📄 CodeRabbit Inference Engine (CLAUDE.md)

lib/**/*.dart: Use S.of(context).yourKey for all user-facing strings
Always check mounted before using context after async operations

Files:

  • lib/features/order/widgets/payment_methods_section.dart
  • lib/features/home/widgets/order_list_item.dart
  • lib/features/order/screens/take_order_screen.dart
  • lib/features/trades/screens/trade_detail_screen.dart
**/*.dart

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.dart: Remove unused imports and dependencies
Use const constructors where possible

Files:

  • lib/features/order/widgets/payment_methods_section.dart
  • lib/features/home/widgets/order_list_item.dart
  • lib/features/order/screens/take_order_screen.dart
  • lib/features/trades/screens/trade_detail_screen.dart
🧠 Learnings (2)
lib/features/order/widgets/payment_methods_section.dart (1)

Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-20T01:48:43.335Z
Learning: All changes should pass flutter analyze before commit

lib/features/trades/screens/trade_detail_screen.dart (1)

Learnt from: chebizarro
PR: #74
File: lib/features/trades/models/trade_state.dart:1-15
Timestamp: 2025-05-08T16:06:33.665Z
Learning: In the context of the Mostro Mobile app, the TradeState class is specifically constructed using the tradeStateProvider. While some fields are nullable (lastAction and orderPayload), they are still marked as required parameters to ensure they are explicitly considered during state construction.

🔇 Additional comments (5)
lib/features/order/widgets/payment_methods_section.dart (1)

205-206: LGTM! Button styling improvements enhance consistency.

The explicit padding and minimum size constraints improve the touch target and visual consistency of the confirmation button.

lib/features/home/widgets/order_list_item.dart (1)

191-219: LGTM! Conditional premium display correctly implements the PR objective.

The logic properly omits premium display when the value is 0% and shows appropriately styled premium information when non-zero. The color coding (green for positive, red for negative) and text formatting with proper signs enhance user experience.

lib/features/order/screens/take_order_screen.dart (1)

73-89: LGTM! Premium formatting logic correctly implements the PR requirements.

The implementation properly handles null/zero premium cases and formats non-zero premiums with appropriate signs and localized text. The integration into the priceText string maintains consistency with the existing UI.

lib/features/trades/screens/trade_detail_screen.dart (2)

114-131: LGTM! Premium display logic correctly handles pending creator orders.

The implementation properly formats premium information with appropriate conditional display and localized text.


184-203: LGTM! Consistent premium display logic for non-pending orders.

The implementation mirrors the logic used for pending orders, ensuring consistent premium formatting across different order states.

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tACK

@grunch grunch merged commit c06aaaa into main Jul 25, 2025
2 checks passed
@grunch grunch deleted the improve-order-details branch July 25, 2025 12:54
@coderabbitai coderabbitai Bot mentioned this pull request Sep 1, 2025
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.

2 participants