import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';

@RoutePage()
class DefaultLayoutView extends StatefulWidget {
  const DefaultLayoutView({super.key});

  @override
  State<DefaultLayoutView> createState() => _DefaultLayoutViewState();
}

class _DefaultLayoutViewState extends State<DefaultLayoutView> {
  @override
  Widget build(BuildContext context) {
    return AutoTabsScaffold(
      routes: const [HomeRoute(), ServiceIndexRoute(), ReportIndexRoute(), ProfileRoute()],
      transitionBuilder: (context, child, animation) => child,
      bottomNavigationBuilder: (context, tabsRouter) {
        return Container(
          decoration: const BoxDecoration(
            color: Colors.white,
            border: Border(
              top: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
            ),
          ),
          child: BottomNavigationBar(
            currentIndex: tabsRouter.activeIndex,
            onTap: tabsRouter.setActiveIndex,
            elevation: 0,
            backgroundColor: Colors.white,
            selectedItemColor: const Color(0xFF4995EA),
            unselectedItemColor: const Color(0xFF666666),
            type: BottomNavigationBarType.fixed,
            selectedFontSize: 24.sp,
            unselectedFontSize: 24.sp,
            items: [
              BottomNavigationBarItem(
                icon: Image.asset(
                  'lib/assets/tab/tab1.png',
                  width: 48.w,
                  height: 48.h,
                ),
                activeIcon: Image.asset(
                  'lib/assets/tab/tab1_active.png',
                  width: 48.w,
                  height: 48.h,
                ),
                label: "告警",
              ),
              BottomNavigationBarItem(
                icon: Image.asset(
                  'lib/assets/tab/tab2.png',
                  width: 48.w,
                  height: 48.h,
                ),
                activeIcon: Image.asset(
                  'lib/assets/tab/tab2_active.png',
                  width: 48.w,
                  height: 48.h,
                ),
                label: "管理",
              ),
              BottomNavigationBarItem(
                icon: Image.asset(
                  'lib/assets/tab/tab3.png',
                  width: 48.w,
                  height: 48.h,
                ),
                activeIcon: Image.asset(
                  'lib/assets/tab/tab3_active.png',
                  width: 48.w,
                  height: 48.h,
                ),
                label: "能耗",
              ),
              BottomNavigationBarItem(
                icon: Image.asset(
                  'lib/assets/tab/tab4.png',
                  width: 48.w,
                  height: 48.h,
                ),
                activeIcon: Image.asset(
                  'lib/assets/tab/tab4_active.png',
                  width: 48.w,
                  height: 48.h,
                ),
                label: "我的",
              ),
            ],
          ),
        );
      },
    );
  }
}
