import 'dart:ui'; import 'package:cs_resources/generated/assets.dart'; import 'package:domain/entity/response/job_list_remark_view_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:plugin_platform/engine/toast/toast_engine.dart'; import 'package:shared/utils/util.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:cs_resources/constants/color_constants.dart'; import 'package:widgets/my_text_view.dart'; import 'package:widgets/shatter/rating_widget.dart'; import 'package:widgets/widget_export.dart'; /* * 员工的评价弹窗 */ class AppliedStaffReviews extends StatefulWidget { JobListRemarkViewEntity appliedReviews; void Function(String attitudeRate, String performanceRate, String experienceRate, String groomingRate, String content)? confirmAction; AppliedStaffReviews({required this.appliedReviews, this.confirmAction}); @override State createState() => _AppliedStaffReviewsState(); } class _AppliedStaffReviewsState extends State { late JobListRemarkViewEntity reviews; late String attitudeRate; late String groomingRate; late String performanceRate; late String experienceRate; late String content; late TextEditingController _controller; late FocusNode _focusNode; @override void initState() { super.initState(); _controller = TextEditingController(); _focusNode = FocusNode(); reviews = widget.appliedReviews; attitudeRate = reviews.attitudeRate.toString(); groomingRate = reviews.groomingRate.toString(); performanceRate = reviews.performanceRate.toString(); experienceRate = reviews.experienceRate.toString(); _controller.text = reviews.content ?? ""; } @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度) Container( width: double.infinity, decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(15)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: MyTextView( "Remarks".tr, fontSize: 19, isFontMedium: true, textColor: ColorConstants.black, marginTop: 23, marginBottom: 19, marginLeft: 22, marginRight: 22, ), ), MyTextView( reviews.memberName ?? "", isFontRegular: true, textColor: Colors.black, marginLeft: 22, marginRight: 22, fontSize: 17, ), //态度评分 Row( children: [ MyTextView( "Attitude".tr, isFontRegular: true, textColor: ColorConstants.black66, fontSize: 15, ).expanded(), RatingWidget( nomalImage: Assets.baseServiceRatingUnselected, selectImage: Assets.baseServiceRatingSelected, size: 21, padding: 5, selectAble: Utils.isEmpty(reviews.content), integerOnly: true, value: reviews.attitudeRate, onRatingUpdate: (value) { attitudeRate = value; }, ) ], ).marginOnly(top: 15, left: 22, right: 22), //表现评分 Row( children: [ MyTextView( "Performance".tr, isFontRegular: true, textColor: ColorConstants.black66, fontSize: 15, ).expanded(), RatingWidget( nomalImage: Assets.baseServiceRatingUnselected, selectImage: Assets.baseServiceRatingSelected, size: 21, padding: 5, selectAble: Utils.isEmpty(reviews.content), integerOnly: true, value: reviews.performanceRate, onRatingUpdate: (value) { performanceRate = value; }, ) ], ).marginOnly(top: 15, left: 22, right: 22), //经验评分 Row( children: [ MyTextView( "Experience".tr, isFontRegular: true, textColor: ColorConstants.black66, fontSize: 15, ).expanded(), RatingWidget( nomalImage: Assets.baseServiceRatingUnselected, selectImage: Assets.baseServiceRatingSelected, size: 21, padding: 5, selectAble: Utils.isEmpty(reviews.content), integerOnly: true, value: reviews.experienceRate, onRatingUpdate: (value) { experienceRate = value; }, ) ], ).marginOnly(top: 15, left: 22, right: 22), //着装评分 Row( children: [ MyTextView( "Grooming".tr, isFontRegular: true, textColor: ColorConstants.black66, fontSize: 15, ).expanded(), RatingWidget( nomalImage: Assets.baseServiceRatingUnselected, selectImage: Assets.baseServiceRatingSelected, size: 21, padding: 5, selectAble: Utils.isEmpty(reviews.content), integerOnly: true, value: reviews.groomingRate, onRatingUpdate: (value) { groomingRate = value; }, ) ], ).marginOnly(top: 15, left: 22, right: 22), IgnoreKeyboardDismiss( child: Container( height: 130, margin: const EdgeInsets.symmetric(vertical: 19, horizontal: 22), padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15), decoration: BoxDecoration( color: const Color(0xFFF0F0F0), border: Border.all( color: const Color(0xFFD8D8D8), width: 0.5, ), ), child: TextField( cursorColor: ColorConstants.black66, cursorWidth: 1.5, autofocus: false, enabled: Utils.isEmpty(reviews.content), focusNode: _focusNode, controller: _controller, // 装饰 decoration: InputDecoration( isDense: true, isCollapsed: true, border: InputBorder.none, hintText: "Enter...".tr, hintStyle: const TextStyle( color: ColorConstants.black66, fontSize: 15.0, fontWeight: FontWeight.w400, ), ), style: const TextStyle( color: ColorConstants.black, fontSize: 15.0, fontWeight: FontWeight.w400, ), // 键盘动作右下角图标 textInputAction: TextInputAction.done, onSubmitted: (value) { doCallbackAction(); }, ), ), ), // 分割线 Container( color: const Color(0XFFCECECE), height: 0.5, ), //按钮组 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(); }, child: MyTextView( "Submit".tr, marginLeft: 10, fontSize: 17.5, isFontMedium: true, textAlign: TextAlign.center, textColor: Color(0XFF0085C4), cornerRadius: 3, ), )), ], ).constrained(height: 46), ], ), ), ], ).constrained(width: 285); } //取消弹框 void onCancel() async { SmartDialog.dismiss(); } //执行回调 void doCallbackAction() { _focusNode.unfocus(); content = _controller.text.toString(); if (attitudeRate == "0" || experienceRate == "0" || performanceRate == "0" || groomingRate == "0") { ToastEngine.show("Rate First"); return; } if (Utils.isEmpty(content)) { ToastEngine.show("Please Enter Remark".tr); return; } onCancel(); widget.confirmAction?.call(attitudeRate, performanceRate, experienceRate, groomingRate, content); } }