import 'package:flutter/material.dart';
import '../widgets/app_background.dart';
import '../widgets/FloatingNavBar.dart';
import 'attendence_screen.dart';
import 'finance_screen.dart';
import 'holiday_screen.dart';

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    // final screenHeight = MediaQuery.sizeOf(context).height;
    return Scaffold(
      body: Stack(
        children: [
          /// BACKGROUND
          const AppBackground(child: SizedBox()),

          /// ACTIVE SCREEN (fills entire screen - content will extend behind navbar)
          ///
          Positioned.fill(
            child: IndexedStack(
              index: _currentIndex,
              children: [
                const AttendanceScreen(),
                const FinanceScreen(),
                const HolidayScreen(),
              ],
            ),
          ),

          /// FLOATING NAVBAR (positioned above content)
          Positioned(
            left: 0,
            right: 0,
            bottom: 0,
            child: Floatingnavbar(
              items: [
                NavBarItem(
                  iconPath: 'assets/images/attendance.svg',
                  label: 'الحضور',
                ),
                NavBarItem(
                  iconPath: 'assets/images/finance.svg',
                  label: 'المالية',
                ),
                NavBarItem(
                  iconPath: 'assets/images/holiday.svg',
                  label: 'الإجازة',
                ),
              ],
              selectedIndex: _currentIndex,
              onTap: (index) {
                setState(() {
                  _currentIndex = index;
                });
              },
            ),
          ),
        ],
      ),
    );
  }
}
