sidebarx icon indicating copy to clipboard operation
sidebarx copied to clipboard

hoverIconTheme property not working

Open eugustavorosa opened this issue 1 year ago • 3 comments

Describe the bug When I set an IconThemeData to the property hoverIconTheme it does not work and it renders the selectedIconTheme instead. The other hover properties work normally (hoverColor and hoverTextStyle).

To Reproduce Code for my example:

import 'package:ceu/gabriel_ceu.dart';
import 'package:flutter/material.dart';
import 'package:sidebarx/sidebarx.dart';

class CeuSideBar extends StatelessWidget {
  final List<SidebarXItem> items;

  const CeuSideBar({
    required this.items,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

  return SidebarX(
    controller: SidebarXController(selectedIndex: 0, extended: true),
    footerItems: const [
      SidebarXItem(
        icon: Icons.logout,
        label: 'Sair',
      )
    ],
    theme: SidebarXTheme(
      decoration: BoxDecoration(color: theme.colorScheme.surface),
      hoverColor: theme.colorScheme.onPrimaryContainer.withOpacity(0.12),
      selectedTextStyle: theme.textTheme.bodyLarge?.copyWith(
        color: theme.colorScheme.onPrimaryContainer,
      ),
      hoverTextStyle: theme.textTheme.bodyLarge,
      textStyle: theme.textTheme.bodyLarge,
      hoverIconTheme:
          IconThemeData(color: theme.colorScheme.onSurface, size: 24),
      iconTheme: IconThemeData(color: theme.colorScheme.onSurface, size: 24),
      selectedIconTheme: IconThemeData(
          color: theme.colorScheme.onPrimaryContainer, size: 24),
      itemDecoration: BoxDecoration(
        borderRadius: CeuRadius.extraSmallRadius4,
        border: Border.all(color: theme.colorScheme.surface),
      ),
      selectedItemDecoration: BoxDecoration(
        borderRadius: CeuRadius.extraSmallRadius4,
        color: theme.colorScheme.primaryContainer,
      ),
      itemTextPadding: const EdgeInsets.only(left: 10),
      selectedItemTextPadding: const EdgeInsets.only(left: 10),
      itemMargin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
      selectedItemMargin:
          const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
    ),
    extendedTheme: const SidebarXTheme(
      width: 360,
      itemMargin: EdgeInsets.only(left: 24, right: 59, top: 4, bottom: 4),
      selectedItemMargin:
          EdgeInsets.only(left: 24, right: 59, top: 4, bottom: 4),
    ),
    headerBuilder: (context, extended) {
      return extended
          ? Container(
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.only(left: 24),
              height: 100,
              child: Image.asset(
                'assets/images/gabriel_logotype.png',
                package: 'ceu',
              ),
            )
          : SizedBox(
              height: 100,
              child: Image.asset(
                'assets/images/gabriel_logomark.png',
                package: 'ceu',
              ),
            );
    },
    items: items,
  );
 }
}

eugustavorosa avatar May 14 '24 18:05 eugustavorosa

In the source code this line is not correct:

      hoverIconTheme: selectedIconTheme ??
          theme.iconTheme.copyWith(color: theme.primaryColor),

I think should be hoverIconTheme instead selectedIconTheme

Thanks

Paroca72 avatar Jun 13 '24 07:06 Paroca72

+1. Please help to check it, thanks!

starlitya avatar Jun 18 '24 06:06 starlitya

Hi 👋!

Had the same issue.... Try to use selectedIconTheme instead of selectedHoverColor.

theRightHooprod avatar Sep 04 '24 02:09 theRightHooprod