import 'package:flutter/material.dart';
import 'package:flutter/services.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/global_widget/my_text.dart';
import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_logic.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/question_paper_view.dart';
import 'package:making_school_asignment_app/page/home_page/home_logic.dart';

import 'components/bottom_operation_bar.dart';
import 'components/dropdown_switch_students_type.dart';
import 'components/favorite_widget.dart';
import 'configuration_files/index.dart';

class HomeworkReview extends StatelessWidget {
  const HomeworkReview({super.key});

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<HomeworkReviewLogic>();
    final sateData = logic.state;
    final AnnotateClassLogic _controller = Get.find<AnnotateClassLogic>();
    final HomeLogic _homeLogicController = Get.find<HomeLogic>();

    return PopScope(
      canPop: false,
      onPopInvoked: (e) {
        if (e && sateData.needRefresh) {
          _controller.getList();
          _homeLogicController.getList();
        }
      },
      child: SafeArea(
        child: Scaffold(
          appBar: AppBar(
            // titleSpacing: 0,
            leading: IconButton(icon: const Icon(Icons.arrow_back_ios), onPressed: () => Get.back()),
            iconTheme: const IconThemeData(color: Colors.black),
            title: quickText(sateData.param.value.homeworkName),
            backgroundColor: Colors.white,
            elevation: 0,
            actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()],
          ),
          body: Column(
            children: [
              // 下拉切换 30.h
              const DropdownSwitchStudentsType(),
              // +1
              SizedBox(height: 1.h),
              const Expanded(child: QuestionPaperView()),
              // +64.h
              const BottomAnnotationSwitch()
            ],
          ),
          // floatingActionButton: FloatingActionButton(
          //   elevation: 8,
          //   tooltip: "点击打开工具栏",
          //   backgroundColor: Colors.white,
          //   onPressed: () {},
          //   child: Icon(Icons.edit, size: 20.sp, color: Theme.of(context).primaryColor),
          // ),
          // floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
        ),
      ),
    );
  }
}
