import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage.dart';
import 'package:making_school_asignment_app/page/home_page/widget/student_group_list.dart';

import 'student_history_work_logic.dart';

class StudentHistoryWorkPage extends StatefulWidget {
  const StudentHistoryWorkPage({Key? key}) : super(key: key);

  @override
  State<StudentHistoryWorkPage> createState() => _StudentHistoryWorkPageState();
}

class _StudentHistoryWorkPageState extends State<StudentHistoryWorkPage> {
  final logic = Get.find<StudentHistoryWorkLogic>();
  final state = Get.find<StudentHistoryWorkLogic>().state;

  @override
  Widget build(BuildContext context) {
    return OrientationBuilder(
        builder: (BuildContext context, Orientation orientation){
          return Scaffold(
            backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
            appBar: AppBar(
              backgroundColor: Colors.white,
              title: Text(
                '我的班级 ',
                style: TextStyle(fontSize: 14.sp, color: const Color(0xFF333333)),
              ),
              centerTitle: true,
              leading: IconButton(
                icon: const Icon(Icons.arrow_back_ios, color: Colors.black),
                onPressed: () => Get.back(),
              ),
              actions: const [
                ReturnToHomepage(),
              ],
            ),
            body: Padding(
              padding: EdgeInsets.only(top: 15.r, left: 14.r, right: 14.r),
              child: EasyRefresh(
                firstRefresh: false,
                taskIndependence: true,
                controller: logic.refreshController,
                header: MaterialHeader(),
                footer: TaurusFooter(),
                onRefresh: () async {
                  logic.getList();
                },
                child: StudentGroupList(state.clssList, logic.goNextPage),
              ),
            ),
          );
        });

  }

  @override
  void dispose() {
    Get.delete<StudentHistoryWorkLogic>();
    super.dispose();
  }
}
