import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/presentation/book_appointment/book_appointment_page.dart';
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
import 'package:hmg_patient_app_new/presentation/medical_file/medical_file_page.dart';
import 'package:hmg_patient_app_new/widgets/bottom_navigation/bottom_navigation.dart';

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

  @override
  State<LandingNavigation> createState() => _LandingNavigationState();
}

class _LandingNavigationState extends State<LandingNavigation> {
  int _currentIndex = 0;
  late AppState appState;
  final PageController _pageController = PageController();

  @override
  Widget build(BuildContext context) {
    appState = getIt.get<AppState>();
    return Scaffold(
      body: PageView(
        controller: _pageController,
        physics: const NeverScrollableScrollPhysics(),
        children: [
          const LandingPage(),
          appState.isAuthenticated ?   MedicalFilePage() :/* need add feedback page */ const LandingPage(),
          BookAppointmentPage(),
          const LandingPage(),
          appState.isAuthenticated ? /* need add news page */ LandingPage() :   const LandingPage(),
        ],
      ),
      bottomNavigationBar: BottomNavigation(
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() => _currentIndex = index);
          _pageController.animateToPage(index, duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
        },
      ),
    );
  }
}
