import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/job/homework_details.dart';
import 'package:making_school_asignment_app/page/global_widget/my_text.dart';
import 'package:making_school_asignment_app/routes/app_pages.dart';

class ShowStudentList extends StatelessWidget {
  final String title;
  final String homeworkId;
  final List<dynamic> studentList;
  final int subject;
  const ShowStudentList({Key? key, required this.title, required this.studentList, required this.homeworkId,required this.subject}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      backgroundColor: Colors.white,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(20.r)),
      ),
      content: Container(
        width: Get.width * 0.8,
        height: Get.height * 0.7,
        padding: EdgeInsets.symmetric(horizontal: 2.w),
        child: Column(
          children: [
            Container(
              margin: EdgeInsets.only(top: 14.h),
              child: quickText(
                title,
                size: 18.sp,
                fontWeight: FontWeight.bold,
                color: const Color.fromRGBO(60, 60, 60, 1),
              ),
            ),
            Expanded(
              child: ListView(
                padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 4.w),
                children: [
                  Wrap(
                    spacing: 6.r, // 主轴(水平)方向间距
                    runSpacing: 4.r, // 纵轴（垂直）方向间距
                    alignment: WrapAlignment.spaceAround, //沿主轴方向居中
                    children: studentList.map((e) {
                      return InkWell(
                        onTap: () {
                          Get.toNamed(Routes.studentPersonalPage, arguments: {'studentId': e.studentId, 'homeworkId': homeworkId,'subject':subject});
                        },
                        child: Container(
                          padding: EdgeInsets.symmetric(vertical: 4.r, horizontal: 8.r),
                          decoration: BoxDecoration(
                            color: e.state == 3 ? Color(0xFF4CC793) : Color(0xFFF0ECFF),
                            borderRadius: BorderRadius.circular(4.r),
                          ),
                          child: quickText(e.studentName, color: e.state == 3 ? Colors.white : Color(0xFF505E6E), size: 10.sp),
                        ),
                      );
                    }).toList(),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
