Skip to content
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

feat: menubar #273

Merged
merged 27 commits into from
Mar 2, 2025
Merged

feat: menubar #273

merged 27 commits into from
Mar 2, 2025

Conversation

nank1ro
Copy link
Owner

@nank1ro nank1ro commented Jan 28, 2025

closes #235

Summary by CodeRabbit

  • New Features

    • Introduced a new menubar component with dedicated routing and documentation.
    • Added dynamic index management for improved UI flow.
    • Enhanced ShadContextMenu with new tap event callbacks.
  • Refactor

    • Replaced divider components with enhanced separator variants.
    • Updated theming to incorporate menubar and separator styling.
  • Documentation

    • Revised component progress lists, examples, and formatting.
    • Updated documentation to reflect the transition from "Divider" to "Separator".
  • Tests

    • Updated tests to align with the new separator naming conventions.
  • Chores

    • Bumped the package version to 0.22.0.

@nank1ro nank1ro changed the title chore: menubar boilerplate feat: menubar Jan 28, 2025
@nank1ro nank1ro self-assigned this Jan 28, 2025
@nank1ro nank1ro added the feature New feature or request label Jan 28, 2025
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2025

Deploying shadcn-ui-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7bc6795
Status: ✅  Deploy successful!
Preview URL: https://7cff7542.flutter-shadcn-ui.pages.dev
Branch Preview URL: https://feat-menubar.flutter-shadcn-ui.pages.dev

View logs

Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The pull request updates the library to version 0.22.0. A new component, ShadMenubar, is introduced while the existing ShadDivider and ShadDividerTheme are deprecated in favor of ShadSeparator and ShadSeparatorTheme. Documentation, examples, tests, and theme configurations have been updated to reflect these changes. Import and export statements have been adjusted accordingly, and several formatting improvements have been applied to Markdown files. Additional event callbacks have been added to ShadContextMenu to enhance tap handling.

Changes

