import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:making_school_asignment_app/common/job/class_item.dart';
import 'package:making_school_asignment_app/common/mixins/request_tool_mixin.dart';
import 'package:making_school_asignment_app/routes/app_pages.dart';

import 'student_history_work_state.dart';

class StudentHistoryWorkLogic extends GetxController with RequestToolMixin {
  final StudentHistoryWorkState state = StudentHistoryWorkState();
  late final EasyRefreshController refreshController;
  String nextPage = '';
  @override
  void onInit() {
    super.onInit();
    nextPage = Get.arguments['page'] ?? '';
    EasyLoading.show(status: 'loading...');
    refreshController = EasyRefreshController();
    getList();
  }

  void getList() async {
    List<ClassItem> data = await getClient().getStudentClass();
    state.clssList.value = data;
    EasyLoading.dismiss();
    refreshController.finishRefresh();
  }

  void goNextPage(String id, String title, int subject) {
    if(nextPage == 'points'){
      Get.toNamed(Routes.knowledgePointsGraspPage, arguments: {'classId': id, 'page': nextPage, 'subject': subject});
    }else{
      Get.toNamed(Routes.classStudentPage, arguments: {'title': title, 'classId': id, 'page': nextPage, 'subject': subject});
    }

  }

  @override
  void dispose() {
    super.dispose();
    refreshController.dispose();
  }
}
