Skip to content

Conversation

@aliviahossain
Copy link

@aliviahossain aliviahossain commented Dec 9, 2025

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

    • Added user badge display system showing achievement badges with descriptive tooltips on user profiles.
  • Bug Fixes

    • Improved null value handling in data type conversion for greater stability.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

🎉 Welcome @aliviahossain!
Thank you for your pull request! Our team will review it soon. 🔍

  • Please ensure your PR follows the contribution guidelines. ✅
  • All automated tests should pass before merging. 🔄
  • If this PR fixes an issue, link it in the description. 🔗

We appreciate your contribution! 🚀

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

A 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

Cohort / File(s) Summary
Badge system infrastructure
lib/utils/badge_constants.dart, pubspec.yaml
New BadgeConstants class with five static badge IDs (anchor, storyteller, crowdFavorite, conversationalist, audiophile) and two maps (icons, tooltips). Assets directory assets/badges/ added to pubspec.yaml.
Badge display widget
lib/views/widgets/badge_row.dart, lib/views/screens/user_account_screen.dart
New BadgeRow stateless widget renders user badges as a Wrap of 35×35 asset images with tooltips; includes logic to skip badges with missing icon mappings. Import added to user_account_screen.dart.
Null-safety enhancement
lib/models/resonate_user.dart
Null check added to toDouble() function to return null immediately if input is null, preventing fallthrough to type checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Badge icon lookup logic in BadgeRow: verify null/missing key handling is robust
  • Asset paths in BadgeConstants align with actual assets/badges/ directory structure
  • Tooltip default behavior and styling consistency with app design

Suggested labels

enhancement

Poem

A badge row blooms, five treasures bright,
Anchor, storyteller, crowd's delight,
Icons dance in a wrap so neat,
With tooltips whispering stories sweet! 🎖️✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Updated files for badges' is vague and generic, lacking specificity about what was actually implemented (e.g., new badge system, widget addition, constants). Revise the title to be more specific and descriptive, such as 'Implement user badge system with BadgeRow widget and BadgeConstants' or 'Add badge UI component and asset management for user profiles'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 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 an errorBuilder to 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

📥 Commits

Reviewing files that changed from the base of the PR and between b063ecb and 9bc0c74.

⛔ Files ignored due to path filters (5)
  • assets/badges/anchor.png is excluded by !**/*.png
  • assets/badges/audiophile.png is excluded by !**/*.png
  • assets/badges/coversationalist.png is excluded by !**/*.png
  • assets/badges/crowdfav.png is excluded by !**/*.png
  • assets/badges/storyteller.png is 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.

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.

1 participant