import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:kaer_with_panels/app/modules/kr_login/views/kr_login_view.dart';
import 'package:kaer_with_panels/app/modules/kr_main/views/kr_tabbar_view.dart';
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';

import '../controllers/kr_main_controller.dart';

class KRMainView extends GetView<KRMainController> {
  const KRMainView({super.key});

  @override
  Widget build(BuildContext context) {
       final theme = Theme.of(context); // 获取当前主题
    return Scaffold(
      // 根据下标显示哪个页面
      body: GetBuilder<KRMainController>(builder: (mc) {
        return PageView(
          children: mc.widgets,
          controller: controller.pageController,
          physics: const NeverScrollableScrollPhysics(),
        );
      }),

      bottomNavigationBar: Obx(
        () => KRCustomBottomNavBar(
          backgroundColor: theme.scaffoldBackgroundColor,
          currentIndex: controller.kr_currentIndex.value,
          onTap: (i) => controller.kr_setPage(i),
          items: [
            KRCustomBottomNavBarItem(
              imageName: "tab_home_n",
              activeImageName: "tab_home_s",
            ),
            KRCustomBottomNavBarItem(
              imageName: "tab_invite_n",
              activeImageName: "tab_invite_s",
            ),
            KRCustomBottomNavBarItem(
              imageName: "tab_statistics_n",
              activeImageName: "tab_statistics_s",
            ),
            KRCustomBottomNavBarItem(
              imageName: "tab_my_n",
              activeImageName: "tab_my_s",
            ),
          ],
        ),
      ),
    );
  }
}
