-
Notifications
You must be signed in to change notification settings - Fork 1
feat(us10): phase 13 — post-trade rating system #64
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
| import 'package:go_router/go_router.dart'; | ||
|
|
||
| import 'package:mostro/core/app_theme.dart'; | ||
| import 'package:mostro/features/rate/widgets/star_rating.dart'; | ||
|
|
||
| /// Rate counterpart screen — Route `/rate_user/:orderId`. | ||
| /// | ||
| /// Prompted after trade completion: | ||
| /// - Seller: prompted at `SettledHoldInvoice` (after releasing funds) | ||
| /// - Buyer: prompted at `Success` (after payment confirmed) | ||
| /// | ||
| /// Layout: | ||
| /// - "RATE" header label (uppercase, gray) | ||
| /// - Green double-lightning-bolt success indicator + "Successful order" text | ||
| /// - [StarRating] widget (5 tappable stars) | ||
| /// - "X / 5" score display | ||
| /// - SUBMIT button (green filled, disabled until rating > 0) | ||
| /// - CLOSE button (green outline, skips rating) | ||
| class RateCounterpartScreen extends ConsumerStatefulWidget { | ||
| const RateCounterpartScreen({super.key, required this.orderId}); | ||
|
|
||
| final String orderId; | ||
|
|
||
| @override | ||
| ConsumerState<RateCounterpartScreen> createState() => | ||
| _RateCounterpartScreenState(); | ||
| } | ||
|
|
||
| class _RateCounterpartScreenState | ||
| extends ConsumerState<RateCounterpartScreen> { | ||
| int _rating = 0; | ||
| bool _isSubmitting = false; | ||
|
|
||
| Future<void> _submit() async { | ||
| if (_rating == 0) return; | ||
| setState(() => _isSubmitting = true); | ||
| try { | ||
| // TODO(bridge): Call reputation.submit_rating(widget.orderId, _rating) | ||
| // via Rust bridge once FFI bindings are generated. | ||
| await Future.delayed(const Duration(milliseconds: 300)); | ||
| if (mounted) context.pop(); | ||
| } catch (e) { | ||
| if (!mounted) return; | ||
| ScaffoldMessenger.of(context).showSnackBar( | ||
| SnackBar(content: Text('Rating failed: $e')), | ||
| ); | ||
| } finally { | ||
| if (mounted) setState(() => _isSubmitting = false); | ||
| } | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colors = Theme.of(context).extension<AppColors>(); | ||
| assert(colors != null, 'AppColors theme extension must be registered'); | ||
| if (colors == null) return const SizedBox.shrink(); | ||
|
|
||
| final textTheme = Theme.of(context).textTheme; | ||
| final green = colors.mostroGreen; | ||
|
|
||
| return Scaffold( | ||
| backgroundColor: colors.backgroundDark, | ||
| body: SafeArea( | ||
| child: Padding( | ||
| padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg), | ||
| child: Column( | ||
| children: [ | ||
| const SizedBox(height: AppSpacing.xl), | ||
|
|
||
| // ── "RATE" header ───────────────────────────────────────── | ||
| Text( | ||
| 'RATE', | ||
| style: textTheme.labelMedium?.copyWith( | ||
| color: colors.textSubtle, | ||
| letterSpacing: 2, | ||
| fontWeight: FontWeight.w600, | ||
| ), | ||
| ), | ||
|
|
||
| const SizedBox(height: AppSpacing.xl), | ||
|
|
||
| // ── Success indicator ───────────────────────────────────── | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| Icon(Icons.bolt, color: green, size: 32), | ||
| Icon(Icons.bolt, color: green, size: 32), | ||
| ], | ||
| ), | ||
| const SizedBox(height: AppSpacing.sm), | ||
| Text( | ||
| 'Successful order', | ||
| style: textTheme.titleMedium?.copyWith( | ||
| color: green, | ||
| fontWeight: FontWeight.bold, | ||
| ), | ||
| ), | ||
|
|
||
| const SizedBox(height: AppSpacing.xl), | ||
|
|
||
| // ── Star rating ─────────────────────────────────────────── | ||
| StarRating( | ||
| rating: _rating, | ||
| onChanged: (value) => setState(() => _rating = value), | ||
| ), | ||
|
|
||
| const SizedBox(height: AppSpacing.md), | ||
|
|
||
| // ── "X / 5" display ─────────────────────────────────────── | ||
| Text( | ||
| '$_rating / 5', | ||
| style: textTheme.headlineSmall?.copyWith( | ||
| color: colors.textPrimary, | ||
| fontWeight: FontWeight.bold, | ||
| ), | ||
| ), | ||
|
|
||
| const Spacer(), | ||
|
|
||
| // ── SUBMIT button ───────────────────────────────────────── | ||
| FilledButton( | ||
| onPressed: (_rating > 0 && !_isSubmitting) ? _submit : null, | ||
| style: FilledButton.styleFrom( | ||
| backgroundColor: green, | ||
| foregroundColor: Colors.black, | ||
| disabledBackgroundColor: green.withValues(alpha: 0.35), | ||
| disabledForegroundColor: Colors.black54, | ||
| minimumSize: const Size.fromHeight(48), | ||
| shape: RoundedRectangleBorder( | ||
| borderRadius: BorderRadius.circular(AppRadius.button), | ||
| ), | ||
| ), | ||
| child: _isSubmitting | ||
| ? const SizedBox( | ||
| width: 20, | ||
| height: 20, | ||
| child: CircularProgressIndicator( | ||
| strokeWidth: 2, | ||
| color: Colors.black54, | ||
| ), | ||
| ) | ||
| : const Text( | ||
| 'SUBMIT', | ||
| style: TextStyle(fontWeight: FontWeight.bold), | ||
| ), | ||
| ), | ||
|
|
||
| const SizedBox(height: AppSpacing.sm), | ||
|
|
||
| // ── CLOSE button (skip rating) ──────────────────────────── | ||
| OutlinedButton( | ||
| onPressed: () => context.pop(), | ||
| style: OutlinedButton.styleFrom( | ||
| foregroundColor: green, | ||
| side: BorderSide(color: green), | ||
| minimumSize: const Size.fromHeight(48), | ||
| shape: RoundedRectangleBorder( | ||
| borderRadius: BorderRadius.circular(AppRadius.button), | ||
| ), | ||
| ), | ||
| child: const Text( | ||
| 'CLOSE', | ||
| style: TextStyle(fontWeight: FontWeight.bold), | ||
| ), | ||
| ), | ||
|
|
||
| const SizedBox(height: AppSpacing.lg), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import 'package:mostro/core/app_theme.dart'; | ||
|
|
||
| /// Interactive 5-star rating selector. | ||
| /// | ||
| /// Renders 5 tappable [Icon] widgets. Filled stars use [AppColors.mostroGreen] | ||
| /// (`#8CC63F`); empty stars use a dark-gray outline. Tapping a star sets the | ||
| /// rating to that star's index + 1 (1-based). | ||
| /// | ||
| /// The [onChanged] callback is invoked with the new score whenever the user | ||
| /// taps a star. The widget is read-only when [onChanged] is null. | ||
| class StarRating extends StatelessWidget { | ||
| const StarRating({ | ||
| super.key, | ||
| required this.rating, | ||
| this.onChanged, | ||
| this.starSize = 40.0, | ||
| }) : assert(rating >= 0 && rating <= 5); | ||
|
|
||
| /// Current rating value (0 = none selected, 1–5 = star count). | ||
| final int rating; | ||
|
|
||
| /// Called with the new score when the user taps a star. | ||
| /// Pass `null` to make the widget read-only. | ||
| final ValueChanged<int>? onChanged; | ||
|
|
||
| /// Diameter of each star icon in logical pixels. | ||
| final double starSize; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colors = Theme.of(context).extension<AppColors>(); | ||
| final filledColor = colors?.mostroGreen ?? const Color(0xFF8CC63F); | ||
| const emptyColor = Color(0xFF4A4A4A); | ||
|
|
||
| return Row( | ||
| mainAxisSize: MainAxisSize.min, | ||
| children: List.generate(5, (index) { | ||
| final isFilled = index < rating; | ||
| final starNumber = index + 1; | ||
| return IconButton( | ||
| onPressed: onChanged == null ? null : () => onChanged!(starNumber), | ||
| tooltip: 'Select $starNumber star${starNumber == 1 ? '' : 's'}', | ||
| padding: const EdgeInsets.symmetric(horizontal: 4), | ||
| constraints: BoxConstraints(minWidth: starSize + 8, minHeight: starSize + 8), | ||
| icon: Icon( | ||
| isFilled ? Icons.star_rounded : Icons.star_outline_rounded, | ||
| color: isFilled ? filledColor : emptyColor, | ||
| size: starSize, | ||
| ), | ||
| ); | ||
| }), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUBMIT currently reports success without saving anything.
This handler only waits 300 ms and pops the route; it never calls
rust/src/api/reputation.rs::submit_rating(). The UI therefore shows a successful flow while nothing is persisted, and backend errors likePrivacyModeEnabled/AlreadyRatedcan never reach the user. Wire the generated bridge call here and dismiss only after it succeeds.🤖 Prompt for AI Agents