import 'package:flutter/material.dart'; import 'package:ftc_mobile_app/ftc_mobile_app.dart'; import 'package:get/get.dart'; import 'home_screen.dart'; class DashboardScreen extends StatefulWidget { const DashboardScreen({Key? key}) : super(key: key); @override State createState() => _DashboardScreenState(); } class _DashboardScreenState extends State { final controller = Get.put(DashboardScreenController()); @override Widget build(BuildContext context) { return CustomScaffold( appBar: appBar, backgroundColor: CustomAppColors.kPrimaryColor, screenKey: controller.screenKey, onScreenTap: controller.removeFocus, showAppBar: true, sideDrawer: const CustomDrawer(), body: SafeArea( child: Obx(() { if (controller.myProfileData() == null) { return FrequentFunctions.centerText(text: "No data found"); } return ClientProfileScreen(userData: controller.myProfileData()!); }), ), ); return CustomScaffold( appBar: appBar, sideDrawer: const CustomDrawer(), bottomMenu: Obx( () => BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: controller.selectedIndex.value, onTap: (value) { if (value == 0) { Navigator.pushNamed( context, CustomRouteNames.kRotaDashboardScreenRoute); return; } controller.selectedIndex.value = value; }, items: [ BottomNavigationBarItem( label: "", icon: Column( children: [ CustomImageWidget( imagePath: AssetsManager.kCalendarIcon, height: 26.h, width: 26.w, imageColor: controller.selectedIndex.value == 0 ? CustomAppColors.kSecondaryColor : null, ), CustomTextWidget( text: "Rota", isExpanded: false, fontSize: 12.sp, fontColor: controller.selectedIndex.value == 0 ? CustomAppColors.kSecondaryColor : null), ], ), ), BottomNavigationBarItem( label: "", icon: Column( children: [ CustomImageWidget( imagePath: AssetsManager.kHomeIcon, height: 26.h, width: 26.w, imageColor: controller.selectedIndex.value == 1 ? CustomAppColors.kSecondaryColor : null, ), CustomTextWidget( text: "Dashboard", isExpanded: false, fontSize: 12.sp, fontColor: controller.selectedIndex.value == 1 ? CustomAppColors.kSecondaryColor : null, ), ], ), ), BottomNavigationBarItem( label: "", icon: Column( children: [ CustomImageWidget( imagePath: AssetsManager.kMessageIcon, height: 26.h, width: 26.w, imageColor: controller.selectedIndex.value == 2 ? CustomAppColors.kSecondaryColor : null, ), CustomTextWidget( text: "Inbox", isExpanded: false, fontSize: 12.sp, fontColor: controller.selectedIndex.value == 2 ? CustomAppColors.kSecondaryColor : null, ), ], ), ), BottomNavigationBarItem( label: "", icon: Column( children: [ CustomImageWidget( imagePath: AssetsManager.kPeopleUnselectedIcon, height: 26.h, width: 26.w, imageColor: controller.selectedIndex.value == 3 ? CustomAppColors.kSecondaryColor : null, ), CustomTextWidget( text: "Clients", isExpanded: false, fontSize: 12.sp, fontColor: controller.selectedIndex.value == 3 ? CustomAppColors.kSecondaryColor : null, ), ], ), ), ], ), ), backgroundColor: CustomAppColors.kPrimaryColor, screenKey: controller.screenKey, onScreenTap: controller.removeFocus, showAppBar: true, body: SafeArea( child: Obx(() => selectedScreen()[controller.selectedIndex.value])), ); } PreferredSizeWidget get appBar => CustomAppBar( showBoxShadow: false, titleWidget: Row( children: [ InkWell( onTap: () => controller.screenKey.currentState!.openDrawer(), child: CustomImageWidget( imagePath: AssetsManager.kDrawerIcon, height: 27.h, width: 27.w, ), ), Padding( padding: EdgeInsets.only(left: 15.0.w), child: Obx(() { return CustomTextWidget( text: controller.selectedIndex.value == 0 ? 'Home' : controller.selectedIndex.value == 1 ? 'Home' : controller.selectedIndex.value == 2 ? 'Inbox' : controller.selectedIndex.value == 3 ? 'Clients' : "", isExpanded: false, fontSize: 16.sp, fontWeight: FontWeight.w700, fontColor: CustomAppColors.kDarkBlueTextColor, ); }), ), const Spacer(), Obx(() { return Visibility( visible: controller.selectedIndex.value == 0, child: CustomImageWidget( imagePath: AssetsManager.kBellIcon, height: 23.h, width: 22.w, ), ); }), ], ), ); List selectedScreen() { return [ const RotaDashboardScreen(), const HomeScreen(), const InboxScreen(), const ClientsListScreen(), ]; } @override void dispose() { controller.dispose(); super.dispose(); } }