
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:plugin_basic/base/base_state.dart';
import 'package:plugin_basic/base/base_stateful_page.dart';
import 'package:plugin_basic/utils/ext_get_nav.dart';
import 'package:router/path/router_path.dart';
import 'package:shared/utils/screen_util.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_appbar.dart';
import 'package:widgets/widget_export.dart';
import 'item_job_category.dart';
import 'job_category_controller.dart';
import 'job_category_state.dart';

/*
 * 工作下面的子模块分类列表
 */
class JobCategoryPage extends BaseStatefulPage<JobCategoryController> {
  JobCategoryPage({Key? key}) : super(key: key);

  //启动当前页面
  static void startInstance() {
    return Get.start(RouterPath.UKJobCategory);
  }

  @override
  JobCategoryController createRawController() {
    return JobCategoryController();
  }

  @override
  State<JobCategoryPage> createState() => _LabourRequestListState();
}

class _LabourRequestListState extends BaseState<JobCategoryPage, JobCategoryController> {
  late JobCategoryState state;

  @override
  void initState() {
    super.initState();
    state = controller.state;
  }

  @override
  Widget build(BuildContext context) {
    return autoCtlGetBuilder(builder: (controller) {
      return SafeArea(
        bottom: MediaQuery.of(context).padding.bottom > 38,
        top: false,
        child: Container(
          width: double.infinity,
          height: double.infinity,
          padding: EdgeInsets.only(top: ScreenUtil.getStatusBarH(context)),
          decoration: const BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Color(0xFF091D44),
                Color(0xFF245A8A),
                Color(0xFF7F7CEC),
              ],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
          ),
          child: Column(
            children: [
              MyAppBar.titleBar(context, "Jobs".tr),

              //底部的列表
              EasyRefresh(
                controller: controller.refreshController,
                onRefresh: null,
                onLoad: null,
                child: ListView.builder(
                  padding: const EdgeInsets.only(top: 8),
                  itemCount: state.datas.length,
                  itemBuilder: (_, int index) {
                    //Item布局
                    return JobCategoryItem(
                      item: state.datas[index],
                      onClickAction: () {
                        controller.gotoModulePage(state.datas[index]);
                      },
                    );
                  },
                ),
              ).expanded(),

            ],
          ),
        ),
      );
    });
  }
}
