170 lines
6.4 KiB
Dart
170 lines
6.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:superport/utils/constants.dart';
|
|
import 'package:superport/screens/sidebar/widgets/sidebar_menu_header.dart';
|
|
import 'package:superport/screens/sidebar/widgets/sidebar_menu_footer.dart';
|
|
import 'package:superport/screens/sidebar/widgets/sidebar_menu_item.dart';
|
|
import 'package:superport/screens/sidebar/widgets/sidebar_menu_submenu.dart';
|
|
import 'package:superport/screens/sidebar/widgets/sidebar_menu_types.dart';
|
|
import 'package:superport/screens/common/theme_tailwind.dart';
|
|
import 'package:superport/screens/login/widgets/login_view.dart'; // AnimatedBoatIcon import
|
|
import 'package:wave/wave.dart';
|
|
import 'package:wave/config.dart';
|
|
|
|
// 사이드바 메뉴 메인 위젯 (조립만 담당)
|
|
class SidebarMenu extends StatefulWidget {
|
|
final String currentRoute;
|
|
final Function(String) onRouteChanged;
|
|
|
|
const SidebarMenu({
|
|
super.key,
|
|
required this.currentRoute,
|
|
required this.onRouteChanged,
|
|
});
|
|
|
|
@override
|
|
State<SidebarMenu> createState() => _SidebarMenuState();
|
|
}
|
|
|
|
class _SidebarMenuState extends State<SidebarMenu> {
|
|
// 장비 관리 메뉴 확장 상태
|
|
bool _isEquipmentMenuExpanded = false;
|
|
// hover 상태 관리
|
|
String? _hoveredRoute;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_updateExpandedState();
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(SidebarMenu oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.currentRoute != widget.currentRoute) {
|
|
_updateExpandedState();
|
|
}
|
|
}
|
|
|
|
// 현재 경로에 따라 장비 관리 메뉴 확장 상태 업데이트
|
|
void _updateExpandedState() {
|
|
final bool isEquipmentRoute =
|
|
widget.currentRoute == Routes.equipment ||
|
|
widget.currentRoute == Routes.equipmentInList ||
|
|
widget.currentRoute == Routes.equipmentOutList ||
|
|
widget.currentRoute == Routes.equipmentRentList;
|
|
setState(() {
|
|
_isEquipmentMenuExpanded = isEquipmentRoute;
|
|
});
|
|
}
|
|
|
|
// 장비 관리 메뉴 확장/축소 토글
|
|
void _toggleEquipmentMenu() {
|
|
setState(() {
|
|
_isEquipmentMenuExpanded = !_isEquipmentMenuExpanded;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// SRP 분할: 각 역할별 위젯 조립
|
|
return Container(
|
|
width: 260,
|
|
color: const Color(0xFFF4F6F8), // 연회색 배경
|
|
child: Column(
|
|
children: [
|
|
const SidebarMenuHeader(),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SidebarMenuItem(
|
|
icon: Icons.dashboard,
|
|
title: '대시보드',
|
|
route: Routes.home,
|
|
isActive: widget.currentRoute == Routes.home,
|
|
isHovered: _hoveredRoute == Routes.home,
|
|
onTap: () => widget.onRouteChanged(Routes.home),
|
|
),
|
|
const SizedBox(height: 4),
|
|
SidebarMenuWithSubmenu(
|
|
icon: Icons.inventory,
|
|
title: '장비 관리',
|
|
route: Routes.equipment,
|
|
subItems: const [
|
|
SidebarSubMenuItem(
|
|
title: '입고',
|
|
route: Routes.equipmentInList,
|
|
),
|
|
SidebarSubMenuItem(
|
|
title: '출고',
|
|
route: Routes.equipmentOutList,
|
|
),
|
|
SidebarSubMenuItem(
|
|
title: '대여',
|
|
route: Routes.equipmentRentList,
|
|
),
|
|
],
|
|
isExpanded: _isEquipmentMenuExpanded,
|
|
isMenuActive: widget.currentRoute == Routes.equipment,
|
|
isSubMenuActive: [
|
|
Routes.equipmentInList,
|
|
Routes.equipmentOutList,
|
|
Routes.equipmentRentList,
|
|
].contains(widget.currentRoute),
|
|
isHovered: _hoveredRoute == Routes.equipment,
|
|
onToggleExpanded: _toggleEquipmentMenu,
|
|
currentRoute: widget.currentRoute,
|
|
onRouteChanged: widget.onRouteChanged,
|
|
),
|
|
const SizedBox(height: 4),
|
|
SidebarMenuItem(
|
|
icon: Icons.location_on,
|
|
title: '입고지 관리',
|
|
route: Routes.warehouseLocation,
|
|
isActive: widget.currentRoute == Routes.warehouseLocation,
|
|
isHovered: _hoveredRoute == Routes.warehouseLocation,
|
|
onTap:
|
|
() => widget.onRouteChanged(Routes.warehouseLocation),
|
|
),
|
|
const SizedBox(height: 4),
|
|
SidebarMenuItem(
|
|
icon: Icons.business,
|
|
title: '회사 관리',
|
|
route: Routes.company,
|
|
isActive: widget.currentRoute == Routes.company,
|
|
isHovered: _hoveredRoute == Routes.company,
|
|
onTap: () => widget.onRouteChanged(Routes.company),
|
|
),
|
|
const SizedBox(height: 4),
|
|
SidebarMenuItem(
|
|
icon: Icons.vpn_key,
|
|
title: '유지보수 관리',
|
|
route: Routes.license,
|
|
isActive: widget.currentRoute == Routes.license,
|
|
isHovered: _hoveredRoute == Routes.license,
|
|
onTap: () => widget.onRouteChanged(Routes.license),
|
|
),
|
|
const SizedBox(height: 4),
|
|
SidebarMenuItem(
|
|
icon: Icons.category,
|
|
title: '물품 관리',
|
|
route: Routes.goods,
|
|
isActive: widget.currentRoute == Routes.goods,
|
|
isHovered: _hoveredRoute == Routes.goods,
|
|
onTap: () => widget.onRouteChanged(Routes.goods),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SidebarMenuFooter(),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|