feat: display premium/discount in order details and omit 0%#232
Conversation
WalkthroughThe 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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: UseS.of(context).yourKeyfor all user-facing strings
Always checkmountedbefore using context after async operations
Files:
lib/features/order/widgets/payment_methods_section.dartlib/features/home/widgets/order_list_item.dartlib/features/order/screens/take_order_screen.dartlib/features/trades/screens/trade_detail_screen.dart
**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.dart: Remove unused imports and dependencies
Useconstconstructors where possible
Files:
lib/features/order/widgets/payment_methods_section.dartlib/features/home/widgets/order_list_item.dartlib/features/order/screens/take_order_screen.dartlib/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.
Summary by CodeRabbit