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';

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

  const KgtZgtTable(
      {Key? key,
      required this.studentCount,
      required this.homeworkId,
      required this.kgReport,
      required this.zgReport,
      required this.kgtOkRate,
      required this.zgtOkRate})
      : 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: [
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text(
                    '客观题',
                    style: TextStyle(fontSize: 14.sp, color: Color(0xFF5C5C5C), fontWeight: FontWeight.w600),
                  ),
                  SizedBox(
                    width: 10.r,
                  ),
                  Text(
                    '${widget.kgtOkRate}%',
                    style: TextStyle(fontSize: 14.sp, color: Color(0xFF6888FD), fontWeight: FontWeight.w600),
                  ),
                ],
              ),
              SizedBox(
                height: 6.r,
              ),
              SizedBox(
                height: widget.kgReport.length > 10 ? 300.r : widget.kgReport.length * 40.r + (Utils.isPad() == true ? 40.r : 65.r),
                child: ReportTable(
                  headList: const ['题', '作答率', '作答人数', '正确率', '标准答案', '优先批阅概况'],
                  bodyList: widget.kgReport,
                  fixedCols: 1,
                  fixedRows: 1,
                  jobId: widget.homeworkId,
                  studentCount: widget.studentCount,
                ),
              ),
              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: [
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text(
                    '主观题',
                    style: TextStyle(fontSize: 14.sp, color: const Color(0xFF5C5C5C), fontWeight: FontWeight.w600),
                  ),
                  SizedBox(
                    width: 6.r,
                  ),
                  Text(
                    '${widget.zgtOkRate}%',
                    style: TextStyle(fontSize: 14.sp, color: const Color(0xFF6888FD), fontWeight: FontWeight.w600),
                  ),
                ],
              ),
              SizedBox(
                height: 10.r,
              ),
              SizedBox(
                height: widget.zgReport.length > 10 ? 300.r : widget.zgReport.length * 40.r + (Utils.isPad() == true ? 40.r : 65.r),
                child: ReportTable(
                  headList: const ['题', '作答率', '作答人数', '正确率', '查看原题', '优先批阅概况'],
                  bodyList: widget.zgReport,
                  fixedCols: 1,
                  fixedRows: 1,
                  isKG: true,
                  jobId: widget.homeworkId,
                  studentCount: widget.studentCount,
                ),
              ),
              if (widget.zgReport.isEmpty) MyEmptyWidget(imgWidth: 100.r, imgHeight: 100.r, font: 8.sp),
            ],
          ),
        ),
      ],
    );
  }
}
