import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';

import 'package:staff_main/src/presentation/blocs/staff_main_cubit.dart';
import 'package:staff_main/src/presentation/blocs/staff_main_state.dart';
import 'package:staff_main/src/presentation/widgets/staff_main_bottom_bar.dart';

/// The main page for the Staff app, acting as a shell for the bottom navigation.
///
/// It follows KROW Clean Architecture by:
/// - Being a [StatelessWidget].
/// - Delegating state management to [StaffMainCubit].
/// - Using [RouterOutlet] for nested navigation.
class StaffMainPage extends StatelessWidget {
  const StaffMainPage({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocProvider<StaffMainCubit>(
      create: (BuildContext context) => Modular.get<StaffMainCubit>(),
      child: Scaffold(
        extendBody: true,
        body: const RouterOutlet(),
        bottomNavigationBar: BlocBuilder<StaffMainCubit, StaffMainState>(
          builder: (BuildContext context, StaffMainState state) {
            return StaffMainBottomBar(
              currentIndex: state.currentIndex,
              onTap: (int index) {
                BlocProvider.of<StaffMainCubit>(context).navigateToTab(index);
              },
            );
          },
        ),
      ),
    );
  }
}
