Skip to content

Conversation

@AndreaDiazCorreia
Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia commented Jun 2, 2025

This PR addresses issue #105 with the following improvements:

  • Moved info icons next to section titles for better visibility
  • Made info icons tappable with improved dialog display
  • Changed premium slider to display whole numbers only
  • Added dynamic text change in price type section (shows "Fixed price" when market is off)
  • Enhanced dialog styling with better centering, larger text, and improved button appearance

These changes improve the usability and clarity of the Create Order screen.

Summary by CodeRabbit

  • New Features
    • Added informational tooltips to form sections, providing users with helpful explanations when tapping the info icon.
  • Improvements
    • The Add Order button and bottom navigation bar now better respect device safe areas, improving layout on devices with notches or system overlays.
    • Order list items now clearly distinguish between fixed price and market price orders, enhancing clarity in order details.
    • Premium values are now displayed as whole numbers for easier reading.
    • Price type labeling is now dynamic, switching between "Market price" and "Fixed price" as appropriate.
    • Enhanced input validation and digit-only input restriction for the sats amount field when not using market rate.
  • Style
    • Updated the Add Order menu button layout for improved visual separation of arrow icons and button labels.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 2, 2025

Walkthrough

This update introduces dynamic positioning for the AddOrderButton on the home screen, enhances order list item UI to distinguish fixed and market price orders, adds tooltips to form sections, and improves safe area handling for navigation and button components. Several widgets are visually refined, with new tooltip dialogs and conditional icon rendering.

Changes

File(s) Change Summary
lib/features/home/screens/home_screen.dart Adjusted AddOrderButton's vertical position to account for device bottom padding dynamically using MediaQuery.
lib/features/home/widgets/order_list_item.dart Introduced isFixedOrder logic; restructured order detail display to conditionally show fixed sats or market price with premium, updating UI to differentiate order types.
lib/features/order/widgets/form_section.dart Added optional infoTooltip parameter; displays info icon and modal dialog with tooltip when provided; changed title layout from single text to row with conditional icon.
lib/features/order/widgets/premium_section.dart Changed premium value display to show whole numbers; added tooltip string to FormSection; removed extra info icon widget.
lib/features/order/widgets/price_type_section.dart Made price label dynamic based on isMarketRate; added tooltip string to FormSection; removed extra info icon widget.
lib/shared/widgets/add_order_button.dart Modified button layout: arrow icon now conditionally overlays to the left of button label using a Stack and Positioned widget; icon parameter replaced with empty SizedBox; removed comments.
lib/shared/widgets/bottom_nav_bar.dart Wrapped navigation bar in SafeArea (bottom only) to respect device safe area insets; internal structure unchanged except for indentation.
lib/features/order/screens/add_order_screen.dart Added input formatter to restrict sats amount input to digits only when not using market rate; enhanced validator to check numeric input accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeScreen
    participant AddOrderButton
    participant MediaQuery

    User->>HomeScreen: Opens home screen
    HomeScreen->>MediaQuery: Get device bottom padding
    HomeScreen->>AddOrderButton: Position button at (80 + bottom padding + 16) from bottom
    AddOrderButton-->>User: Renders at dynamic position
Loading
sequenceDiagram
    participant User
    participant OrderListItem

    User->>OrderListItem: View order details
    OrderListItem->>OrderListItem: Determine isFixedOrder
    alt isFixedOrder
        OrderListItem-->>User: Show "For X sats"
    else
        OrderListItem-->>User: Show "Market Price" + premium %
    end
Loading
sequenceDiagram
    participant User
    participant FormSection
    participant Dialog

    User->>FormSection: Sees section with info icon
    User->>FormSection: Taps info icon
    FormSection->>Dialog: Show tooltip modal
    User->>Dialog: Reads and dismisses
    Dialog->>FormSection: Close modal
Loading

Possibly related PRs

  • MostroP2P/mobile#108: Adjusted AddOrderButton bottom offset to include device bottom padding, directly related to this PR's positioning changes.
  • MostroP2P/mobile#98: Introduced the initial AddOrderButton and UI redesigns in home_screen.dart; both PRs modify AddOrderButton usage and layout.
  • MostroP2P/mobile#103: Refactored AddOrderButton to a stateful widget with an expandable menu and repositioned it in home_screen.dart; both PRs directly relate to AddOrderButton's positioning and layout.

