123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- import 'dart:ui';
- import 'package:cs_resources/generated/assets.dart';
- import 'package:domain/entity/response/job_list_applied_staff_search_entity.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/widgets.dart';
- import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
- import 'package:get/get.dart';
- import 'package:widgets/ext/ex_widget.dart';
- import 'package:cs_resources/constants/color_constants.dart';
- import 'package:widgets/load_state_layout.dart';
- import 'package:widgets/my_load_image.dart';
- import 'package:widgets/my_text_view.dart';
- import 'package:widgets/search_app_bar.dart';
- import 'package:widgets/widget_export.dart';
- import 'applied_add_staff_controller.dart';
- /**
- * 添加员工的弹窗
- */
- class AppliedAddStaff extends StatefulWidget {
- String jobId;
- void Function(String selectIds)? confirmAction;
- AppliedAddStaff({required this.jobId, this.confirmAction});
- @override
- State<AppliedAddStaff> createState() => _AppliedAddStaffState();
- }
- class _AppliedAddStaffState extends State<AppliedAddStaff> {
- @override
- void initState() {
- super.initState();
- Get.put(AppliedAddStaffController());
- }
- @override
- void dispose() {
- super.dispose();
- Get.delete<AppliedAddStaffController>();
- }
- @override
- Widget build(BuildContext context) {
- return GetBuilder<AppliedAddStaffController>(
- assignId: true,
- builder: (controller) {
- return Container(
- width: 300,
- height: 555,
- decoration: BoxDecoration(
- color: Color(0XFFF7F7F7),
- borderRadius: const BorderRadius.all(Radius.circular(15)),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Center(
- child: MyTextView(
- "Choose Staff".tr,
- fontSize: 19,
- isFontMedium: true,
- textColor: ColorConstants.black,
- marginTop: 22,
- marginBottom: 15,
- marginLeft: 22,
- marginRight: 22,
- ),
- ),
- SearchAppBar(
- value: controller.keyword,
- searchBarHeight: 38,
- searchBarBgColor: Colors.white,
- searchBarBorderRadius: 15,
- searchBarBorder: Border.all(
- color: Color(0XFFC3C3C3), // 设置边框颜色为灰色
- width: 0.5, // 设置边框宽度
- ),
- textHintColor: Color(0XFFAFB3B7),
- textColor: ColorConstants.black33,
- onSearch: (keyword) {
- controller.doSearch(keyword);
- },
- hintText: "Staff Name/ID/Phone".tr,
- controller: controller.searchController,
- ).marginOnly(left: 16.5, right: 1.5, bottom: 15.5),
- Container(
- color: Colors.white,
- child: EasyRefresh(
- header: ClassicHeader(
- dragText: 'Pull to refresh'.tr,
- armedText: 'Release ready'.tr,
- readyText: 'Refreshing...'.tr,
- processingText: 'Refreshing...'.tr,
- processedText: 'Succeeded'.tr,
- noMoreText: 'No more'.tr,
- failedText: 'Failed'.tr,
- messageText: 'Last updated at %T'.tr,
- textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
- messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
- iconTheme: const IconThemeData(color: ColorConstants.black66),
- backgroundColor: Colors.transparent,
- ),
- footer: ClassicFooter(
- dragText: 'Pull to load'.tr,
- armedText: 'Release ready'.tr,
- readyText: 'Loading...'.tr,
- processingText: 'Loading...'.tr,
- processedText: 'Succeeded'.tr,
- noMoreText: 'No more'.tr,
- failedText: 'Failed'.tr,
- showMessage: false,
- triggerOffset: 50,
- iconDimension: 22,
- textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
- messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
- iconTheme: const IconThemeData(color: ColorConstants.black66),
- backgroundColor: Colors.transparent,
- ),
- controller: controller.refreshController,
- onRefresh: controller.onRefresh,
- onLoad: controller.loadMore,
- child: LoadStateLayout(
- themeColor: ColorConstants.black66,
- state: controller.loadingState,
- errorMessage: controller.errorMessage,
- errorRetry: () {
- controller.retryRequest();
- },
- successSliverWidget: [
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return _buildStaffItem(controller.datas[index], () {
- /// Item选中与未选中设置
- controller.datas[index].isSelected = !controller.datas[index].isSelected;
- controller.update();
- });
- },
- childCount: controller.datas.length,
- ))
- ],
- ),
- ),
- ).expanded(),
- //按钮组
- Row(
- children: [
- //取消按钮
- Expanded(
- flex: 1,
- child: InkWell(
- onTap: () {
- onCancel();
- },
- child: MyTextView(
- "Cancel".tr,
- fontSize: 17.5,
- isFontMedium: true,
- textAlign: TextAlign.center,
- textColor: Color(0XFF0085C4),
- cornerRadius: 3,
- borderWidth: 1,
- ),
- )),
- //垂直分割线
- Container(
- color: Color(0xff09141F).withOpacity(0.13),
- width: 0.5,
- ),
- //同意按钮
- Expanded(
- flex: 1,
- child: InkWell(
- onTap: () {
- doCallbackAction(controller);
- },
- child: MyTextView(
- "Submit".tr,
- marginLeft: 10,
- fontSize: 17.5,
- isFontMedium: true,
- textAlign: TextAlign.center,
- textColor: Color(0XFF0085C4),
- cornerRadius: 3,
- ),
- )),
- ],
- ).constrained(height: 46),
- ],
- ),
- );
- },
- );
- }
- //取消弹框
- void onCancel() async {
- SmartDialog.dismiss();
- }
- //执行回调
- void doCallbackAction(AppliedAddStaffController controller) {
- onCancel();
- //找到当前选中的
- var selectedList = controller.datas.where((element) => element.isSelected).toList(growable: false);
- if (selectedList.isNotEmpty) {
- var ids = selectedList.map((e) => e.id.toString()).toList(growable: false);
- String separatedIds = ids.join(',');
- widget.confirmAction?.call(separatedIds);
- }
- }
- Widget _buildStaffItem(JobListAppliedStaffSearchRows item, VoidCallback callback) {
- return Stack(
- children: [
- Column(
- children: [
- //姓名
- Row(
- children: [
- MyTextView(
- "Staff:",
- textColor: ColorConstants.black66,
- fontSize: 13,
- marginRight: 3,
- isFontRegular: true,
- ),
- MyTextView(
- item.name ?? "-",
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- ],
- ),
- //头像
- Row(
- children: [
- MyTextView(
- "Avatar:",
- textColor: ColorConstants.black66,
- fontSize: 13,
- marginRight: 3,
- isFontRegular: true,
- ),
- MyLoadImage(
- item.avatar ?? "",
- width: 25,
- height: 25,
- ),
- ],
- ).marginOnly(top: 5),
- //性别
- Row(
- children: [
- MyTextView(
- "Gender:",
- marginRight: 3,
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- MyTextView(
- item.sex ?? "-",
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- ],
- ).marginOnly(top: 5),
- //身份证
- Row(
- children: [
- MyTextView(
- "NRIC:",
- marginRight: 3,
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- MyTextView(
- item.nric ?? "-",
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- ],
- ).marginOnly(top: 5),
- //电话
- Row(
- children: [
- MyTextView(
- "Phone:",
- marginRight: 3,
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- MyTextView(
- item.phone ?? "-",
- textColor: ColorConstants.black66,
- fontSize: 13,
- isFontRegular: true,
- ),
- ],
- ).marginOnly(top: 5),
- Container(
- margin: EdgeInsets.only(top: 19),
- width: double.infinity,
- height: 1,
- color: Color(0XFFF7F7F7),
- )
- ],
- ).paddingOnly(left: 19, right: 20, top: 17),
- //是否勾选
- MyAssetImage(
- item.isSelected ? Assets.baseServiceItemSelectedIcon : Assets.baseServiceItemUnselectedGrayIcon,
- width: 20.5,
- height: 20.5,
- ).alignRight().marginOnly(right: 20, top: 17.5),
- ],
- ).onTap(callback);
- }
- }
|