import 'package:flutter/material.dart';
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
import 'package:get/get.dart';


import '../../../../core/constants/translation_keys.dart';
import '../../../../res/app_colors.dart';
import '../../../../routes/app_pages.dart';
import '../../controllers/dashboard_screen_controller.dart';
import 'drawer_data.dart';
import 'main_dash_board.dart';

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key});

  final DashboardScreenController dashBoardController = Get.put(DashboardScreenController());
  final MenuController menuController = Get.put(MenuController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
        centerTitle: true,
        elevation: 0.0,
        title: Text(
          TranslationKeys.makeTranslation(TranslationKeys.textOverView),
          style: Theme.of(context).textTheme.displaySmall!.copyWith(
                color: AppColors.colorSecondary,
                fontSize: 23,
                fontFamily: "Poppins",
                fontWeight: FontWeight.w500,
              ),
        ),
        leading: Obx(() {
          return Center(
            child: Container(
              color: Colors.transparent,
              child: Material(
                color: Colors.transparent,
                child: Container(
                  decoration: BoxDecoration(borderRadius: BorderRadius.circular(50), color: Colors.transparent),
                  width: 40.0,
                  height: 40.0,
                  child: InkWell(
                      borderRadius: const BorderRadius.all(Radius.circular(50)),
                      splashColor: Colors.transparent,
                      onTap: () {
                        dashBoardController.toggleDrawer();
                      },
                      child: Icon(
                        dashBoardController.isDrawerOpen.value ? Icons.close : Icons.menu,
                        color: AppColors.colorSecondary,
                      )),
                ),
              ),
            ),
          );
        }),
        actions: [
          Center(
            child: Container(
              color: Colors.transparent,
              child: Material(
                color: Colors.transparent,
                child: Container(
                  decoration: BoxDecoration(borderRadius: BorderRadius.circular(50), color: Colors.transparent),
                  width: 40.0,
                  height: 40.0,
                  child: InkWell(
                      borderRadius: const BorderRadius.all(Radius.circular(50)),
                      splashColor: Colors.transparent,
                      onTap: () {
                        dashBoardController.fetchDepositAccounts();
                        dashBoardController.fetchExchangeRates();
                      },
                      child: const Icon(
                        Icons.refresh_outlined,
                        color: AppColors.colorSecondary,
                      )),
                ),
              ),
            ),
          ),
          Center(
            child: Container(
              color: Colors.transparent,
              child: Material(
                color: Colors.transparent,
                child: Container(
                  decoration: BoxDecoration(borderRadius: BorderRadius.circular(50), color: Colors.transparent),
                  width: 40.0,
                  height: 40.0,
                  child: InkWell(
                      borderRadius: const BorderRadius.all(Radius.circular(50)),
                      splashColor: Colors.transparent,
                      onTap: () {
                        Get.toNamed(Routes.NOTIFICATIONS);
                      },
                      child: const Icon(
                        Icons.notifications_none_outlined,
                        color: AppColors.colorSecondary,
                      )),
                ),
              ),
            ),
          ),
          const SizedBox(width: 10)
        ],
      ),
      body: ZoomDrawer(
        controller: dashBoardController.zoomController,
        menuScreen:  DrawerData(),
        mainScreen: DashBoardWithAllAccounts(),
        openCurve: Curves.fastOutSlowIn,
        showShadow: false,
        slideWidth: MediaQuery.of(context).size.width * 0.7,
        isRtl: Directionality.of(context) == TextDirection.rtl,
        mainScreenTapClose: false,
        mainScreenOverlayColor: Colors.transparent,
        borderRadius: 10,
        angle: 0.0,
        menuScreenWidth: double.infinity,
        moveMenuScreen: true,
        style: DrawerStyle.defaultStyle,
        //drawerShadowsBackgroundColor: Colors.yellow,
        mainScreenAbsorbPointer: false,
        boxShadow: [
          BoxShadow(
            color: Colors.grey.withOpacity(0.5),
            spreadRadius: 10,
            blurRadius: 4,
            offset: const Offset(3, 3), // changes position of shadow
          ),
        ],
      ),
    );
  }
}