Suggested reviewers

  • chebizarro

Poem

In the meadow of code where the widgets hop free,
A button now floats with safe padding, you see!
Tooltips are blooming, with info to share,
And orders show prices with clarity rare.
Navigation’s cozy, snug in its bar—
This patch is a treat for devs near and far!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f4dc1ed and d353d00.

📒 Files selected for processing (1)
  • lib/features/order/screens/add_order_screen.dart (2 hunks)
🔇 Additional comments (3)
lib/features/order/screens/add_order_screen.dart (3)

2-2: LGTM!

The import for flutter/services.dart is correctly added to support the FilteringTextInputFormatter used later in the code.


191-193: Enhance input validation with numeric-only check.

The validator correctly ensures that fixed price orders only accept numeric input. The regex pattern ^[0-9]+$ appropriately validates whole numbers only, which is suitable for sats amounts.


196-199: Good defensive programming with input formatter.

The FilteringTextInputFormatter.digitsOnly provides an excellent user experience by preventing non-numeric characters from being entered in the first place. This works well in combination with the validator to ensure data integrity.


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 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.

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

🧹 Nitpick comments (2)
lib/features/order/widgets/premium_section.dart (1)

17-21: Good simplification for premium display.

Showing whole numbers using value.round() simplifies the UI as requested. However, be aware that this introduces a visual precision loss - the actual slider value might be 1.5% but displays as "2". Consider whether this discrepancy between displayed and actual values could confuse users during fine-tuning.

lib/shared/widgets/add_order_button.dart (1)

90-90: Consider semantic meaning of empty SizedBox for icon parameter.

While the empty SizedBox maintains layout, it might be clearer to use a more explicit approach since the icon parameter is now essentially unused.

Consider using a more semantic approach:

-                        icon: const SizedBox(width: 16, height: 16),
+                        icon: const SizedBox.shrink(), // No icon, using overlay instead

Or consider using ElevatedButton instead of ElevatedButton.icon since no icon is actually being used in the traditional sense.

Also applies to: 119-119

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c403a5b and f4dc1ed.

📒 Files selected for processing (7)
  • lib/features/home/screens/home_screen.dart (1 hunks)
  • lib/features/home/widgets/order_list_item.dart (2 hunks)
  • lib/features/order/widgets/form_section.dart (3 hunks)
  • lib/features/order/widgets/premium_section.dart (2 hunks)
  • lib/features/order/widgets/price_type_section.dart (1 hunks)
  • lib/shared/widgets/add_order_button.dart (2 hunks)
  • lib/shared/widgets/bottom_nav_bar.dart (2 hunks)
🔇 Additional comments (10)
lib/shared/widgets/bottom_nav_bar.dart (1)

21-23: LGTM! Proper safe area implementation.

The SafeArea wrapper with top: false correctly ensures the bottom navigation bar respects device safe areas (like home indicators on newer devices) while preserving the existing layout structure. This aligns well with the dynamic positioning changes in the home screen.

lib/features/home/screens/home_screen.dart (1)

82-82: Excellent dynamic positioning implementation.

The calculation 80 + MediaQuery.of(context).viewPadding.bottom + 16 properly accounts for device-specific safe areas while maintaining consistent spacing. This ensures the AddOrderButton is always positioned correctly above the bottom navigation, regardless of device type (notched phones, phones with home indicators, etc.).

lib/features/order/widgets/price_type_section.dart (2)

28-28: Well-crafted informational tooltip.

The tooltip text clearly explains the difference between Market Price and Fixed Price options, helping users make informed decisions. The bullet-point format makes it easy to understand both options.


32-36: Excellent dynamic label implementation.

The conditional text display isMarketRate ? 'Market price' : 'Fixed price' provides immediate visual feedback about the current selection, improving user understanding of their choice. This enhances the UX by making the interface more responsive and informative.

lib/features/order/widgets/premium_section.dart (1)

