프로젝트 최초 커밋
This commit is contained in:
124
lib/screens/sidebar/widgets/sidebar_menu_submenu.dart
Normal file
124
lib/screens/sidebar/widgets/sidebar_menu_submenu.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/sidebar/widgets/sidebar_menu_item.dart';
|
||||
import 'package:superport/screens/sidebar/widgets/sidebar_menu_types.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
|
||||
// 서브메뉴(확장/축소, 하위 아이템) 위젯
|
||||
class SidebarMenuWithSubmenu extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String route;
|
||||
final List<SidebarSubMenuItem> subItems;
|
||||
final bool isExpanded;
|
||||
final bool isMenuActive;
|
||||
final bool isSubMenuActive;
|
||||
final bool isHovered;
|
||||
final VoidCallback onToggleExpanded;
|
||||
final String currentRoute;
|
||||
final void Function(String) onRouteChanged;
|
||||
|
||||
const SidebarMenuWithSubmenu({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.route,
|
||||
required this.subItems,
|
||||
required this.isExpanded,
|
||||
required this.isMenuActive,
|
||||
required this.isSubMenuActive,
|
||||
required this.isHovered,
|
||||
required this.onToggleExpanded,
|
||||
required this.currentRoute,
|
||||
required this.onRouteChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isHighlighted = isMenuActive || isSubMenuActive;
|
||||
return Column(
|
||||
children: [
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
onTap: () {
|
||||
onToggleExpanded();
|
||||
onRouteChanged(route);
|
||||
},
|
||||
child: Container(
|
||||
height: 44,
|
||||
margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 6),
|
||||
padding: const EdgeInsets.only(left: 24, right: 24),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isMenuActive
|
||||
? Colors.white
|
||||
: (isHovered
|
||||
? const Color(0xFFE9EDF2)
|
||||
: Colors.transparent),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 18,
|
||||
color:
|
||||
isHighlighted
|
||||
? AppThemeTailwind.primary
|
||||
: AppThemeTailwind.dark,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color:
|
||||
isHighlighted
|
||||
? AppThemeTailwind.primary
|
||||
: AppThemeTailwind.dark,
|
||||
fontWeight:
|
||||
isHighlighted ? FontWeight.bold : FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(
|
||||
isExpanded
|
||||
? Icons.keyboard_arrow_up
|
||||
: Icons.keyboard_arrow_down,
|
||||
size: 20,
|
||||
color: AppThemeTailwind.muted,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: ClipRect(
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
heightFactor: isExpanded ? 1 : 0,
|
||||
child: Column(
|
||||
children:
|
||||
subItems.map((item) {
|
||||
return SidebarMenuItem(
|
||||
icon: Icons.circle,
|
||||
title: item.title,
|
||||
route: item.route,
|
||||
isActive: currentRoute == item.route,
|
||||
isHovered: false, // hover는 상위에서 관리
|
||||
isSubItem: true,
|
||||
onTap: () => onRouteChanged(item.route),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user