/*
 * @Author: wangyang 1147192855@qq.com
 * @Date: 2022-07-05 16:42:44
 * @LastEditors: wangyang 1147192855@qq.com
 * @LastEditTime: 2022-09-27 16:15:03
 * @FilePath: \marking_app\lib\pages\marking\index.dart
 * @Description: 阅卷主页
 */

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:marking_app/common/mixin/common.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:marking_app/common/config/request_config.dart';
import 'package:marking_app/common/model/event_bus/job_home_refresh_bus.dart';
import 'package:marking_app/common/model/job/job_task_item.dart';
import 'package:marking_app/pages/common/event_bus_mixin.dart';
import 'package:marking_app/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart';
import 'package:marking_app/provider/review_provider.dart';
import 'package:marking_app/routes/RouterManager.dart';
import 'package:marking_app/utils/index.dart';
import 'package:marking_app/utils/my_text.dart';
import 'package:marking_app/utils/request/rest_client.dart';
import 'package:marking_app/common/model/common/base_page_data.dart';
import 'package:marking_app/common/model/marking/marking_list_params.dart';
import 'package:marking_app/utils/easy_refresh/MyEmptyWidget.dart';
import 'package:marking_app/utils/easy_refresh/mixin/refresh_data_handle.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';

part 'index.g.dart';

// 作业主页
class HomeworkCorrection extends StatefulHookConsumerWidget {
  const HomeworkCorrection({Key? key}) : super(key: key);

  @override
  _HomeworkCorrectionState createState() => _HomeworkCorrectionState();
}

