import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:web_panel/routs/rout_name.dart';

import '../../controllers/MenuController.dart';
import '../../responsive.dart';

import '../dashboard/dashboard_screen.dart';
import '../device management/device.dart';
import '../ticket/ticket_screen.dart';
import 'components/side_menu.dart';


class MainScreen extends StatelessWidget {
  MainScreen({super.key, required this.routName});

  // Widget child;
  String routName;

  final SidebarController menuController = Get.find();

  final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return GetBuilder<SidebarController>(
      init: menuController,

      builder: (controller) {
        return Scaffold(
          key: scaffoldKey,
          drawer: SideMenu(),
          body: SafeArea(
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                if (Responsive.isDesktop(context)) Expanded(child: SideMenu()),
                Expanded(
                  flex: 5,
                  child: routName == RoutName.dashBoard
                      ? DashboardScreen(scaffoldKey: scaffoldKey)
                      : routName == RoutName.device
                      ? Device(scaffoldKey: scaffoldKey)
                      : TicketScreen(scaffoldKey: scaffoldKey),
                  // child,
                  // Navigator(
                  //   key: Get.nestedKey(1),
                  //   // initialRoute: RoutName.dashBoard,
                  //   onGenerateRoute: (settings) {
                  //     if (settings.name == RoutName.dashBoard) {
                  //       return GetPageRoute(page: () => DashboardScreen(scaffoldKey:  scaffoldKey,));
                  //     } else if (settings.name == RoutName.device) {
                  //       return GetPageRoute(page: () => Device(scaffoldKey:  scaffoldKey,));
                  //     } else if (settings.name == RoutName.ticket) {
                  //       return GetPageRoute(page: () => TicketScreen(scaffoldKey:  scaffoldKey,));
                  //     }
                  //     return null;
                  //   },
                  // ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
