FloweryComponentSidebar

Overview

FloweryComponentSidebar is a high-performance, navigational sidebar designed for the Gallery and complex app layouts. It features collapsible categories, clickable items with selection persistence, live search filtering, and deep integration with the project's global sizing and localization systems.

Key Features:

Key Properties & Events

Member Description
Categories (ObservableCollection) The source data. Add categories containing list of items.
SelectedItem (SidebarItem?) Highlighted item. Selected state uses DaisyPrimaryBrush variant.
SidebarWidth (double) The width of the sidebar. Default ~254.
AutoSizeSidebarWidth (bool) If true, sidebar width scales automatically with the global DaisySize.
SearchText (string) Live filtering query. Syncs automatically with the internal search input.
Size (DaisySize) The manual sizing override. Typically synced with the global scale.
ItemSelected (event) Fired when an item is clicked. Includes the item and its parent category.
FavoriteToggled (event) Fired when an item's favorite/star icon is toggled.

Data Models

The sidebar uses a hierarchy of model classes that support localizable display names via FloweryLocalization:

- SidebarLanguageSelectorItem: Renders a localized language dropdown.

- SidebarThemeSelectorItem: Renders a themed color/theme dropdown.

- SidebarSizeSelectorItem: Renders the DaisyUI global size selector.

Localizable Strings

SidebarCategory.DisplayName and SidebarItem.DisplayName automatically resolve via FloweryLocalization.GetString(Name). Setting Name="Actions" will display "Actions" in English or "Aktionen" in German if the translation exists.

Usage Example

XAML Configuration

<controls:FloweryComponentSidebar 
    x:Name="Sidebar"
    AutoSizeSidebarWidth="True"
    ItemSelected="OnSidebarItemSelected" />

Populating Data (C#)

var general = new SidebarCategory { Name = "General", IconKey = "DaisyIconHome" };
general.Items.Add(new SidebarItem { Id = "welcome", Name = "Welcome", TabHeader = "Home" });
general.Items.Add(new SidebarItem { Id = "settings", Name = "Settings", TabHeader = "Home", ShowFavoriteIcon = true });

// Add a special selector item
general.Items.Add(new SidebarSizeSelectorItem { Id = "size_picker", Name = "Global Size" });

Sidebar.Categories = new ObservableCollection<SidebarCategory> { general };

Internal Sizing Metrics

The sidebar uses a sophisticated internal metrics system (SidebarMetrics) to ensure a balanced look across all 5 standard sizes (ExtraSmall to ExtraLarge).

Selection States

Selected items are visually distinct, using the project's Primary color palette:

State Management

The sidebar automatically persists its state via StateStorageProvider:

1. Selection: Re-selects the last item on app restart.

2. Expansion: Remembers which categories were collapsed or expanded.

3. Scroll Position: Attempts to scroll the selected item into view on load if it's deep in a long list.

Tips for AI Agents