import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/mixins/getx_keepalive_widget.dart';
import 'package:making_school_asignment_app/page/global_widget/my_text.dart';
import 'package:making_school_asignment_app/page/home_page/children/read_over/widget/annotate_list.dart';
import 'package:making_school_asignment_app/routes/app_pages.dart';

import 'work_logic.dart';

class WorkPage extends GetxKeepAliveWidget<WorkLogic> {
  const WorkPage({super.key});

  @override
  Widget buildContent(BuildContext context, WorkLogic controller) {
    final state = controller.state;
    return Scaffold(
      backgroundColor: const Color.fromRGBO(244, 244, 244, 1),
      body: Column(
        children: <Widget>[
          Container(
            color: Colors.white,
            margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
            padding: EdgeInsets.only(bottom: 9.h, top: 4.h),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      alignment: Alignment.centerLeft,
                      padding: EdgeInsets.only(left: 10.w),
                    )),
                Expanded(
                  flex: 4,
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 2.h),
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      color: const Color.fromRGBO(243, 243, 243, 1),
                      borderRadius: BorderRadius.circular(8.r),
                    ),
                    child: TabBar(
                      padding: EdgeInsets.zero,
                      indicatorPadding: EdgeInsets.zero,
                      indicatorWeight: 0,
                      labelPadding: EdgeInsets.symmetric(horizontal: 2.w),
                      controller: controller.tabController,
                      unselectedLabelStyle: TextStyle(
                        fontSize: 14.sp,
                        color: const Color.fromRGBO(69, 83, 100, 1),
                      ),
                      labelStyle: TextStyle(
                        fontSize: 14.sp,
                        color: const Color(0xFF4CC793),
                      ),
                      // labelColor: const Color.fromRGBO(45, 56, 76, 1),
                      indicator: const BoxDecoration(),
                      onTap: (index) {
                        state.tabIndex.value = index;
                        if (index == 1 && state.completedToRefresh) {
                          // 已阅卷
                          // _refreshController2.callRefresh();
                          state.completedToRefresh = false;
                        }
                      },
                      tabs: <Widget>[
                        Tab(
                          iconMargin: EdgeInsets.zero,
                          height: 34.h,
                          child: Obx(() {
                            return Container(
                              width: 140.w,
                              alignment: Alignment.center,
                              decoration: BoxDecoration(
                                color: state.tabIndex.value == 0 ? const Color.fromRGBO(255, 255, 255, 1) : null,
                                borderRadius: BorderRadius.all(Radius.circular(8.r)),
                              ),
                              child: quickText(
                                '待批阅',
                                size: 14.sp,
                                color: state.tabIndex.value == 0
                                    ? Theme.of(context).primaryColor
                                    : const Color.fromRGBO(80, 94, 110, 1),
                                fontWeight: state.tabIndex.value == 0 ? FontWeight.bold : null,
                              ),
                            );
                          }),
                        ),
                        Tab(
                          iconMargin: EdgeInsets.zero,
                          height: 34.h,
                          child: Obx(() {
                            return Container(
                              width: 140.w,
                              alignment: Alignment.center,
                              decoration: BoxDecoration(
                                color: state.tabIndex.value == 1 ? const Color.fromRGBO(255, 255, 255, 1) : null,
                                borderRadius: BorderRadius.all(Radius.circular(8.r)),
                              ),
                              child: quickText(
                                '已批阅',
                                size: 14.sp,
                                color: state.tabIndex.value == 1
                                    ? Theme.of(context).primaryColor
                                    : const Color.fromRGBO(80, 94, 110, 1),
                                fontWeight: state.tabIndex.value == 1 ? FontWeight.bold : null,
                              ),
                            );
                          }),
                        ),
                      ],
                    ),
                  ),
                ),
                Expanded(
                  flex: 1,
                  child: InkWell(
                    onTap: () {
                      Get.toNamed(Routes.studentHistoryWorkPage, arguments: {'page': 'set'});
                    },
                    child: Icon(const IconData(0xe63e, fontFamily: "AlibabaIcon"),
                        color: const Color.fromRGBO(44, 48, 63, 1), size: 24.sp),
                  ),
                ),
              ],
            ),
          ),
          Expanded(
            child: Obx(() {
              return AnnotateList(
                tabIndex: state.tabIndex.value,
                assessType: 1,
              );
            }),
          ),
        ],
      ),
    );
  }
}