28-28: Excellent explanatory tooltip for premium concept.

The tooltip clearly explains the premium percentage concept and reassures users about the default 0% setting. This is particularly helpful for users new to P2P trading who might not understand what "premium" means in this context.

lib/features/order/widgets/form_section.dart (2)

10-10: LGTM! Clean addition of optional tooltip parameter.

The optional infoTooltip parameter is well-designed and maintains backward compatibility.


34-96: Well-implemented tooltip dialog with good UX.

The implementation successfully centralizes tooltip functionality with several strong points:

  • Clean conditional rendering that only shows the info icon when tooltip content exists
  • Consistent dialog styling that matches the app theme (dark background, green button)
  • Proper spacing and layout with centered text and full-width button
  • Good accessibility with tappable area and clear visual feedback
lib/features/home/widgets/order_list_item.dart (1)

115-189: Excellent UI restructuring for better order type clarity.

The layout changes provide clear visual distinction between fixed and market price orders:

  • Clean separation of currency display and price type information
  • Consistent styling with proper color coding for premium values
  • Intuitive labeling ("For X sats" vs "Market Price (+X%)")
lib/shared/widgets/add_order_button.dart (2)

74-101: Clean implementation of overlay arrow icons.

The Stack approach with conditional Positioned arrows is well-executed:

  • Arrow directions are semantically appropriate (downward for BUY indicating price decrease expectation)
  • Proper positioning at left: 16 aligns with visual hierarchy
  • Conditional rendering ensures arrows only appear when menu is open

103-130: Consistent implementation for SELL button.

The SELL button follows the same pattern with appropriate upward arrow direction, maintaining visual and functional consistency.

Comment on lines +20 to +22
// Determine if this is a fixed order (has specific sats amount and is not zero)
final bool isFixedOrder =
order.amount != null && order.amount != "0" && order.amount!.isNotEmpty;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the logic for determining fixed orders.

The logic checks for non-null, non-zero, and non-empty amount, but should we also validate that the amount is a valid number?


🏁 Script executed:

#!/bin/bash
# Description: Search for other usages of order.amount to understand the expected data format and validation patterns

# Search for other places where order.amount is used
rg -A 3 -B 3 "order\.amount" --type dart

# Look for amount validation patterns
rg -A 5 "amount.*validation\|validate.*amount" --type dart

Length of output: 3143


Validate order.amount as a numeric value before treating it as “fixed”

To avoid treating non‐numeric or malformed strings as valid sat amounts, parse and check the numeric value instead of just non‐null/non‐empty:

lib/features/home/widgets/order_list_item.dart (around lines 20–22):

- // Determine if this is a fixed order (has specific sats amount and is not zero)
- final bool isFixedOrder =
-     order.amount != null && order.amount != "0" && order.amount!.isNotEmpty;
+ // Determine if this is a fixed order (valid positive sats amount)
+ final int? satAmount = int.tryParse(order.amount ?? '');
+ final bool isFixedOrder = satAmount != null && satAmount > 0;

This guarantees that only valid, positive integer amounts are treated as fixed orders.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Determine if this is a fixed order (has specific sats amount and is not zero)
final bool isFixedOrder =
order.amount != null && order.amount != "0" && order.amount!.isNotEmpty;
// Determine if this is a fixed order (valid positive sats amount)
final int? satAmount = int.tryParse(order.amount ?? '');
final bool isFixedOrder = satAmount != null && satAmount > 0;
🤖 Prompt for AI Agents
In lib/features/home/widgets/order_list_item.dart around lines 20 to 22, the
current logic to determine if an order is fixed only checks if order.amount is
non-null, non-zero, and non-empty, but does not verify if it is a valid numeric
value. Update the code to parse order.amount as an integer and confirm it is a
positive number before setting isFixedOrder to true. This ensures only valid
numeric amounts are considered fixed orders.

Copy link
Member

@Catrya Catrya 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 85c4947 into MostroP2P:main Jun 3, 2025
1 check passed
@AndreaDiazCorreia AndreaDiazCorreia deleted the feat/issue-105 branch June 10, 2025 00:51
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.

3 participants