Skip to content

UI Refinements for My Trades Screen #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AndreaDiazCorreia
Copy link
Collaborator

@AndreaDiazCorreia AndreaDiazCorreia commented Jun 10, 2025

UI Refinements for My Trades Screen - Issue #86

This PR implements UI improvements to match the design mockups for the My Trades screen:

Changes

  • Inverted background and item colors (darker items, lighter background)
  • Removed filter, trade count, and refresh button for a cleaner UI
  • Moved status and role tags to the same row as the "Buying/Selling Bitcoin" title
  • Fixed amount display to show the actual trade amount (using fiatAmount instead of amount)
  • Improved payment methods display to show all methods in a single line separated by commas
  • Enhanced tag styling with more rounded corners and colored text matching tag background

Notes

  • The order detail screen improvements will be addressed in a separate issue
  • The top navigation bar was kept for aesthetic reasons

image

Summary by CodeRabbit

  • New Features

    • Improved display of trade roles with new colored chips indicating "Created by you" or "Taken by you."
    • Expanded and restyled status indicators for trades, offering clearer visual cues.
  • Refactor

    • Simplified and unified the layout of the trades screen and trade list items for a cleaner, more modern look.
    • Removed filter options and streamlined the header and content areas.
    • Enhanced readability and organization of trade details.
  • Chores

    • Updated Gradle wrapper to version 8.9 for improved build consistency.

Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The trades screen UI was simplified by removing the filter button and related elements, replacing them with a new header and a consolidated content container. The trade list item widget was restyled to use a custom container, added role and status chips with expanded status handling, and removed unused methods and imports for a cleaner layout. Additionally, the Gradle wrapper was updated from version 8.4 to 8.9.

Changes

File(s) Change Summary
lib/features/trades/screens/trades_screen.dart Removed filter button UI and related methods, added new header with dark background, simplified layout, deleted unused imports.
lib/features/trades/widgets/trades_list_item.dart Refactored UI to replace CustomCard and HeroIcons with custom container, added role and status chips with enhanced styling and logic, removed multiple unused methods and imports.
android/gradle/wrapper/gradle-wrapper.properties Updated Gradle wrapper version from 8.4 to 8.9, changed distribution URL, added timestamp comment.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TradesScreen
    participant TradesListItem

    User->>TradesScreen: Opens Trades Screen
    TradesScreen->>TradesScreen: Display new header and content container
    TradesScreen->>TradesListItem: Render each trade item
    TradesListItem->>TradesListItem: Determine role and status
    TradesListItem->>TradesListItem: Display role/status chips and trade info
    User-->>TradesScreen: Pull to refresh (optional)
    TradesScreen->>TradesScreen: Reload trades list
Loading

Suggested reviewers

  • Catrya
  • grunch

Poem

In the meadow of code, trades now shine anew,
With headers bold and roles in view.
No more filters to confuse the scene,
Just chips of color—blue and green.
A streamlined warren, clear and bright,
For every bunny trading right!
🐇✨


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 (1)
lib/features/trades/screens/trades_screen.dart (1)

63-64: Replace Spanish comment with English.

For consistency, please use English for code comments.

-                          // Espacio superior
+                          // Top spacing
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 67bc68f and a09b1b5.

📒 Files selected for processing (2)
  • lib/features/trades/screens/trades_screen.dart (1 hunks)
  • lib/features/trades/widgets/trades_list_item.dart (1 hunks)
🔇 Additional comments (5)
lib/features/trades/screens/trades_screen.dart (1)

31-111: Clean UI restructuring aligns well with PR objectives.

The simplified layout with a clear header and consolidated content area effectively removes the filter UI complexity while maintaining all essential functionality including error handling and refresh capability.

lib/features/trades/widgets/trades_list_item.dart (4)

47-63: Well-structured layout with clear visual hierarchy.

The reorganization effectively places the trade type, status, and role information on the same row as requested in the PR objectives, creating a cleaner and more scannable interface.


76-76: Correct implementation of fiat amount display.

Using fiatAmount.minimum properly addresses the PR objective to show the actual trade amount.


