import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:making_school_asignment_app/common/job/homework_details.dart';
import 'package:making_school_asignment_app/common/utils/utils.dart';
import 'package:making_school_asignment_app/page/global_widget/MyEmptyWidget.dart';
import 'package:making_school_asignment_app/page/home_page/children/quick_data_check/widget/report_table.dart';
import 'package:making_school_asignment_app/page/home_page/widget/progress_bar.dart';

class KgtZgtTable extends StatefulWidget {
  final int studentCount;
  final String homeworkId;
  final List<Questions> kgReport;
  final List<Questions> zgReport;
  final String kgtOkRate;
  final String zgtOkRate;
  final String kgtCorrectRate;
  final String zgtCorrectRate;
  final int subject;

  const KgtZgtTable(
      {Key? key,
      required this.studentCount,
      required this.homeworkId,
      required this.kgReport,
      required this.zgReport,
      required this.kgtOkRate,
      required this.kgtCorrectRate,
      required this.zgtOkRate,
      required this.zgtCorrectRate,
      required this.subject})
      : super(key: key);

  @override
  State<KgtZgtTable> createState() => _KgtZgtTableState();
}

class _KgtZgtTableState extends State<KgtZgtTable> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        //客观题
        Container(
          padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 10.r),
          margin: EdgeInsets.symmetric(vertical: 10.r, horizontal: 14.r),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(6.r)),
          ),
          child: Column(
            children: [
              Text(
                '客观题',
                style: TextStyle(fontSize: 14.sp, color: const Color(0xFF5C5C5C), fontWeight: FontWeight.w600),
              ),
              SizedBox(height: 20.r),
              ProgressBar(
                color: const Color.fromRGBO(76, 199, 147, 1),
                percent: double.parse(widget.kgtCorrectRate) / 100,
                title: '作答正确率：',
                padingEdg: EdgeInsets.only(left: 5.w, right: 10.w),
                fontSize: 10.sp,
                lineHeight: 10.h,
                marginEdg: EdgeInsets.only(top: 5.h),
              ),
              ProgressBar(
                color: const Color.fromRGBO(76, 199, 147, 1),
                percent: double.parse(widget.kgtOkRate) / 100,
                title: '全班正确率：',
                padingEdg: EdgeInsets.only(left: 5.w, right: 10.w),
                fontSize: 10.sp,
                lineHeight: 10.h,
                marginEdg: EdgeInsets.only(top: 5.h),
              ),
              SizedBox(height: 10.r),
              SizedBox(
                height: widget.kgReport.length > 10 ? 300.h : widget.kgReport.length * 40.h + (Utils.isPad() == true ? 40.h : 65.h),
                child: ReportTable(
                  headList: const ['题', '作答率', '作答人数', '作答正确率', '全班正确率', '标准答案', '优先批阅概况'],
                  bodyList: widget.kgReport,
                  fixedCols: 1,
                  fixedRows: 1,
                  jobId: widget.homeworkId,
                  studentCount: widget.studentCount,
                  subject: widget.subject,
                ),
              ),
              if (widget.kgReport.isEmpty) MyEmptyWidget(imgWidth: 100.r, imgHeight: 100.r, font: 8.sp),
            ],
          ),
        ),
        //主观题
        Container(
          padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 14.r),
          margin: EdgeInsets.symmetric(vertical: 10.r, horizontal: 10.r),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(6.r)),
          ),
          child: Column(
            children: [
              Text(
                '主观题',
                style: TextStyle(fontSize: 14.sp, color: const Color(0xFF5C5C5C), fontWeight: FontWeight.w600),
              ),
              SizedBox(
                height: 20.r,
              ),
              ProgressBar(
                color: const Color.fromRGBO(76, 199, 147, 1),
                percent: double.parse(widget.zgtCorrectRate) / 100,
                title: '作答正确率：',
                padingEdg: EdgeInsets.only(left: 5.w, right: 10.w),
                fontSize: 10.sp,
                lineHeight: 10.h,
                marginEdg: EdgeInsets.only(top: 5.h),
              ),
              ProgressBar(
                color: const Color.fromRGBO(76, 199, 147, 1),
                percent: double.parse(widget.zgtOkRate) / 100,
                title: '全班正确率：',
                padingEdg: EdgeInsets.only(left: 5.w, right: 10.w),
                fontSize: 10.sp,
                lineHeight: 10.h,
                marginEdg: EdgeInsets.only(top: 5.h),
              ),
              SizedBox(
                height: 10.r,
              ),
              SizedBox(
                height: widget.zgReport.length > 10 ? 300.h : widget.zgReport.length * 40.h + (Utils.isPad() == true ? 40.h : 65.h),
                child: ReportTable(
                  headList: const ['题', '作答率', '作答人数', '作答正确率', '全班正确率', '查看原题', '优先批阅概况', '作答效率'],
                  bodyList: widget.zgReport,
                  fixedCols: 1,
                  fixedRows: 1,
                  isZG: true,
                  jobId: widget.homeworkId,
                  studentCount: widget.studentCount,
                  subject: widget.subject,
                ),
              ),
              if (widget.zgReport.isEmpty) MyEmptyWidget(imgWidth: 100.r, imgHeight: 100.r, font: 8.sp),
            ],
          ),
        ),
      ],
    );
  }
}
