applied_staff_reviews.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. import 'dart:ui';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:domain/entity/response/job_list_remark_view_entity.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/widgets.dart';
  7. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  8. import 'package:get/get.dart';
  9. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  10. import 'package:shared/utils/util.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:cs_resources/constants/color_constants.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import 'package:widgets/shatter/rating_widget.dart';
  15. import 'package:widgets/widget_export.dart';
  16. /*
  17. * 员工的评价弹窗
  18. */
  19. class AppliedStaffReviews extends StatefulWidget {
  20. JobListRemarkViewEntity appliedReviews;
  21. void Function(String attitudeRate, String performanceRate, String experienceRate, String groomingRate, String content)? confirmAction;
  22. AppliedStaffReviews({required this.appliedReviews, this.confirmAction});
  23. @override
  24. State<AppliedStaffReviews> createState() => _AppliedStaffReviewsState();
  25. }
  26. class _AppliedStaffReviewsState extends State<AppliedStaffReviews> {
  27. late JobListRemarkViewEntity reviews;
  28. late String attitudeRate;
  29. late String groomingRate;
  30. late String performanceRate;
  31. late String experienceRate;
  32. late String content;
  33. late TextEditingController _controller;
  34. late FocusNode _focusNode;
  35. @override
  36. void initState() {
  37. super.initState();
  38. _controller = TextEditingController();
  39. _focusNode = FocusNode();
  40. reviews = widget.appliedReviews;
  41. attitudeRate = reviews.attitudeRate.toString();
  42. groomingRate = reviews.groomingRate.toString();
  43. performanceRate = reviews.performanceRate.toString();
  44. experienceRate = reviews.experienceRate.toString();
  45. _controller.text = reviews.content ?? "";
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. return Column(
  50. crossAxisAlignment: CrossAxisAlignment.center,
  51. mainAxisAlignment: MainAxisAlignment.center,
  52. children: [
  53. //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度)
  54. Container(
  55. width: double.infinity,
  56. decoration: const BoxDecoration(
  57. color: Colors.white,
  58. borderRadius: BorderRadius.all(Radius.circular(15)),
  59. ),
  60. child: Column(
  61. crossAxisAlignment: CrossAxisAlignment.start,
  62. children: [
  63. Center(
  64. child: MyTextView(
  65. "Remarks".tr,
  66. fontSize: 19,
  67. isFontMedium: true,
  68. textColor: ColorConstants.black,
  69. marginTop: 23,
  70. marginBottom: 19,
  71. marginLeft: 22,
  72. marginRight: 22,
  73. ),
  74. ),
  75. MyTextView(
  76. reviews.memberName ?? "",
  77. isFontRegular: true,
  78. textColor: Colors.black,
  79. marginLeft: 22,
  80. marginRight: 22,
  81. fontSize: 17,
  82. ),
  83. //态度评分
  84. Row(
  85. children: [
  86. MyTextView(
  87. "Attitude".tr,
  88. isFontRegular: true,
  89. textColor: ColorConstants.black66,
  90. fontSize: 15,
  91. ).expanded(),
  92. RatingWidget(
  93. nomalImage: Assets.baseServiceRatingUnselected,
  94. selectImage: Assets.baseServiceRatingSelected,
  95. size: 21,
  96. padding: 5,
  97. selectAble: Utils.isEmpty(reviews.content),
  98. integerOnly: true,
  99. value: reviews.attitudeRate,
  100. onRatingUpdate: (value) {
  101. attitudeRate = value;
  102. },
  103. )
  104. ],
  105. ).marginOnly(top: 15, left: 22, right: 22),
  106. //表现评分
  107. Row(
  108. children: [
  109. MyTextView(
  110. "Performance".tr,
  111. isFontRegular: true,
  112. textColor: ColorConstants.black66,
  113. fontSize: 15,
  114. ).expanded(),
  115. RatingWidget(
  116. nomalImage: Assets.baseServiceRatingUnselected,
  117. selectImage: Assets.baseServiceRatingSelected,
  118. size: 21,
  119. padding: 5,
  120. selectAble: Utils.isEmpty(reviews.content),
  121. integerOnly: true,
  122. value: reviews.performanceRate,
  123. onRatingUpdate: (value) {
  124. performanceRate = value;
  125. },
  126. )
  127. ],
  128. ).marginOnly(top: 15, left: 22, right: 22),
  129. //经验评分
  130. Row(
  131. children: [
  132. MyTextView(
  133. "Experience".tr,
  134. isFontRegular: true,
  135. textColor: ColorConstants.black66,
  136. fontSize: 15,
  137. ).expanded(),
  138. RatingWidget(
  139. nomalImage: Assets.baseServiceRatingUnselected,
  140. selectImage: Assets.baseServiceRatingSelected,
  141. size: 21,
  142. padding: 5,
  143. selectAble: Utils.isEmpty(reviews.content),
  144. integerOnly: true,
  145. value: reviews.experienceRate,
  146. onRatingUpdate: (value) {
  147. experienceRate = value;
  148. },
  149. )
  150. ],
  151. ).marginOnly(top: 15, left: 22, right: 22),
  152. //着装评分
  153. Row(
  154. children: [
  155. MyTextView(
  156. "Grooming".tr,
  157. isFontRegular: true,
  158. textColor: ColorConstants.black66,
  159. fontSize: 15,
  160. ).expanded(),
  161. RatingWidget(
  162. nomalImage: Assets.baseServiceRatingUnselected,
  163. selectImage: Assets.baseServiceRatingSelected,
  164. size: 21,
  165. padding: 5,
  166. selectAble: Utils.isEmpty(reviews.content),
  167. integerOnly: true,
  168. value: reviews.groomingRate,
  169. onRatingUpdate: (value) {
  170. groomingRate = value;
  171. },
  172. )
  173. ],
  174. ).marginOnly(top: 15, left: 22, right: 22),
  175. IgnoreKeyboardDismiss(
  176. child: Container(
  177. height: 130,
  178. margin: const EdgeInsets.symmetric(vertical: 19, horizontal: 22),
  179. padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
  180. decoration: BoxDecoration(
  181. color: const Color(0xFFF0F0F0),
  182. border: Border.all(
  183. color: const Color(0xFFD8D8D8),
  184. width: 0.5,
  185. ),
  186. ),
  187. child: TextField(
  188. cursorColor: ColorConstants.black66,
  189. cursorWidth: 1.5,
  190. autofocus: false,
  191. enabled: Utils.isEmpty(reviews.content),
  192. focusNode: _focusNode,
  193. controller: _controller,
  194. // 装饰
  195. decoration: InputDecoration(
  196. isDense: true,
  197. isCollapsed: true,
  198. border: InputBorder.none,
  199. hintText: "Enter...".tr,
  200. hintStyle: const TextStyle(
  201. color: ColorConstants.black66,
  202. fontSize: 15.0,
  203. fontWeight: FontWeight.w400,
  204. ),
  205. ),
  206. style: const TextStyle(
  207. color: ColorConstants.black,
  208. fontSize: 15.0,
  209. fontWeight: FontWeight.w400,
  210. ),
  211. // 键盘动作右下角图标
  212. textInputAction: TextInputAction.done,
  213. onSubmitted: (value) {
  214. doCallbackAction();
  215. },
  216. ),
  217. ),
  218. ),
  219. // 分割线
  220. Container(
  221. color: const Color(0XFFCECECE),
  222. height: 0.5,
  223. ),
  224. //按钮组
  225. Row(
  226. children: [
  227. Expanded(
  228. flex: 1,
  229. child: InkWell(
  230. onTap: () {
  231. onCancel();
  232. },
  233. child: MyTextView(
  234. "Cancel".tr,
  235. fontSize: 17.5,
  236. isFontMedium: true,
  237. textAlign: TextAlign.center,
  238. textColor: Color(0XFF0085C4),
  239. cornerRadius: 3,
  240. borderWidth: 1,
  241. ),
  242. )),
  243. Container(
  244. color: Color(0xff09141F).withOpacity(0.13),
  245. width: 0.5,
  246. ),
  247. Expanded(
  248. flex: 1,
  249. child: InkWell(
  250. onTap: () {
  251. doCallbackAction();
  252. },
  253. child: MyTextView(
  254. "Submit".tr,
  255. marginLeft: 10,
  256. fontSize: 17.5,
  257. isFontMedium: true,
  258. textAlign: TextAlign.center,
  259. textColor: Color(0XFF0085C4),
  260. cornerRadius: 3,
  261. ),
  262. )),
  263. ],
  264. ).constrained(height: 46),
  265. ],
  266. ),
  267. ),
  268. ],
  269. ).constrained(width: 285);
  270. }
  271. //取消弹框
  272. void onCancel() async {
  273. SmartDialog.dismiss();
  274. }
  275. //执行回调
  276. void doCallbackAction() {
  277. _focusNode.unfocus();
  278. content = _controller.text.toString();
  279. if (attitudeRate == "0" || experienceRate == "0" || performanceRate == "0" || groomingRate == "0") {
  280. ToastEngine.show("Rate First");
  281. return;
  282. }
  283. if (Utils.isEmpty(content)) {
  284. ToastEngine.show("Please Enter Remark".tr);
  285. return;
  286. }
  287. onCancel();
  288. widget.confirmAction?.call(attitudeRate, performanceRate, experienceRate, groomingRate, content);
  289. }
  290. }