87-101: Clean implementation of payment methods display.

The comma-separated list format for multiple payment methods and fallback to "Bank Transfer" provides a clear and concise presentation.


136-222: Excellent status chip styling with improved visual consistency.

The updated color scheme with dark backgrounds and light text provides good contrast and visual hierarchy. The more rounded corners (borderRadius: 12) align well with the PR's styling objectives.

Copy link
Collaborator

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

Hi @AndreaDiazCorreia all orders have the label created by you even if they are not created by the user.

  • In this screenshot, the 1st and last orders are taken by user, not created by user, it should have the label: taken by you

image

Copy link
Collaborator

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

Please rebase against main
It's important that the statuses displayed on orders are not those published in events 38383 (specifically in-progress), but rather those sent to the user by mostrod in DMs. These would be the same status that were displayed before: pending, waiting-payment, waiting-buyer-invoice, active, fiat-sent, success, canceled.

Copy link
Collaborator

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

It must comply with the aesthetics of lovable, the colors must be darker.

Now:
image

In Lovable:
image

@Catrya
Copy link
Collaborator

Catrya commented Jun 11, 2025

If the order has a % premium or discount, it must also appear on the order card.

Copy link
Collaborator

@chebizarro chebizarro left a comment

Choose a reason for hiding this comment

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

Suggestions follow to address comments on order creator/owner and status

final role = session?.role;
final isBuying = role == Role.buyer;
// Determine if the user is the creator of the order based on available information
final isCreator = session != null && role != null;

Copy link
Collaborator

Choose a reason for hiding this comment

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

In order to display the internal status as per:
#116 (review)
you will first need to retrieve the current OrderState:

Suggested change
final orderState = ref.watch(orderNotifierProvider(trade.orderId!));

),
),
const Spacer(),
_buildStatusChip(trade.status),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can then use the OrderState.status which is the internal Mostro order status and not the one from the 38383 event

Suggested change
_buildStatusChip(trade.status),
_buildStatusChip(orderState.status),

@AndreaDiazCorreia
Copy link
Collaborator Author

@Catrya what do you think about this colors?
image

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

🧹 Nitpick comments (2)
lib/features/trades/widgets/trades_list_item.dart (2)

92-115: Duplicated double.parse(...) – parse once, reuse

trade.premium is parsed three times inside this small block. Parsing once simplifies the code and avoids redundant work:

-                        if (trade.premium != null && trade.premium != '0')
+                        final premium = double.tryParse(trade.premium ?? '');
+                        if (premium != null && premium != 0)
 ...
-                                color:
-                                    double.tryParse(trade.premium!) != null &&
-                                            double.parse(trade.premium!) > 0
+                                color: (premium ?? 0) > 0
                                         ? Colors.green.shade700
                                         : Colors.red.shade700,
 ...
-                                '${double.tryParse(trade.premium!) != null && double.parse(trade.premium!) > 0 ? '+' : ''}${trade.premium}%',
+                                '${premium! > 0 ? '+' : ''}${premium.toStringAsFixed(2)}%',

170-238: _buildStatusChip is very verbose – consider a lookup map

22 identical switch branches differ only by three values (background, text color, label). A simple map drives the same result with ⅓ of the code and far less maintenance overhead:

static const _statusStyles = {
  Status.active:      _ChipStyle('Active',      Color(0xFF1E3A8A), Color(0xFF93C5FD)),
  Status.pending:     _ChipStyle('Pending',     Color(0xFF854D0E), Color(0xFFFCD34D)),
  Status.fiatSent:    _ChipStyle('Fiat-sent',   Color(0xFF065F46), Color(0xFF6EE7B7)),
  ...
};

Widget _buildStatusChip(Status status) {
  final style = _statusStyles[status] ??
      _ChipStyle(status.name, Colors.grey, Colors.white);

  return Container(
    padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
    decoration: BoxDecoration(
      color: style.bg.withOpacity(0.3),
      borderRadius: BorderRadius.circular(12),
    ),
    child: Text(
      style.label,
      style: TextStyle(color: style.fg, fontSize: 12, fontWeight: FontWeight.w500),
    ),
  );
}

