-
Notifications
You must be signed in to change notification settings - Fork 315
Updated files for badges #632
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
base: master
Are you sure you want to change the base?
Conversation
|
🎉 Welcome @aliviahossain!
We appreciate your contribution! 🚀 |
WalkthroughA badge display system is introduced, consisting of badge constants (IDs, icon paths, tooltips), a new BadgeRow widget to render badges, and configuration updates. Additionally, a null-safety enhancement is added to the toDouble() utility function. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (6)
lib/views/screens/user_account_screen.dart (1)
6-6: Unused import - remove until integration is complete.The BadgeRow import is not yet used in this screen. Per the PR objectives, integration is deferred until the backend is ready. Consider removing this import for now to avoid unused import warnings and add it back when you integrate the widget with
user.badges.-import 'widgets/badge_row.dart';lib/views/widgets/badge_row.dart (4)
10-12: Use const for empty widget.Consider using
const SizedBox.shrink()for better performance, as the widget is immutable.- if (userBadges.isEmpty) return SizedBox.shrink(); // Hide if no badges + if (userBadges.isEmpty) return const SizedBox.shrink(); // Hide if no badges
16-21: Use const for empty widget.Same as the earlier case, use
const SizedBox.shrink()when iconPath is null.// If we define a badge in DB but forget the image, don't crash - if (iconPath == null) return SizedBox.shrink(); + if (iconPath == null) return const SizedBox.shrink();
22-30: Add error handling for missing badge assets.Currently, if a badge asset file is missing from
assets/badges/, the app may display an error icon or crash. Consider adding anerrorBuilderto gracefully handle missing assets.return Tooltip( message: BadgeConstants.tooltips[badgeId] ?? '', triggerMode: TooltipTriggerMode.tap, child: Image.asset( iconPath, width: 35, // Size of the badge height: 35, + errorBuilder: (context, error, stackTrace) { + return const SizedBox.shrink(); // Hide badges with missing assets + }, ), );
22-24: Consider tooltip discoverability.The tap trigger for tooltips may not be discoverable on mobile devices, as users typically don't expect to tap badges. Consider using
TooltipTriggerMode.longPress(the default) or adding a visual indicator that badges are tappable for more information.lib/utils/badge_constants.dart (1)
1-6: Add private constructor to prevent instantiation.Since this is a constants-only class with static members, it should not be instantiable. Add a private constructor following Dart's utility class pattern.
class BadgeConstants { + // Private constructor to prevent instantiation + BadgeConstants._(); + static const String anchor = 'ANCHOR'; static const String storyteller = 'STORYTELLER'; static const String crowdFavorite = 'CROWD_FAVORITE'; static const String conversationalist = 'CONVERSATIONALIST'; static const String audiophile = 'AUDIOPHILE';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
assets/badges/anchor.pngis excluded by!**/*.pngassets/badges/audiophile.pngis excluded by!**/*.pngassets/badges/coversationalist.pngis excluded by!**/*.pngassets/badges/crowdfav.pngis excluded by!**/*.pngassets/badges/storyteller.pngis excluded by!**/*.png
📒 Files selected for processing (5)
lib/models/resonate_user.dart(1 hunks)lib/utils/badge_constants.dart(1 hunks)lib/views/screens/user_account_screen.dart(1 hunks)lib/views/widgets/badge_row.dart(1 hunks)pubspec.yaml(1 hunks)
🔇 Additional comments (4)
pubspec.yaml (1)
134-134: LGTM!The badge assets directory is correctly registered to support the new BadgeRow widget.
lib/models/resonate_user.dart (1)
23-28: LGTM - improved null safety.The explicit null check at the beginning makes the function's behavior clearer and more defensive.
lib/utils/badge_constants.dart (2)
8-15: LGTM!The icon mappings are well-structured with all badge IDs covered and const appropriately used.
17-24: LGTM!The tooltip descriptions are clear and user-friendly, with complete coverage of all badge types.
Subject: Feature: Gamification Badges UI & Architecture
Description: I have implemented the frontend architecture for the new User Badge system. This includes:
Assets: Added high-quality badge icons (Anchor, Storyteller, Crowd Favorite, etc.).
UI Component: Created a reusable BadgeRow widget that dynamically renders badges with tooltips.
Architecture: Set up BadgeConstants to map database IDs to asset paths.
Integration: Integrated the BadgeRow into the User Account Screen.
Note for Maintainers (Action Required): Due to a local environment issue with build_runner, I could not regenerate the ResonateUser.freezed.dart file. Therefore, I have commented out the backend logic to prevent build errors.
To finalize this feature, please:
Add a badges (String Array) attribute to the Users collection in Appwrite.
Add @default([]) List badges, to ResonateUser model.
Run flutter pub run build_runner build.
Update User Account Screen to pass user.badges into the BadgeRow
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.