Skip to content

feat(ui): add child support to StreamBadgeNotification and StreamBadgeCount#102

Merged
xsahil03x merged 1 commit intomainfrom
feat/support-child-in-badge
Apr 13, 2026
Merged

feat(ui): add child support to StreamBadgeNotification and StreamBadgeCount#102
xsahil03x merged 1 commit intomainfrom
feat/support-child-in-badge

Conversation

@xsahil03x
Copy link
Copy Markdown
Member

@xsahil03x xsahil03x commented Apr 13, 2026

Description of the pull request

Allow badge components to wrap a child widget with configurable alignment and offset, matching the pattern used by StreamOnlineIndicator. Also removes alignment/offset from StreamOnlineIndicatorThemeData as these are layout concerns, not styling.

Summary by CodeRabbit

  • New Features

    • Badge count and notification components now accept optional child widgets, enabling badges to position themselves relative to wrapped content with customizable alignment and offset parameters.
    • Gallery showcase expanded with new examples demonstrating badge positioning with child widgets and alignment variants.
  • Breaking Changes

    • Removed alignment and offset parameters from online indicator theme configuration.

…eCount

Allow badge components to wrap a child widget with configurable
alignment and offset, matching the pattern used by StreamOnlineIndicator.
Also removes alignment/offset from StreamOnlineIndicatorThemeData as
these are layout concerns, not styling.

Made-with: Cursor
@xsahil03x xsahil03x requested a review from a team as a code owner April 13, 2026 11:30
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Badge components now support optional child, alignment, and offset parameters for positioning badges over child widgets. StreamOnlineIndicatorThemeData had its alignment and offset fields removed to shift positioning control from theme to instance level. Gallery examples updated to showcase new badge positioning capabilities.

Changes

Cohort / File(s) Summary
Badge Component Enhancements
packages/stream_core_flutter/lib/src/components/badge/stream_badge_count.dart, packages/stream_core_flutter/lib/src/components/badge/stream_badge_notification.dart
Added child, alignment, and offset parameters to both badge components. When child is provided, badge wraps the child in a Stack with Align and Transform.translate to position the badge relative to the child using the provided alignment and offset (defaults: AlignmentDirectional.topEnd, Offset.zero).
Online Indicator Theme Refactor
packages/stream_core_flutter/lib/src/theme/components/stream_online_indicator_theme.dart, packages/stream_core_flutter/lib/src/theme/components/stream_online_indicator_theme.g.theme.dart
Removed alignment and offset from StreamOnlineIndicatorThemeData constructor and public fields. Breaking change: positioning now controlled only at instance level via DefaultStreamOnlineIndicator props rather than theme defaults.
Online Indicator Logic Update
packages/stream_core_flutter/lib/src/components/badge/stream_online_indicator.dart
Updated DefaultStreamOnlineIndicator to compute effective alignment and offset only from props values (fallback to AlignmentDirectional.topEnd and Offset.zero), removing fallback to theme values.
Gallery Playground & Showcase Updates
apps/design_system_gallery/lib/components/badge/stream_badge_count.dart, apps/design_system_gallery/lib/components/badge/stream_badge_notification.dart, apps/design_system_gallery/lib/components/badge/stream_online_indicator.dart
Added withChild knob to conditionally show badge-with-child examples. Introduced alignment and offset knobs (active when withChild enabled). Added new showcase sections (_AlignmentVariantsSection, _UsagePatternsSection, _ExampleCard) to demonstrate positioning variants and usage patterns. Updated "Avatar with Badge" example to use new StreamBadgeCount child wrapping instead of manual Stack positioning.
Documentation
packages/stream_core_flutter/CHANGELOG.md
Added breaking change note (removal of alignment/offset from StreamOnlineIndicatorThemeData) and feature notes documenting new child, alignment, offset support in StreamBadgeNotification and StreamBadgeCount.

Sequence Diagram