class _ChipStyle {
  const _ChipStyle(this.label, this.bg, this.fg);
  final String label;
  final Color  bg;
  final Color  fg;
}

Benefits: easier to add new statuses, avoids future copy-paste errors, and reduces file size.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce0ed1 and 345ce71.

📒 Files selected for processing (3)
  • android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • lib/features/trades/screens/trades_screen.dart (2 hunks)
  • lib/features/trades/widgets/trades_list_item.dart (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • android/gradle/wrapper/gradle-wrapper.properties
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/features/trades/screens/trades_screen.dart

Comment on lines +23 to +27
final session = ref.watch(sessionProvider(trade.orderId!));
final role = session?.role;
final isBuying = role == Role.buyer;
final orderState = ref.watch(orderNotifierProvider(trade.orderId!));

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Null-safety guard for orderId is missing

trade.orderId! is force-unwrapped twice. If a corrupted/legacy event reaches this widget with a null orderId, the entire screen will crash.

-    final session = ref.watch(sessionProvider(trade.orderId!));
-    final role = session?.role;
-    final isBuying = role == Role.buyer;
-    final orderState = ref.watch(orderNotifierProvider(trade.orderId!));
+    final orderId = trade.orderId;
+    if (orderId == null) {
+      // Defensive – skip rendering instead of crashing
+      return const SizedBox.shrink();
+    }
+
+    final session    = ref.watch(sessionProvider(orderId));
+    final role       = session?.role;
+    final isBuying   = role == Role.buyer;
+    final orderState = ref.watch(orderNotifierProvider(orderId));
📝 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
final session = ref.watch(sessionProvider(trade.orderId!));
final role = session?.role;
final isBuying = role == Role.buyer;
final orderState = ref.watch(orderNotifierProvider(trade.orderId!));
final orderId = trade.orderId;
if (orderId == null) {
// Defensive – skip rendering instead of crashing
return const SizedBox.shrink();
}
final session = ref.watch(sessionProvider(orderId));
final role = session?.role;
final isBuying = role == Role.buyer;
final orderState = ref.watch(orderNotifierProvider(orderId));
🤖 Prompt for AI Agents
In lib/features/trades/widgets/trades_list_item.dart around lines 23 to 27, the
code force-unwraps trade.orderId twice without null-safety checks, risking a
crash if orderId is null. Add a null check before using trade.orderId, and
handle the null case gracefully, such as returning early or showing a fallback
UI, to prevent the screen from crashing when orderId is null.

Comment on lines +28 to 32
// Determine if the user is the creator of the order based on role and order type
final isCreator = isBuying
? trade.orderType == OrderType.buy
: trade.orderType == OrderType.sell;

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

isCreator still yields wrong results when either role or orderType is null

If role == null the ternary falls into the seller branch, which marks the order as “Created by you” whenever orderType == sell.
Guard against nulls and use a single, explicit comparison:

-final isCreator = isBuying
-        ? trade.orderType == OrderType.buy
-        : trade.orderType == OrderType.sell;
+final orderType = trade.orderType;
+final isCreator = role != null &&
+    orderType != null &&
+    ((role == Role.buyer  && orderType == OrderType.buy) ||
+     (role == Role.seller && orderType == OrderType.sell));
📝 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 the user is the creator of the order based on role and order type
final isCreator = isBuying
? trade.orderType == OrderType.buy
: trade.orderType == OrderType.sell;
// Determine if the user is the creator of the order based on role and order type
final orderType = trade.orderType;
final isCreator = role != null &&
orderType != null &&
((role == Role.buyer && orderType == OrderType.buy) ||
(role == Role.seller && orderType == OrderType.sell));
🤖 Prompt for AI Agents
In lib/features/trades/widgets/trades_list_item.dart around lines 28 to 32, the
isCreator calculation does not handle null values for role or orderType, causing
incorrect results. Update the logic to explicitly check for nulls before
comparing role and orderType, and use a single clear comparison that returns
true only when the user's role matches the orderType, ensuring no false
positives when either value is null.

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