96 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
			
		
		
	
	
			96 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
| import 'package:flutter/material.dart';
 | |
| 
 | |
| import 'package:badges/badges.dart';
 | |
| import 'package:matrix/matrix.dart';
 | |
| 
 | |
| import 'package:extera_next/config/app_config.dart';
 | |
| import 'package:extera_next/widgets/hover_builder.dart';
 | |
| import 'package:extera_next/widgets/unread_rooms_badge.dart';
 | |
| import '../../config/themes.dart';
 | |
| 
 | |
| class NaviRailItem extends StatelessWidget {
 | |
|   final String toolTip;
 | |
|   final bool isSelected;
 | |
|   final void Function() onTap;
 | |
|   final Widget icon;
 | |
|   final Widget? selectedIcon;
 | |
|   final bool Function(Room)? unreadBadgeFilter;
 | |
| 
 | |
|   const NaviRailItem({
 | |
|     required this.toolTip,
 | |
|     required this.isSelected,
 | |
|     required this.onTap,
 | |
|     required this.icon,
 | |
|     this.selectedIcon,
 | |
|     this.unreadBadgeFilter,
 | |
|     super.key,
 | |
|   });
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     final theme = Theme.of(context);
 | |
| 
 | |
|     final borderRadius = BorderRadius.circular(AppConfig.borderRadius);
 | |
|     final icon = isSelected ? selectedIcon ?? this.icon : this.icon;
 | |
|     final unreadBadgeFilter = this.unreadBadgeFilter;
 | |
|     return HoverBuilder(
 | |
|       builder: (context, hovered) {
 | |
|         return SizedBox(
 | |
|           height: 72,
 | |
|           width: FluffyThemes.navRailWidth,
 | |
|           child: Stack(
 | |
|             children: [
 | |
|               Positioned(
 | |
|                 top: 8,
 | |
|                 bottom: 8,
 | |
|                 left: 0,
 | |
|                 child: AnimatedContainer(
 | |
|                   width: isSelected ? 8 : 0,
 | |
|                   duration: FluffyThemes.animationDuration,
 | |
|                   curve: FluffyThemes.animationCurve,
 | |
|                   decoration: BoxDecoration(
 | |
|                     color: theme.colorScheme.primary,
 | |
|                     borderRadius: const BorderRadius.only(
 | |
|                       topRight: Radius.circular(90),
 | |
|                       bottomRight: Radius.circular(90),
 | |
|                     ),
 | |
|                   ),
 | |
|                 ),
 | |
|               ),
 | |
|               Center(
 | |
|                 child: AnimatedScale(
 | |
|                   scale: hovered ? 1.1 : 1.0,
 | |
|                   duration: FluffyThemes.animationDuration,
 | |
|                   curve: FluffyThemes.animationCurve,
 | |
|                   child: Material(
 | |
|                     borderRadius: borderRadius,
 | |
|                     color: isSelected
 | |
|                         ? theme.colorScheme.primaryContainer
 | |
|                         : theme.colorScheme.surfaceContainerHigh,
 | |
|                     child: Tooltip(
 | |
|                       message: toolTip,
 | |
|                       child: InkWell(
 | |
|                         borderRadius: borderRadius,
 | |
|                         onTap: onTap,
 | |
|                         child: unreadBadgeFilter == null
 | |
|                             ? icon
 | |
|                             : UnreadRoomsBadge(
 | |
|                                 filter: unreadBadgeFilter,
 | |
|                                 badgePosition: BadgePosition.topEnd(
 | |
|                                   top: -12,
 | |
|                                   end: -8,
 | |
|                                 ),
 | |
|                                 child: icon,
 | |
|                               ),
 | |
|                       ),
 | |
|                     ),
 | |
|                   ),
 | |
|                 ),
 | |
|               ),
 | |
|             ],
 | |
|           ),
 | |
|         );
 | |
|       },
 | |
|     );
 | |
|   }
 | |
| }
 |