sequenceDiagram
    participant Client
    participant StreamBadge as Badge Component
    participant Stack
    participant Align
    participant Transform

    Client->>StreamBadge: new StreamBadge(child, alignment, offset)
    alt child is null
        StreamBadge-->>Client: return badge only
    else child is provided
        StreamBadge->>Stack: Stack(children: [child, badge])
        Stack->>Align: Align(alignment, child: Transform)
        Align->>Transform: Transform.translate(offset, child: badge)
        Transform-->>Stack: positioned badge
        Stack-->>Client: wrapped layout
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Badges now dance with grace and care,
Wrapping children with flair to spare,
No theme-bound chains, just props that guide,
Alignment blooms at each widget's side,
Stack by stack, a prettier pride!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the feature and rationale, but lacks required template sections like Linear ticket, CLA checkbox, testing details, and screenshots. Add missing template sections: Linear ticket number, CLA acknowledgment checkbox, testing instructions, and before/after screenshots or video demonstrations.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature change: adding child support to two badge components with alignment and offset parameters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/support-child-in-badge

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 8.69565% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.68%. Comparing base (0332dc1) to head (52c925d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r/lib/src/components/badge/stream_badge_count.dart 0.00% 11 Missing ⚠️
...rc/components/badge/stream_badge_notification.dart 20.00% 8 Missing ⚠️
.../src/components/badge/stream_online_indicator.dart 0.00% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (8.69%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #102      +/-   ##
==========================================
- Coverage   24.73%   24.68%   -0.06%     
==========================================
  Files         152      152              
  Lines        5623     5639      +16     
==========================================
+ Hits         1391     1392       +1     
- Misses       4232     4247      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stream_core_flutter/lib/src/components/badge/stream_online_indicator.dart (1)

136-147: ⚠️ Potential issue | 🟡 Minor

Documentation references removed theme properties.

The docstrings for alignment and offset in StreamOnlineIndicatorProps still reference StreamOnlineIndicatorThemeData.alignment and StreamOnlineIndicatorThemeData.offset, but these properties have been removed from the theme data class.

📝 Suggested documentation fix
   /// The alignment of the indicator relative to [child].
   ///
   /// Only used when [child] is provided.
-  /// Falls back to [StreamOnlineIndicatorThemeData.alignment], or
-  /// [AlignmentDirectional.topEnd].
+  /// Defaults to [AlignmentDirectional.topEnd].
   final AlignmentGeometry? alignment;

   /// The offset for fine-tuning indicator position.
   ///
   /// Applied after [alignment] to adjust the indicator's final position.
-  /// Falls back to [StreamOnlineIndicatorThemeData.offset], or [Offset.zero].
+  /// Defaults to [Offset.zero].
   final Offset? offset;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/stream_core_flutter/lib/src/components/badge/stream_online_indicator.dart`
around lines 136 - 147, The docstrings for StreamOnlineIndicatorProps.alignment
and StreamOnlineIndicatorProps.offset incorrectly reference removed properties
StreamOnlineIndicatorThemeData.alignment and
StreamOnlineIndicatorThemeData.offset; update these comments to reference the
current theme fallback (remove or replace the removed property names), e.g.,
state that they fall back to the theme's values via
StreamOnlineIndicatorThemeData (or simply to the default
AlignmentDirectional.topEnd and Offset.zero) and ensure the docstrings mention
only existing API symbols such as StreamOnlineIndicatorProps.alignment,
StreamOnlineIndicatorProps.offset, and StreamOnlineIndicatorThemeData (without
the removed .alignment/.offset members).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@packages/stream_core_flutter/lib/src/components/badge/stream_online_indicator.dart`:
- Around line 136-147: The docstrings for StreamOnlineIndicatorProps.alignment
and StreamOnlineIndicatorProps.offset incorrectly reference removed properties
StreamOnlineIndicatorThemeData.alignment and
StreamOnlineIndicatorThemeData.offset; update these comments to reference the
current theme fallback (remove or replace the removed property names), e.g.,
state that they fall back to the theme's values via
StreamOnlineIndicatorThemeData (or simply to the default
AlignmentDirectional.topEnd and Offset.zero) and ensure the docstrings mention
only existing API symbols such as StreamOnlineIndicatorProps.alignment,
StreamOnlineIndicatorProps.offset, and StreamOnlineIndicatorThemeData (without
the removed .alignment/.offset members).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17ea7269-778a-4c6e-8476-f54bdb828973

📥 Commits

Reviewing files that changed from the base of the PR and between 0332dc1 and 52c925d.

📒 Files selected for processing (9)
  • apps/design_system_gallery/lib/components/badge/stream_badge_count.dart
  • apps/design_system_gallery/lib/components/badge/stream_badge_notification.dart
  • apps/design_system_gallery/lib/components/badge/stream_online_indicator.dart
  • packages/stream_core_flutter/CHANGELOG.md
  • packages/stream_core_flutter/lib/src/components/badge/stream_badge_count.dart
  • packages/stream_core_flutter/lib/src/components/badge/stream_badge_notification.dart
  • packages/stream_core_flutter/lib/src/components/badge/stream_online_indicator.dart
  • packages/stream_core_flutter/lib/src/theme/components/stream_online_indicator_theme.dart
  • packages/stream_core_flutter/lib/src/theme/components/stream_online_indicator_theme.g.theme.dart
💤 Files with no reviewable changes (1)
  • packages/stream_core_flutter/lib/src/theme/components/stream_online_indicator_theme.dart

@xsahil03x xsahil03x merged commit a05c73f into main Apr 13, 2026
9 of 10 checks passed
@xsahil03x xsahil03x deleted the feat/support-child-in-badge branch April 13, 2026 11:42
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.

2 participants