class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
    with CommonMixin, EventBusMixin, TickerProviderStateMixin, RefreshDataHandle<JobTaskItem, MarkingListParams> {
  /* Tab控制器 */
  late TabController _tabController;
  late TabController _tabController2;

  int _tabIndex = 0;
  bool completedToRefresh = true;

  /* 待阅卷 */
  late final EasyRefreshController _refreshController1;
  final MarkingListParams params1 = MarkingListParams(
    isFinish: false,
    page: RequestConfig.basePage.page,
    limit: RequestConfig.basePage.limit,
    pageType: 0,
  );
  List<JobTaskItem> markingDatas1 = [];

  /* 已阅完 */
  late final EasyRefreshController _refreshController2;
  RemoveListener? _currentTaskIdListener;
  final MarkingListParams params2 = MarkingListParams(
    isFinish: true,
    page: RequestConfig.basePage.page,
    limit: RequestConfig.basePage.limit,
    pageType: 0,
  );
  List<JobTaskItem> markingDatas2 = [];

  /* 发起请求 */
  Future<List<JobTaskItem>> getData(
    EasyRefreshController controller,
    MarkingListParams params, {
    bool isReFresh = false,
  }) async {
    RestClient client = await getClient();
    BasePageData<JobTaskItem>? results = await toRefreshData(
      controller,
      api: client.getJobsByPage,
      params: params,
      isReFresh: isReFresh,
      context: context,
    );
    if (results != null) return results.items;
    return [];
  }

  @override
  void initState() {
    _tabController = TabController(
      length: 2,
      vsync: this,
    );
    _tabController2 = TabController(length: 4, vsync: this);
    _refreshController1 = EasyRefreshController();
    _refreshController2 = EasyRefreshController();

    Future.delayed(Duration.zero, () {
      //在这里处理页面
      _currentTaskIdListener = ref.watch(currentTaskIdProvider.notifier).addListener((state) {
        int? taskId = state.taskId;

        if (taskId != null && state.refresh) {
          _refreshController1.callRefresh();
          _refreshController2.callRefresh();
        }
      });
    });
    super.initState();
  }

  @override
  void dispose() {
    if (_currentTaskIdListener != null) {
      _currentTaskIdListener!();
    }
    _tabController2.dispose();
    _tabController.dispose();
    _refreshController1.dispose();
    _refreshController2.dispose();
    eventCancel();
    super.dispose();
  }

  /// 刷新方法
  Future<void> onMyRefresh(EasyRefreshController controller, MarkingListParams params, int tab) async {
    params.page = RequestConfig.basePage.page;
    List<JobTaskItem> lists = await getData(controller, params, isReFresh: true);
    try {
      tab == 1 ? (markingDatas1 = lists) : (markingDatas2 = lists);
    } catch (e) {}
    toUpState(setState, () {}, mounted);
  }

  /// 加载方法
  Future<void> onMyLoad(EasyRefreshController controller, MarkingListParams params, int tab) async {
    params.page++;
    List<JobTaskItem> lists = await getData(controller, params);
    if (lists.isNotEmpty) {
      tab == 1 ? markingDatas1.addAll(lists) : markingDatas2.addAll(lists);
      toUpState(setState, () {}, mounted);
    }
  }

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
      value: const SystemUiOverlayStyle(
        systemNavigationBarColor: Color(0xFF000000),
        systemNavigationBarDividerColor: null,
        statusBarColor: Colors.white,
        systemNavigationBarIconBrightness: Brightness.light,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.light,
      ),
      child: Scaffold(
        backgroundColor: Color.fromRGBO(244, 244, 244, 1),
        body: OrientationBuilder(
          builder: (BuildContext context, Orientation orientation) {
            return Column(
              children: <Widget>[
                Container(
                  color: Colors.white,
                  margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
                  padding: EdgeInsets.only(bottom: 9.h, top: 4.h),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Expanded(
                          flex: 1,
                          child: Container(
                            alignment: Alignment.centerLeft,
                            padding: EdgeInsets.only(left: 10.w),
                            child: InkWell(
                              onTap: () => easyThrottle('BACK_JOB_HOME', () => Navigator.of(context).pop()),
                              child: Icon(
                                Icons.arrow_back_ios_sharp,
                                size: 16.sp,
                              ),
                            ),
                          )),
                      Expanded(
                        flex: 4,
                        child: Container(
                          padding: EdgeInsets.symmetric(vertical: 2.h),
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                            color: const Color.fromRGBO(243, 243, 243, 1),
                            borderRadius: BorderRadius.circular(8.r),
                          ),
                          child: TabBar(
                            padding: EdgeInsets.zero,
                            indicatorPadding: EdgeInsets.zero,
                            indicatorWeight: 0,
                            labelPadding: EdgeInsets.symmetric(horizontal: 2.w),
                            controller: _tabController,
                            unselectedLabelStyle: TextStyle(
                              fontSize: 14.sp,
                              color: const Color.fromRGBO(69, 83, 100, 1),
                            ),
                            labelStyle: TextStyle(
                              fontSize: 14.sp,
                              color: const Color.fromRGBO(104, 136, 253, 1),
                            ),
                            // labelColor: const Color.fromRGBO(45, 56, 76, 1),
                            indicator: const BoxDecoration(),
                            onTap: (index) {
                              setState(() {
                                _tabIndex = index;
                                if (index == 1 && completedToRefresh) {
                                  // 已阅卷
                                  _refreshController2.callRefresh();
                                  completedToRefresh = false;
                                }
                              });
                            },
                            tabs: <Widget>[
                              Tab(
                                iconMargin: EdgeInsets.zero,
                                height: 34.h,
                                child: Container(
                                  width: 140.w,
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: _tabIndex == 0 ? const Color.fromRGBO(255, 255, 255, 1) : null,
                                    borderRadius: BorderRadius.all(Radius.circular(8.r)),
                                  ),
                                  child: quickText(
                                    '待批阅',
                                    size: 14.sp,
                                    color: _tabIndex == 0 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1),
                                    fontWeight: _tabIndex == 0 ? FontWeight.bold : null,
                                  ),
                                ),
                              ),
                              Tab(
                                iconMargin: EdgeInsets.zero,
                                height: 34.h,
                                child: Container(
                                  width: 140.w,
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: _tabIndex == 1 ? const Color.fromRGBO(255, 255, 255, 1) : null,
                                    borderRadius: BorderRadius.all(Radius.circular(8.r)),
                                  ),
                                  child: quickText(
                                    '已批阅',
                                    size: 14.sp,
                                    color: _tabIndex == 1 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1),
                                    fontWeight: _tabIndex == 1 ? FontWeight.bold : null,
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                      Expanded(
                        flex: 1,
                        child: InkWell(
                          onTap: () {
                            RouterManager.router.navigateTo(context, RouterManager.jobStudentGroupPath, transition: getTransition());
                          },
                          child: Icon(IconData(0xe63e, fontFamily: "AlibabaIcon"), color: Color.fromRGBO(44, 48, 63, 1), size: 24.sp),
                        ),
                      ),
                    ],
                  ),
                ),

                if (_tabIndex == 1)
                  $CompletedJobConditionFilter(
                    controller: _tabController2,
                    jobType: params2.markingType ?? 1,
                    customTime: _tabController2.index != 3 || (params2.startTime == null && params2.endTime == null)
                        ? null
                        : PickerDateRange(
                            params2.startTime == null ? null : DateTime.parse(params2.startTime!),
                            params2.endTime == null ? null : DateTime.parse(params2.endTime!),
                          ),
                    onJobTypeTap: (int jobTypeVal) {
                      params2.markingType = jobTypeVal;
                      _refreshController2.callRefresh();
                    },
                    onTimeFilter: (String? startTime, String? endTime) {
                      if (startTime == null && endTime == null && _tabController2.index == 3) {
                        _tabController2.animateTo(0);
                      }
                      params2.endTime = endTime;
                      params2.startTime = startTime;
                      _refreshController2.callRefresh();
                    },
                  ),
                Expanded(
                  child: IndexedStack(
                    index: _tabIndex,
                    children: <Widget>[
                      $EasyRefresh(
                        controller: _refreshController1,
                        params: params1,
                        tab: 1,
                        data: markingDatas1,
                        onLoad: onMyLoad,
                        onRefresh: onMyRefresh,
                        eventFire: () {
                          eventFire(model: JobHomeRefreshBus());
                        },
                      ),
                      $EasyRefresh(
                        controller: _refreshController2,
                        params: params2,
                        tab: 2,
                        data: markingDatas2,
                        onLoad: onMyLoad,
                        onRefresh: onMyRefresh,
                        eventFire: () {
                          eventFire(model: JobHomeRefreshBus());
                        },
                      ),
                    ],
                  ),
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}

/// 已阅卷
/// OnRefreshCallback? onRefresh
///
@swidget
Widget $easyRefresh({
  required EasyRefreshController controller,
  required Future<void> Function(EasyRefreshController controller, MarkingListParams params, int tab) onRefresh,
  required Future<void> Function(EasyRefreshController controller, MarkingListParams params, int tab) onLoad,
  required Function eventFire,
  required MarkingListParams params,
  required List<JobTaskItem> data,
  required int tab,
}) {
  bool completed = tab == 2; // 是否是待批阅
  bool isPadFlag = isPad();
  return EasyRefresh(
    firstRefresh: true,
    taskIndependence: true,
    enableControlFinishLoad: true,
    enableControlFinishRefresh: true,
    emptyWidget: data.isEmpty ? const MyEmptyWidget() : null,
    controller: controller,
    header: MaterialHeader(),
    footer: TaurusFooter(),
    child: completed && isPadFlag
        ? GridView(
            padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 2, //横轴三个子widget
                mainAxisSpacing: 10.h,
                crossAxisSpacing: 6.w,
                childAspectRatio: 1.81 //宽高比为1时，子widget
                ),
            children: data.map((e) => $ReviewedItem(jobTaskItem: e)).toList(),
          )
        : ListView.builder(
            padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w),
            itemBuilder: (context, index) {
              return HomeworkTasksViewItem(
                completed: completed,
                jobTaskItem: data[index],
                call: () {
                  controller.callRefresh();
                  eventFire();
                },
              );
            },
            itemCount: data.length,
          ),
    onRefresh: () => onRefresh(controller, params, tab),
    onLoad: () => onLoad(controller, params, tab),
  );
}

@swidget
Widget $reviewedItem(BuildContext context, {required JobTaskItem jobTaskItem}) {
  EdgeInsets padEdg = EdgeInsets.symmetric(horizontal: 10.w);
  return InkWell(
    onTap: () {
      String url =
          '${RouterManager.jobListParticipateInClassPath}?&jobId=${jobTaskItem.id}&genderName=${Uri.encodeComponent(jobTaskItem.genderName)}&jobName=${Uri.encodeComponent(jobTaskItem.title)}&completed=${true}';
      RouterManager.router.navigateTo(context, url, transition: getTransition());
    },
    child: Container(
      padding: EdgeInsets.only(top: 10.h),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(6.r),
        color: Colors.white,
        boxShadow: [
          BoxShadow(
            color: const Color.fromRGBO(210, 216, 241, 1),
            offset: Offset.zero, //阴影y轴偏移量
            blurRadius: 5.8, //阴影模糊程度
            spreadRadius: 0, //阴影扩散程度
          )
        ],
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          // 顶部任务名称
          Padding(
            padding: padEdg,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  width: 32.w,
                  height: 18.h,
                  alignment: Alignment.center,
                  padding: EdgeInsets.only(left: 2.w),
                  decoration: BoxDecoration(
                    color: jobTaskItem.markingTypeEnum.name == '作业' ? const Color.fromRGBO(104, 136, 253, 1) : const Color.fromRGBO(255, 175, 56, 1),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(14.r),
                      topRight: Radius.circular(3.r),
                      bottomLeft: Radius.circular(4.r),
                      bottomRight: Radius.circular(4.r),
                    ),
                  ),
                  margin: EdgeInsets.only(right: 4.w),
                  child: quickText(jobTaskItem.markingTypeEnum.name, color: Colors.white, size: 10.sp),
                ),
                Expanded(
                  child: quickText(jobTaskItem.title, size: 14.sp, color: Color.fromRGBO(70, 70, 70, 1), maxLines: 2),
                )
              ],
            ),
          ),

          Padding(
            padding: padEdg,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                quickText(
                  jobTaskItem.createTime.substring(0, 10),
                  color: Color.fromRGBO(97, 97, 97, 1),
                  size: 10.sp,
                  fontWeight: FontWeight.w500,
                ),
                quickText(' / ', color: Color.fromRGBO(76, 199, 147, 1), size: 10.sp, fontWeight: FontWeight.w500),
                quickText(
                  '参与班级：',
                  color: Color.fromRGBO(76, 199, 147, 1),
                  size: 9.sp,
                ),
                quickText(
                  '${jobTaskItem.taskCount}',
                  color: Color.fromRGBO(76, 199, 147, 1),
                  size: 10.sp,
                ),
                quickText(' / ', color: Color.fromRGBO(116, 145, 253, 1), size: 10.sp, fontWeight: FontWeight.w500),
                quickText(
                  '科目：' + jobTaskItem.subjectName,
                  color: Color.fromRGBO(116, 145, 253, 1),
                  size: 9.sp,
                ),
              ],
            ),
          ),
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 10.w),
            child: FavoriteButton(
              jobTaskItem.id,
              jobTaskItem.title,
              margin: EdgeInsets.only(top: 4.h, bottom: 6.h),
            ),
          ),
          GestureDetector(
            onTap: () => easyThrottle('go_to_homework_report', () {
              RouterManager.router.navigateTo(
                context,
                RouterManager.jobReportPagePath + '?title=${Uri.encodeComponent(jobTaskItem.title)}&id=${jobTaskItem.id}',
                transition: getTransition(),
              );
            }),
            child: Container(
              padding: EdgeInsets.symmetric(vertical: 6.h),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(bottomLeft: Radius.circular(6.r), bottomRight: Radius.circular(6.r)),
                color: Colors.white,
                boxShadow: [
                  BoxShadow(
                    color: const Color.fromRGBO(0, 0, 0, 0.15),
                    offset: Offset(0, -0.0001), //阴影y轴偏移量
                    blurRadius: 4, //阴影模糊程度
                    spreadRadius: 0, //阴影扩散程度
                  )
                ],
              ),
              child: Row(children: [
                Expanded(
                  child: Container(
                    alignment: Alignment.center,
                    child: quickText('查看报告', color: Color.fromRGBO(118, 118, 118, 1), size: 11.sp),
                  ),
                ),
              ]),
            ),
          ),
        ],
      ),
    ),
  );
}