File(s) Change Summary
CHANGELOG.md, README.md Version bump to 0.22.0, addition of ShadMenubar, deprecation of ShadDivider in favor of ShadSeparator, and updates to the component progress list.
docs/src/content/docs/Components/{alert, avatar, badge, radio-group, sheet, slider, switch, tooltip}.md Formatting adjustments: updated import styles, newline placements, and code block spacing without functional changes.
docs/src/content/docs/Components/{menubar.mdx, separator.mdx} New documentation for the Menubar component; renaming of "Divider" to "Separator" in descriptions and code examples.
example/lib/{main.dart, pages/*, menubar.dart} Updated routes and widget references: replaced ShadDivider with ShadSeparator, added new MenubarPage, and fixed route mappings.
lib/shadcn_ui.dart, lib/src/app.dart Export and theme configuration updates: removed divider exports; added separator and menubar exports; updated theme references from dividerTheme to separatorTheme.
lib/src/components/{accordion.dart, context_menu.dart, resizable.dart, select.dart, divider.dart, menubar.dart, separator.dart} Replaced ShadDivider with ShadSeparator throughout; introduced new tap event callbacks in ShadContextMenu; added new menubar component implementations; removed old divider implementation.
lib/src/theme/{components/separator.dart, components/menubar.dart, data.dart, theme.dart, themes/*} Renamed ShadDividerTheme to ShadSeparatorTheme; added ShadMenubarTheme; updated merging, interpolation, and equality methods in theme classes.
lib/src/utils/provider_index.dart New provider index added: ShadProviderIndex and ShadIndexProvider for passing index values through widget context.
playground/lib/{pages/context_menu.dart, divider.dart, menubar.dart, router.dart} Updated playground examples: replaced divider with separator components; added new menubar route and example pages; updated route path from /divider to /separator.
test/src/components/separator_test.dart Renamed tests from ShadDivider to ShadSeparator with corresponding changes to variable names and golden file references.
pubspec.yaml Updated package version from 0.21.0 to 0.22.0.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MenubarPage
    participant ShadMenubar
    participant ShadMenubarController
    User->>MenubarPage: Request menubar screen
    MenubarPage->>ShadMenubar: Build menubar widget
    ShadMenubar->>ShadMenubarController: Initialize controller
    ShadMenubarController->>ShadMenubar: Manage focus & selection
    ShadMenubar->>User: Render interactive menubar items
Loading
sequenceDiagram
    participant User
    participant ShadContextMenu
    participant TapRegion
    User->>ShadContextMenu: Tap interaction (inside/outside)
    ShadContextMenu->>TapRegion: Detect tap location
    TapRegion-->>ShadContextMenu: Return tap event details
    ShadContextMenu->>User: Trigger corresponding onTap callback
Loading

Possibly related PRs

  • feat: add`ShadDivider #303: Introduced the original ShadDivider component, directly preceding the current changes that deprecate it in favor of the new ShadSeparator.

Poem

I’m a rabbit in code’s woodland glen,
Hopping ‘round changes with a happy pen.
Menubars now shine and separators gleam,
Old dividers retire like a fading dream.
With every commit, my heart skips a beat,
Coding carrots 🥕 make my journey complete!
Hop on, dear coder, to this fresh new feat!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 29ba62b and fb96fda.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • example/lib/pages/menubar.dart (1 hunks)
  • lib/src/components/menubar.dart (1 hunks)
  • lib/src/theme/components/menubar.dart (1 hunks)
🔇 Additional comments (15)
CHANGELOG.md (1)

3-5: LGTM! Clear changelog entries for the new release.

The changelog entries accurately document the addition of the ShadMenubar component, the deprecation of ShadDivider/ShadDividerTheme in favor of ShadSeparator/ShadSeparatorTheme, and the new tap event handlers for ShadContextMenu. The entries follow the established format and provide useful information to users about the changes in this version.

example/lib/pages/menubar.dart (4)

7-12: LGTM! Well-structured widget declaration.

The MenubarPage is properly implemented as a StatefulWidget with a clean separation of concerns between the widget and its state class.


14-16: LGTM! Simple state management.

The state class appropriately manages the selectOnHover property to control the menubar's behavior.


19-38: LGTM! Good theme usage and UI element construction.

The code properly retrieves the theme using ShadTheme.of(context) and creates reusable UI elements (square and divider) that will be used in the menubar items.


39-131: LGTM! Comprehensive example of menubar usage.

This example demonstrates various aspects of the menubar component including:

  • Basic menubar structure with multiple menu items
  • Context menu items with enabled/disabled states
  • Separators between groups of items
  • Nested context menus
  • Various item decorations (with icons, inset items)

The example provides a good showcase of the component's capabilities.

lib/src/theme/components/menubar.dart (5)

13-54: LGTM! Well-designed theme class with comprehensive customization options.

The ShadMenubarTheme class is properly marked as @immutable and provides numerous customization options for the menubar appearance. The constructor has clear parameter names with default values for optional parameters.


56-168: LGTM! Well-documented theme properties.

Each property is documented with appropriate macro references that will be expanded in the generated documentation. The properties cover all aspects of menubar styling including borders, colors, spacing, and button behaviors.


169-256: LGTM! Proper implementation of lerp method.

The lerp method correctly handles interpolation between two theme instances, which is essential for smooth animations when themes change. The implementation properly handles different types of properties (primitives, objects, lists) with appropriate lerp functions.


258-394: LGTM! Comprehensive copyWith and mergeWith methods.

The copyWith and mergeWith methods are well-implemented, following Flutter's standard patterns for these utility methods. The mergeWith method appropriately checks for null and respects the merge property.


396-481: LGTM! Proper implementation of equality and hashCode.

The equality operator and hashCode method are correctly implemented, considering all properties of the class. This ensures that theme instances can be properly compared and used in collections.

lib/src/components/menubar.dart (5)

23-57: LGTM! Well-implemented controller class.

The ShadMenubarController properly:

  • Manages the selected index with appropriate notifications
  • Handles focus node creation and management
  • Cleans up resources in the dispose method

This follows good practices for Flutter controller classes.


59-110: LGTM! Clean menubar widget implementation.

The ShadMenubar class is well-defined with:

  • Clear documentation for the widget and its properties
  • Appropriate property types
  • Good default values where applicable
  • Effective organization of parameters in the constructor

112-170: LGTM! Good state management in the menubar widget.

The _ShadMenubarState implementation:

  • Properly initializes and disposes of the controller
  • Correctly applies theming from the theme context
  • Uses ShadProvider to share state with descendants
  • Properly renders the menubar UI with appropriate styling

172-434: LGTM! Comprehensive menubar item implementation.

The ShadMenubarItem widget provides:

  • Extensive customization options for appearance and behavior
  • Good documentation for all properties
  • Appropriate default values and theming integration
  • Support for various interaction types (tap, long press, hover)

436-596: LGTM! Effective state management in menubar item.

The _ShadMenubarItemState implementation:

  • Properly handles the popover controller lifecycle
  • Correctly integrates with the parent menubar's controller
  • Effectively manages selection and focus states
  • Properly applies theming from the theme context
  • Handles various user interactions appropriately

The state properly updates the UI based on selection, hover, and focus changes.


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

cloudflare-workers-and-pages bot commented Feb 26, 2025

Deploying shadcn-ui-playground with  Cloudflare Pages  Cloudflare Pages

Latest commit: f5404a7
Status: ✅  Deploy successful!
Preview URL: https://51a35158.shadcn-ui-playground.pages.dev
Branch Preview URL: https://feat-menubar.shadcn-ui-playground.pages.dev

View logs

@nank1ro nank1ro marked this pull request as ready for review March 2, 2025 11:39
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

🔭 Outside diff range comments (1)
example/lib/pages/divider.dart (1)

22-24: 💡 Verification agent

🧩 Analysis chain

Filename needs to be updated to match component name

While the component has been properly updated from ShadDivider to ShadSeparator, the file is still named divider.dart. According to the AI summary, the class name has also been updated from DividerPage to SeparatorPage, but this change isn't visible in the provided code.

Consider renaming this file to separator.dart and updating all relevant class names and references for consistency.


🏁 Script executed:

#!/bin/bash
# Check if the class name was updated elsewhere
rg -A 5 "class SeparatorPage" --glob "*.dart"
# Check for any remaining references to DividerPage
rg -A 5 "DividerPage" --glob "*.dart"

Length of output: 1516


Rename file and update class references for consistency

  • The file example/lib/pages/divider.dart still contains class DividerPage and associated state classes instead of the updated SeparatorPage shown in the playground file.
  • Additionally, references (e.g., in example/lib/main.dart where '/divider': (_) => const DividerPage(),) need to be updated to reflect the renamed component.
  • Please rename the file to separator.dart, update the class names from DividerPage to SeparatorPage, and adjust any references accordingly.
🧹 Nitpick comments (9)
docs/src/content/docs/Components/menubar.mdx (1)

1-124: Well-structured menubar documentation with clear examples

The documentation for the Menubar component is comprehensive and well-structured, with a clear description and an illustrative example that demonstrates how to implement a menubar with various menu items, hierarchical submenus, and visual separators.

Consider enhancing the documentation with:

  1. A section on keyboard accessibility for desktop applications
  2. Information about menu item customization options
  3. An interactive example showing state management with the menubar
playground/lib/pages/menubar.dart (1)

22-127: Comprehensive Menubar example with good organization

The MenubarExample class demonstrates a complete implementation of the menubar component with:

  1. Well-organized menu structure with logical item grouping
  2. Proper usage of theme for consistent styling
  3. Appropriate use of enabled/disabled states
  4. Visual separators between menu sections
  5. Nested menu items with chevron indicators

The code follows best practices for Flutter widget composition and demonstrates all the capabilities of the menubar component.

Consider adding example handlers for menu item selection to demonstrate how to respond to user interactions.

lib/src/components/separator.dart (2)

5-6: Consider removing or elaborating the deprecation timeline.

The typedef ShadDivider is clearly marked as deprecated. If it's only intended as a short-term alias, consider fully removing it at a future version or adding a removal timeline for clarity.


92-116: Plan ahead for potential new variants or fallback.

Using a switch expression for handling separator variants is excellent for type safety. If you anticipate adding more variants in the future, ensure each variant is handled or consider a fallback to avoid future runtime errors.

lib/src/theme/components/menubar.dart (1)

165-251: Refine the interpolation logic for smoother transitions.

In the lerp method, properties like effects swap abruptly at mid-values (t < 0.5 ? a.effects : b.effects). This can produce visible snapping or jumps. Consider a more granular interpolation if smoother transitions are desired.

lib/src/theme/themes/default_theme_variant.dart (1)

937-948: Menubar theme looks consistent but can be expanded.

Providing a minimal menubar setup is a good start. In the future, consider allowing custom shadows, icons, or text styles to further extend styling flexibility.

test/src/components/divider_test.dart (2)

10-23: Rename variable for consistency with Separator theme.

Currently, the variable name is still shadDividerTheme while the assigned type is ShadSeparatorTheme. Consider renaming it to avoid confusion and better convey its purpose:

-        const shadDividerTheme = ShadSeparatorTheme(
+        const shadSeparatorTheme = ShadSeparatorTheme(
           thickness: 12,
           horizontalMargin: EdgeInsets.symmetric(vertical: 100),
           color: Color(0xFFF44336),
         );

-            separatorTheme: shadDividerTheme,
+            separatorTheme: shadSeparatorTheme,

123-133: Rename variable for consistency with Separator theme.

Similar to the previous block, rename shadDividerTheme to match ShadSeparatorTheme:

-        const shadDividerTheme = ShadSeparatorTheme(
+        const shadSeparatorTheme = ShadSeparatorTheme(
           thickness: 12,
           verticalMargin: EdgeInsets.symmetric(horizontal: 100),
           color: Color(0xFFF44336),
         );

-            separatorTheme: shadDividerTheme,
+            separatorTheme: shadSeparatorTheme,
lib/src/components/menubar.dart (1)

166-586: Consider refactoring the extensive menubar item constructor.

The constructor includes a large number of parameters, potentially overwhelming to maintain. A specialized builder or data class can improve readability and maintainability:

  • Group related parameters or move them to a dedicated data/model object.
  • Consider a builder pattern to reduce parameter overload.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c67404d and 7bc6795.

📒 Files selected for processing (43)
  • CHANGELOG.md (1 hunks)
  • README.md (2 hunks)
  • docs/src/content/docs/Components/alert.mdx (2 hunks)
  • docs/src/content/docs/Components/avatar.mdx (1 hunks)
  • docs/src/content/docs/Components/badge.mdx (1 hunks)
  • docs/src/content/docs/Components/menubar.mdx (1 hunks)
  • docs/src/content/docs/Components/radio-group.mdx (3 hunks)
  • docs/src/content/docs/Components/separator.mdx (2 hunks)
  • docs/src/content/docs/Components/sheet.mdx (3 hunks)
  • docs/src/content/docs/Components/slider.mdx (1 hunks)
  • docs/src/content/docs/Components/switch.mdx (2 hunks)
  • docs/src/content/docs/Components/tooltip.mdx (2 hunks)
  • example/lib/main.dart (2 hunks)
  • example/lib/pages/calendar.dart (2 hunks)
  • example/lib/pages/context_menu.dart (1 hunks)
  • example/lib/pages/date_picker.dart (2 hunks)
  • example/lib/pages/date_picker_form_field.dart (1 hunks)
  • example/lib/pages/divider.dart (2 hunks)
  • example/lib/pages/menubar.dart (1 hunks)
  • example/lib/pages/typography.dart (1 hunks)
  • lib/shadcn_ui.dart (4 hunks)
  • lib/src/app.dart (1 hunks)
  • lib/src/components/accordion.dart (2 hunks)
  • lib/src/components/context_menu.dart (3 hunks)
  • lib/src/components/divider.dart (0 hunks)
  • lib/src/components/menubar.dart (1 hunks)
  • lib/src/components/resizable.dart (3 hunks)
  • lib/src/components/select.dart (2 hunks)
  • lib/src/components/separator.dart (1 hunks)
  • lib/src/theme/components/menubar.dart (1 hunks)
  • lib/src/theme/components/separator.dart (5 hunks)
  • lib/src/theme/data.dart (9 hunks)
  • lib/src/theme/theme.dart (1 hunks)
  • lib/src/theme/themes/base.dart (4 hunks)
  • lib/src/theme/themes/default_theme_no_secondary_border_variant.dart (2 hunks)
  • lib/src/theme/themes/default_theme_variant.dart (2 hunks)
  • lib/src/utils/provider_index.dart (1 hunks)
  • playground/lib/pages/context_menu.dart (1 hunks)
  • playground/lib/pages/divider.dart (2 hunks)
  • playground/lib/pages/menubar.dart (1 hunks)
  • playground/lib/router.dart (2 hunks)
  • pubspec.yaml (1 hunks)
  • test/src/components/divider_test.dart (9 hunks)
💤 Files with no reviewable changes (1)
  • lib/src/components/divider.dart
✅ Files skipped from review due to trivial changes (15)
  • docs/src/content/docs/Components/switch.mdx
  • docs/src/content/docs/Components/avatar.mdx
  • docs/src/content/docs/Components/radio-group.mdx
  • docs/src/content/docs/Components/alert.mdx
  • pubspec.yaml
  • docs/src/content/docs/Components/tooltip.mdx
  • example/lib/pages/date_picker_form_field.dart
  • docs/src/content/docs/Components/separator.mdx
  • example/lib/pages/calendar.dart
  • lib/src/components/select.dart
  • example/lib/pages/date_picker.dart
  • docs/src/content/docs/Components/badge.mdx
  • docs/src/content/docs/Components/slider.mdx
  • lib/src/components/resizable.dart
  • docs/src/content/docs/Components/sheet.mdx
🔇 Additional comments (63)
example/lib/pages/typography.dart (1)

106-106: Component renamed from ShadDivider to ShadSeparator

The change from ShadDivider.horizontal() to ShadSeparator.horizontal() aligns with the refactoring mentioned in the CHANGELOG where ShadDivider is deprecated in favor of ShadSeparator.

example/lib/pages/divider.dart (2)

55-59: Component renamed from ShadDivider to ShadSeparator

The horizontal divider has been properly updated to use the new ShadSeparator component.


66-70: Component renamed from ShadDivider to ShadSeparator

The vertical divider has been properly updated to use the new ShadSeparator component.

lib/src/theme/theme.dart (1)

14-27: Improved error handling for ShadTheme.of

The addition of proper error handling for the case when no ShadTheme is found is a valuable improvement. The error message is detailed and helpful, explaining possible causes and solutions to the developer.

Before this change, a null reference exception would occur without a clear explanation of what went wrong.

CHANGELOG.md (1)

1-4: Clear CHANGELOG entries for version 0.22.0

The CHANGELOG entries clearly describe the two main changes in this version:

  1. Adding the new ShadMenubar component
  2. Deprecating ShadDivider and ShadDividerTheme in favor of ShadSeparator and ShadSeparatorTheme

This aligns well with the changes observed in the code.

example/lib/main.dart (2)

21-21: Added import for new MenubarPage component.

The import for the MenubarPage component has been properly added to support the new menubar feature.


69-70: Route mappings correctly implemented.

Two important route changes:

  1. The /input-form-field route has been properly restored
  2. The new /menubar route has been correctly mapped to MenubarPage

Both changes follow the established routing pattern in the application.

playground/lib/pages/context_menu.dart (1)

10-10: Component update: ShadDivider → ShadSeparator

The horizontal divider has been updated from ShadDivider.horizontal to ShadSeparator.horizontal, which aligns with the library-wide component rename as mentioned in the AI summary.

example/lib/pages/menubar.dart (2)

1-119: Well-structured new Menubar component implementation.

The new MenubarPage implementation is well organized and follows the design patterns established in the library. The component:

  1. Properly uses the theme system for visual consistency
  2. Creates reusable UI elements (square and divider)
  3. Implements a complex menubar structure with nested items
  4. Uses appropriate components like ShadMenubarItem and ShadContextMenuItem

The implementation includes good examples of different menu item states (enabled/disabled) and proper hierarchy.


26-29: Consistent use of ShadSeparator.

The implementation correctly uses the new ShadSeparator component for dividers, maintaining consistency with the library-wide component rename.

README.md (2)

48-48: Updated README to mark Menubar as completed.

The Menubar component has been marked as completed and includes the correct documentation link.


57-57: Updated component name from Divider to Separator.

The component has been correctly renamed from "Divider" to "Separator" in the README, ensuring documentation consistency with the code changes.

lib/src/app.dart (1)

689-690: Updated divider theme references to use the new separator theme.

The code now uses separatorTheme instead of dividerTheme for configuring the DividerThemeData, aligning with the library's transition from divider to separator components.

example/lib/pages/context_menu.dart (1)

11-11: Updated to use ShadSeparator instead of ShadDivider.

Properly migrated from the deprecated ShadDivider to the new ShadSeparator component while maintaining the same functionality.

lib/src/utils/provider_index.dart (2)

4-14: Well-documented index provider class.

The ShadProviderIndex class is clearly documented and properly implemented as an immutable class to hold index values, which will be used by the new menubar component.


15-37: Clean implementation of the index provider widget.

The ShadIndexProvider implementation follows good practices with:

  • Clear documentation explaining usage
  • Proper parameter requirements
  • Efficient implementation of the notifyUpdate callback to only rebuild when the index changes

This will provide solid infrastructure for the menubar component.

playground/lib/pages/divider.dart (3)

5-6: Renamed DividerPage to SeparatorPage.

Successfully migrated the class name to align with the new component naming convention.


11-11: Updated variant type to ShadSeparatorVariant.

Property type correctly changed from ShadDividerVariant to ShadSeparatorVariant.


20-20: Updated component references to use ShadSeparator.

Consistently updated all component references from ShadDivider to ShadSeparator while maintaining the same functionality and properties.

Also applies to: 25-25

playground/lib/router.dart (3)

18-18: Correctly imported the menubar page

The import for the menubar page has been properly added to the router file, which is necessary for the new menubar route.


286-292: Correctly renamed divider to separator

The route has been appropriately updated from /divider to /separator, and the corresponding builder now returns a SeparatorPage with ShadSeparatorVariant. This change aligns with the transition from dividers to separators throughout the codebase.


294-299: Properly implemented the menubar route

The route for the menubar has been correctly added, returning the MenubarPage component. The implementation is simple and follows the pattern of other routes in the file.

playground/lib/pages/menubar.dart (1)

5-20: Well-structured MenubarPage implementation

The MenubarPage class is well-implemented, providing appropriate padding and alignment for the menubar example. The use of the Scaffold widget and proper alignment ensures good visual presentation.

lib/src/components/accordion.dart (2)

5-5: Updated import for the separator component

The import has been correctly updated to use the new separator component instead of the deprecated divider component.


283-283: Replaced divider with separator in the accordion implementation

The implementation now correctly uses ShadSeparator.horizontal() instead of the deprecated ShadDivider.horizontal(), maintaining consistent behavior while adhering to the new component naming.

lib/src/components/separator.dart (1)

16-32: Constructors are clearly defined and easy to use.

Your approach of having separate named constructors (vertical, horizontal, and raw) for different orientations improves readability and flexibility. Great job!

lib/src/theme/components/menubar.dart (2)

13-14: Immutability is appropriately declared.

Marking the theme class with @immutable is a best practice to ensure a consistent and reliable theming approach.


345-386: Merge logic is clear and consistent.

The mergeWith method handles theme layering well by respecting the merge flag. This is a solid approach for combining theming instructions.

lib/src/theme/themes/default_theme_variant.dart (3)

24-24: New import for menubar theme looks good.

This aligns with the introduction of the new menubar component.


31-31: Importing separator theme aligns with the updated naming convention.

Replacing dividers with separators is consistent throughout the library.


950-958: Separator theme defaults are well-chosen.

Using a thickness of 1 pixel and the border color strikes a suitable balance. This should fit seamlessly with most app designs.

test/src/components/divider_test.dart (2)

62-66: Looks good moving from Divider to Separator.

These changes correctly replace old references to ShadDivider with ShadSeparator. No issues found.

Also applies to: 100-106, 115-115


136-136: Updated references to ShadSeparator appear correct.

These lines appropriately use ShadSeparator.vertical(), reflecting the rename without issues.

Also applies to: 178-178, 223-223, 232-232

lib/shadcn_ui.dart (1)

18-18: Exports updated to reflect Separator and Menubar components.

All newly added export statements align with the renaming from “Divider” to “Separator” and the introduction of the Menubar. No issues found.

Also applies to: 46-46, 84-84, 102-102

lib/src/components/menubar.dart (2)

20-57: Menubar controller implementation looks solid.

The addition of _focusNodes and the cleanup in dispose() appear to be well-managed. Good job ensuring external controllers aren’t disposed.


59-165: Flexible menubar design.

Providing a fallback controller and customizable styling parameters (radius, padding, border, etc.) is well thought out. code is coherent; no issues found.

lib/src/theme/themes/default_theme_no_secondary_border_variant.dart (4)

24-24: Added necessary import for the new menubar component.

The import statement for the menubar component has been correctly added, which is required for the new menubarTheme method.


31-31: Added separator component import to replace divider.

The import statement for the separator component has been correctly added to replace the deprecated divider component.


970-982: Added menubar theme implementation.

The menubarTheme method implementation looks good, providing all necessary styling properties for the new menubar component, including radius, padding, border styling, anchor positioning, and button-related properties.


984-992: Added separator theme implementation to replace divider theme.

The separatorTheme method correctly implements the styling for the separator component that replaces the deprecated divider. The implementation includes all necessary properties: thickness, color, and margins.

lib/src/components/context_menu.dart (3)

202-205: Added new callback properties for enhanced interactivity.

These new callback properties provide more granular control over tap events in the context menu, which will improve interactive behaviors.


265-323: Well-documented new properties with clear usage guidelines.

Excellent documentation for each new tap event callback. The documentation clearly explains each callback's purpose, the events that trigger them, and references to related callbacks for a complete understanding.


399-402: Implemented the new callback properties in the TapRegion widget.

The implementation correctly passes all four new callback properties to the TapRegion widget, enabling the enhanced interaction handling.

lib/src/theme/themes/base.dart (5)

17-17: Added import for the new menubar component.

The menubar component import has been correctly added to the base theme file.


24-24: Replaced divider import with separator import.

The separator component import has been correctly added to replace the deprecated divider component.


89-90: Updated constructor parameters to include new theme components.

The ShadBaseTheme constructor has been properly updated to include the new menubarTheme and separatorTheme parameters, replacing the previous dividerTheme.


142-143: Added final fields for the new theme components.

The ShadBaseTheme class now correctly includes final fields for menubarTheme and separatorTheme.


190-191: Added abstract methods for the new theme components.

The ShadThemeVariant abstract class has been updated with new abstract methods for menubarTheme and separatorTheme, ensuring all theme variants implement these methods.

lib/src/theme/components/separator.dart (6)

5-6: Properly deprecated the old divider theme.

Good use of the @deprecated annotation with a clear migration message directing users to use ShadSeparatorTheme instead. This maintains backward compatibility while guiding users toward the new API.


8-12: Updated class documentation and renamed class.

The class documentation has been updated to reference the new ShadSeparator widget, and the class has been renamed from ShadDividerTheme to ShadSeparatorTheme for consistency.


40-51: Updated mergeWith method signature and implementation.

The mergeWith method has been correctly updated to work with ShadSeparatorTheme instead of ShadDividerTheme.


53-69: Updated copyWith method signature and implementation.

The copyWith method has been properly updated to return ShadSeparatorTheme instead of ShadDividerTheme.


71-87: Updated static lerp method signature and implementation.

The static lerp method has been correctly updated to use ShadSeparatorTheme parameters and return type.


91-99: Updated equality operator implementation.

The equality operator has been updated to correctly check for ShadSeparatorTheme type instead of ShadDividerTheme.

lib/src/theme/data.dart (9)

19-19: Appropriate import added for new menubar component.

The import for the menubar theme component aligns with the PR objective to implement a menubar feature.


26-26: Consistent transition from divider to separator.

This import supports the refactoring from divider to separator components as mentioned in the AI summary.


95-96: Constructor parameters properly added for new themes.

The constructor signature has been correctly updated to include both the new menubar theme and the separator theme (replacing the old divider theme).


239-241: Theme initialization follows established pattern.

The initialization of the new theme properties correctly follows the established pattern of getting default values from the effective variant and merging them with user-provided values.


295-296: Internal constructor properly updated.

The internal constructor has been correctly updated to pass the new required theme parameters to the superclass.


399-401: Lerp method implementation is complete.

The static lerp method correctly handles interpolation for the new theme properties, maintaining consistency with the existing codebase pattern.


459-460: Equality operator updated appropriately.

The equality operator has been correctly extended to include the new theme properties in comparisons.


514-515: Hash code implementation is consistent.

The hashCode getter has been properly updated to include the new theme properties, maintaining consistency with the equality operator implementation.


568-569: CopyWith method completely updated.

The copyWith method has been thoroughly updated to include the new theme properties, both in the parameter list and in the implementation.

Also applies to: 626-627

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 (1)
example/lib/pages/separator.dart (1)

71-71: Consider updating text label for consistency.

While all component references have been updated, this text label still uses "divider" instead of "separator".

- Text('divider', style: theme.textTheme.h4),
+ Text('separator', style: theme.textTheme.h4),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc6795 and 93888f9.

📒 Files selected for processing (2)
  • example/lib/main.dart (2 hunks)
  • example/lib/pages/separator.dart (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • example/lib/main.dart
🔇 Additional comments (5)
example/lib/pages/separator.dart (5)

7-8: Class naming properly updated.

The class has been appropriately renamed from DividerPage to SeparatorPage, along with its state creation method. This change aligns with the component renaming from ShadDivider to ShadSeparator.

Also applies to: 11-11


14-14: State class name properly updated.

The state class has been correctly renamed from _DividerPageState to _SeparatorPageState to match the widget class name change.


23-23: App bar title updated to match component name.

The app bar title has been updated from 'Divider' to 'Separator' to maintain consistency with the component name change.


55-59: Component reference properly updated.

The horizontal divider widget has been updated from ShadDivider.horizontal to ShadSeparator.horizontal, reflecting the component renaming.


66-70: Component reference properly updated.

The vertical divider widget has been updated from ShadDivider.vertical to ShadSeparator.vertical, reflecting the component renaming.

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

🧹 Nitpick comments (1)
test/src/components/separator_test.dart (1)

10-10: Variable naming inconsistency.

There appears to be an inconsistency in variable naming. Here it's shaSeparatorTheme (missing the 'd') while in line 123 it's shadSeparatorTheme (with 'd'). Consider standardizing to use the same prefix.

-const shaSeparatorTheme = ShadSeparatorTheme(
+const shadSeparatorTheme = ShadSeparatorTheme(
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 93888f9 and 8851ab9.

📒 Files selected for processing (1)
  • test/src/components/separator_test.dart (9 hunks)
🔇 Additional comments (2)
test/src/components/separator_test.dart (2)

7-7: Rename from ShadDivider to ShadSeparator is properly applied.

The code correctly implements the renaming from ShadDivider to ShadSeparator throughout the test file, including all horizontal separator tests. The golden test file path has also been updated to match the new component name.

Also applies to: 10-10, 20-20, 23-23, 62-62, 106-106, 115-116


123-123: Rename from ShadDivider to ShadSeparator is properly applied for vertical separator.

The code correctly implements the renaming from ShadDivider to ShadSeparator for the vertical separator tests. The theme, component usage, and golden file path have all been updated consistently.

Also applies to: 133-133, 136-136, 177-177, 223-223, 232-234

@nank1ro nank1ro merged commit 5fc4b04 into main Mar 2, 2025
2 checks passed
@nank1ro nank1ro deleted the feat/menubar branch March 2, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Menubar
1 participant