import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_core/core.dart';

import 'logic.dart';

class PoultryScienceRootPage extends GetView<PoultryScienceRootLogic> {
  const PoultryScienceRootPage({super.key});

  @override
  Widget build(BuildContext context) {
    return ChickenBasePage(
      isFullScreen: true,
      onPopScopTaped: controller.popBackTaped,
      child: ObxValue((data) {
        return Stack(
          children: [
            IndexedStack(children: controller.pages, index: data.value),
            Positioned(
              right: 0,
              left: 0,
              bottom: 0,
              child: RBottomNavigation(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                items: [
                  RBottomNavigationItem(
                    label: 'عملیات',
                    icon: Assets.vec.settingSvg.path,
                    isSelected: controller.currentPage.value == 0,
                    onTap: () {
                      Get.nestedKey(
                        poultrySecondKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      Get.nestedKey(
                        poultryFirstKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      controller.changePage(0);
                    },
                  ),
                  RBottomNavigationItem(
                    label: 'خانه',
                    icon: Assets.vec.homeSvg.path,
                    isSelected: controller.currentPage.value == 1,
                    onTap: () {
                      Get.nestedKey(
                        poultryFirstKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      Get.nestedKey(
                        poultryThirdKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      controller.changePage(1);
                    },
                  ),
                  RBottomNavigationItem(
                    label: 'پروفایل',
                    icon: Assets.vec.profileCircleSvg.path,
                    isSelected: controller.currentPage.value == 2,
                    onTap: () {
                      Get.nestedKey(
                        poultryFirstKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      Get.nestedKey(
                        poultrySecondKey,
                      )?.currentState?.popUntil((route) => route.isFirst);
                      controller.changePage(2);
                    },
                  ),
                ],
              ),
            ),
          ],
        );
      }, controller.currentPage),
    );
  }
}