// 筛选时间
@swidget
Widget $theTabBar({required TabController controller, ValueChanged<int>? onTap, PickerDateRange? customTime}) {
  var customTimeStr = '自定义';
  if (customTime != null) {
    customTimeStr = customTime.startDate?.toString().substring(0, 10) ?? '';
    if (customTime.endDate != null) {
      // print(customTime.startDate!.year == customTime.endDate!.year);
      if (!isPad() && customTime.startDate!.year == customTime.endDate!.year) {
        customTimeStr = customTime.startDate.toString().substring(5, 10) + '~${customTime.endDate.toString().substring(5, 10)}';
      } else {
        customTimeStr += '~${customTime.endDate?.toString().substring(0, 10)}';
      }
    }
  }
  return Container(
    alignment: Alignment.centerLeft,
    child: TabBar(
      controller: controller,
      unselectedLabelStyle: TextStyle(fontSize: 12.sp, color: const Color.fromRGBO(102, 102, 102, 1)),
      labelStyle: TextStyle(
        fontSize: 12.sp,
        fontWeight: FontWeight.bold,
        color: Color.fromRGBO(116, 145, 253, 1),
      ),
      isScrollable: true,
      labelColor: const Color.fromRGBO(45, 56, 76, 1),
      indicatorSize: TabBarIndicatorSize.label, // 设置指示器高度和标签一样高
      onTap: onTap,
      tabs: <Widget>[
        const Tab(text: '全部'),
        const Tab(text: '近一周'),
        const Tab(text: '近一月'),
        Tab(text: customTimeStr),
      ],
    ),
  );
}

