
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/load_state_layout.dart';
import 'package:widgets/my_appbar.dart';
import 'package:widgets/widget_export.dart';

import 'applied_er_workflow_controller.dart';
import 'applied_er_workflow_state.dart';
import 'applied_workflow_item.dart';

/*
 * 已申请的员工-状态工作流列表
 */
class AppliedErWorkflowPage extends BaseStatefulPage<AppliedErWorkflowController> {
  AppliedErWorkflowPage({Key? key}) : super(key: key);

  //启动当前页面
  static void startInstance(String? appliedId) {
    return Get.start(RouterPath.THJobAppliedStaffWorkflowER,arguments: {'appliedId': appliedId});
  }

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

  @override
  State<AppliedErWorkflowPage> createState() => _AppliedWorkflowState();

}

class _AppliedWorkflowState extends BaseState<AppliedErWorkflowPage, AppliedErWorkflowController> {

  late AppliedErWorkflowState state;

  @override
  void initState() {
    super.initState();
    state = controller.state;
    state.appliedId = Get.arguments['appliedId'];
  }

  @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, "Workflow".tr),

                EasyRefresh(
                  controller: controller.refreshController,
                  onRefresh: controller.onRefresh,
                  child: LoadStateLayout(
                    state: controller.loadingState,
                    errorMessage: controller.errorMessage,
                    errorRetry: () {
                      controller.retryRequest();
                    },
                    successSliverWidget: [
                      SliverList(
                          delegate: SliverChildBuilderDelegate((context, index) {
                              return AppliedWorkFlowItem(index: index,item: state.datas[index]);
                            },
                            childCount: state.datas.length,
                          ))
                    ],
                  ),
                ).marginOnly(top: 5,bottom: 5).expanded(),
              ],
            ).marginOnly(top: 10),
          ),
        );
    });
  }
}