/// 已完成作业条件筛选栏
@hwidget
Widget $completedJobConditionFilter(BuildContext context,
    {required TabController controller,
    required int jobType,
    PickerDateRange? customTime,
    required ValueChanged<int> onJobTypeTap,
    required Function(String? startTime, String? endTime) onTimeFilter}) {
  List<Map<String, dynamic>> jobTypes = [
    {'type': 1, 'name': '作业'},
    {'type': 2, 'name': '考试'}
  ];
  var jobTypeState = useState(0);
  var customTimeState = useState<PickerDateRange?>(null);

  useEffect(() {
    if (jobTypeState.value != jobType) jobTypeState.value = jobType;
    if (customTimeState.value != customTime) customTimeState.value = customTime;

    return () {};
  }, []);

  DateTime getWeekStartDate() {
    DateTime now = DateTime.now();
    int dayOfWeek = now.weekday; // 获取今天是周几（1代表周一，7代表周日）
    int diff = dayOfWeek - 1; // 计算今天距离周一的天数差
    if (diff < 0) {
      diff += 7; // 如果是周日，则需要加上一周的天数
    }
    return now.subtract(Duration(days: diff)); // 减去天数差，得到本周一的时间
  }

  DateTime getWeekEndDate() {
    DateTime now = DateTime.now();
    int dayOfWeek = now.weekday; // 获取今天是周几
    int diff = 7 - dayOfWeek; // 计算今天距离周日的天数差
    if (diff == 0) {
      diff = 7; // 如果是周日，则加上一周的天数
    }
    return now.add(Duration(days: diff)); // 加上天数差减一，得到本周日的时间
  }

  DateTime getMonthStartDate() {
    DateTime now = DateTime.now();
    return DateTime(now.year, now.month, 1); // 获取当前月份的第一天
  }

  DateTime getMonthEndDate() {
    DateTime now = DateTime.now();
    int nextMonth = now.month + 1;
    if (nextMonth > 12) {
      nextMonth = 1;
      now = now.add(Duration(days: 31 - now.day)); // 跨年了，所以加到当前月的最后一天
    } else {
      now = now.add(Duration(days: DateTime(now.year, nextMonth, 0).day - now.day)); // 加到下个月的第一天的前一天，即本月最后一天
    }
    return now;
  }

  return Container(
    height: 39.h,
    padding: EdgeInsets.only(left: 4.w, right: 12.w),
    decoration: BoxDecoration(
      color: Color.fromRGBO(244, 244, 244, 1),
      border: Border(bottom: BorderSide(color: Color.fromRGBO(204, 204, 204, 1), width: 1)),
    ),
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        $TheTabBar(
          controller: controller,
          customTime: customTimeState.value,
          onTap: (int val) async {
            switch (val) {
              case 0: // 全部
                onTimeFilter(null, null);
                break;
              case 1: // 近一周
                onTimeFilter(
                  getWeekStartDate().toString().substring(0, 10),
                  getWeekEndDate().toString().substring(0, 10),
                );
                break;
              case 2: // 近一个月
                onTimeFilter(
                  getMonthStartDate().toString().substring(0, 10),
                  getMonthEndDate().toString().substring(0, 10),
                );
                break;
              default: // 自定义
                // DateTimeRange? range = await showDateRangePicker(
                //   // locale: const Locale('zh', 'CN'),
                //   locale: const Locale('zh', 'CN'),
                //   context: context,
                //   confirmText: '搜索',
                //   initialEntryMode: DatePickerEntryMode.calendarOnly,
                //   currentDate: DateTime.now(),
                //   firstDate: DateTime.now().subtract(const Duration(days: 4)),
                //   lastDate: DateTime.now().add(const Duration(days: 3)),
                // );

                var dialogData = await showDialog<PickerDateRange?>(
                    context: context,
                    builder: (BuildContext context1) {
                      return Center(
                        child: Container(
                          color: Colors.white,
                          width: isPad() ? ScreenUtil().screenWidth / 2 : ScreenUtil().screenWidth / 1.3,
                          height: ScreenUtil().screenHeight / 2,
                          child: SfDateRangePicker(
                            showActionButtons: true,
                            confirmText: '确定',
                            cancelText: '取消',
                            onSubmit: (p0) {
                              print(p0);
                              Navigator.of(context1).pop(p0);
                            },
                            onCancel: () {
                              Navigator.of(context1).pop();
                            },
                            selectionMode: DateRangePickerSelectionMode.range,
                            initialSelectedRange: customTimeState.value,
                          ),
                        ),
                      );
                    });
                // startDate: 2024-03-04 18:47:00.117958, endDate: 2024-03-11 18:47:00.117986
                // if (dialogData != null && (dialogData.startDate != null || dialogData.endDate != null)) {}
                onTimeFilter(
                  dialogData?.startDate?.toString().substring(0, 10),
                  dialogData?.endDate?.toString().substring(0, 10),
                );
                customTimeState.value = dialogData;
            }
          },
        ),
        Expanded(child: SizedBox()),
        Container(
          width: 74.r,
          margin: EdgeInsets.symmetric(vertical: 5.h),
          padding: EdgeInsets.symmetric(horizontal: 10.r),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.vertical(
              top: Radius.elliptical(6, 6),
              bottom: Radius.elliptical(6, 6),
            ),
          ),
          child: DropdownButton(
            icon: Icon(Icons.expand_more_outlined),
            padding: EdgeInsets.zero,
            // value: params2.jobType ?? 1,
            value: jobType,
            style: TextStyle(color: Color.fromRGBO(89, 89, 89, 1), fontSize: 12.sp),
            underline: Container(),
            isExpanded: true,
            items: jobTypes.map((e) {
              return DropdownMenuItem(
                value: e['type'],
                child: quickText(e['name'], size: 12.sp, color: Colors.black),
              );
            }).toList(),
            onChanged: (dynamic value) {
              if (value != null) {
                jobTypeState.value = value;
                onJobTypeTap(value as int);
              }
              // jobTypeState
            },
          ),
        )
      ],
    ),
  );
}
