applied_butch_modify.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. import 'dart:typed_data';
  2. import 'dart:ui';
  3. import 'package:cs_resources/generated/assets.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/date_time_utils.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:cs_resources/constants/color_constants.dart';
  13. import 'package:widgets/my_load_image.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import 'package:widgets/picker/date_picker_util.dart';
  16. import 'package:widgets/shatter/form_require_text.dart';
  17. import 'package:widgets/widget_export.dart';
  18. /**
  19. * 批量操作修改时间的弹窗
  20. */
  21. class AppliedButchModify extends StatefulWidget {
  22. DateTime? selectedStartDate;
  23. DateTime? selectedEndDate;
  24. void Function(DateTime startTime, DateTime endTime)? confirmAction;
  25. AppliedButchModify({this.selectedStartDate, this.selectedEndDate, this.confirmAction});
  26. @override
  27. State<AppliedButchModify> createState() => _AppliedButchModifyState();
  28. }
  29. class _AppliedButchModifyState extends State<AppliedButchModify> {
  30. DateTime? selectedStartDate;
  31. DateTime? selectedEndDate;
  32. @override
  33. void initState() {
  34. super.initState();
  35. selectedStartDate = widget.selectedStartDate;
  36. selectedEndDate = widget.selectedEndDate;
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. return Column(
  41. crossAxisAlignment: CrossAxisAlignment.center,
  42. mainAxisAlignment: MainAxisAlignment.center,
  43. children: [
  44. //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度)
  45. Container(
  46. padding: EdgeInsets.symmetric(horizontal: 16.5),
  47. width: double.infinity,
  48. decoration: BoxDecoration(
  49. color: Colors.white,
  50. borderRadius: const BorderRadius.all(Radius.circular(15)),
  51. ),
  52. child: Column(
  53. crossAxisAlignment: CrossAxisAlignment.start,
  54. children: [
  55. Center(
  56. child: MyTextView(
  57. "Batch Modify".tr,
  58. fontSize: 19,
  59. isFontMedium: true,
  60. textColor: ColorConstants.black,
  61. marginTop: 22,
  62. marginBottom: 20,
  63. ),
  64. ),
  65. FormRequireText(
  66. fontSize: 14,
  67. textColor: ColorConstants.black33,
  68. fontWeight: FontWeight.w400,
  69. text: "Job Start Time".tr,
  70. ),
  71. //选择时间
  72. Container(
  73. padding: EdgeInsets.only(left: 16, right: 10),
  74. margin: EdgeInsets.only(top: 10),
  75. height: 45,
  76. decoration: BoxDecoration(
  77. color: ColorConstants.grayECECEC,
  78. borderRadius: const BorderRadius.all(Radius.circular(5)),
  79. ),
  80. child: Row(
  81. mainAxisSize: MainAxisSize.max,
  82. crossAxisAlignment: CrossAxisAlignment.center,
  83. mainAxisAlignment: MainAxisAlignment.start,
  84. children: [
  85. MyTextView(
  86. selectedStartDate == null ? "" : DateTimeUtils.formatDate(selectedStartDate),
  87. fontSize: 14,
  88. hint: "Choose Start Date".tr,
  89. textHintColor: ColorConstants.textBlackHint,
  90. isFontMedium: true,
  91. textColor: ColorConstants.black33,
  92. ).expanded(),
  93. MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
  94. ],
  95. ),
  96. ).onTap(() {
  97. pickerStartDate();
  98. }),
  99. //结束日期
  100. FormRequireText(
  101. fontSize: 14,
  102. textColor: ColorConstants.black33,
  103. fontWeight: FontWeight.w400,
  104. text: "Job End Time".tr,
  105. ).marginOnly(top: 11),
  106. //选择结束日期
  107. Container(
  108. padding: EdgeInsets.only(left: 16, right: 10),
  109. margin: EdgeInsets.only(top: 10),
  110. height: 45,
  111. decoration: BoxDecoration(
  112. color: ColorConstants.grayECECEC,
  113. borderRadius: const BorderRadius.all(Radius.circular(5)),
  114. ),
  115. child: Row(
  116. mainAxisSize: MainAxisSize.max,
  117. crossAxisAlignment: CrossAxisAlignment.center,
  118. mainAxisAlignment: MainAxisAlignment.start,
  119. children: [
  120. MyTextView(
  121. selectedEndDate == null ? "" : DateTimeUtils.formatDate(selectedEndDate),
  122. fontSize: 14,
  123. hint: "Choose End Date".tr,
  124. textHintColor: ColorConstants.textBlackHint,
  125. isFontMedium: true,
  126. textColor: ColorConstants.black33,
  127. ).expanded(),
  128. MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
  129. ],
  130. ),
  131. ).onTap(() {
  132. pickerEndDate();
  133. }),
  134. Container(
  135. margin: EdgeInsets.only(top: 25),
  136. color: Color(0XFFCECECE),
  137. height: 0.5,
  138. ),
  139. Row(
  140. children: [
  141. Expanded(
  142. flex: 1,
  143. child: InkWell(
  144. onTap: () {
  145. onCancel();
  146. },
  147. child: MyTextView(
  148. "Cancel".tr,
  149. fontSize: 17.5,
  150. isFontMedium: true,
  151. textAlign: TextAlign.center,
  152. textColor: Color(0XFF0085C4),
  153. cornerRadius: 3,
  154. borderWidth: 1,
  155. ),
  156. )),
  157. Container(
  158. color: Color(0xff09141F).withOpacity(0.13),
  159. width: 0.5,
  160. ),
  161. Expanded(
  162. flex: 1,
  163. child: InkWell(
  164. onTap: () async {
  165. if (selectedStartDate == null) {
  166. ToastEngine.show("Choose Start Date".tr);
  167. return;
  168. }
  169. if (selectedEndDate == null) {
  170. ToastEngine.show("Choose End Date".tr);
  171. return;
  172. }
  173. widget.confirmAction?.call(selectedStartDate!, selectedEndDate!);
  174. onCancel();
  175. },
  176. child: MyTextView(
  177. "Submit".tr,
  178. marginLeft: 10,
  179. fontSize: 17.5,
  180. isFontMedium: true,
  181. textAlign: TextAlign.center,
  182. textColor: Color(0XFF0085C4),
  183. cornerRadius: 3,
  184. ),
  185. )),
  186. ],
  187. ).constrained(height: 46),
  188. ],
  189. ),
  190. ),
  191. ],
  192. ).constrained(width: 285);
  193. }
  194. /// 筛选开始日期
  195. void pickerStartDate() {
  196. DatePickerUtil.showCupertinoDatePicker(
  197. selectedDateTime: selectedStartDate,
  198. mode: CupertinoDatePickerMode.dateAndTime,
  199. onDateTimeChanged: (date) {
  200. setState(() {
  201. selectedStartDate = date;
  202. });
  203. },
  204. title: "Start Date".tr,
  205. );
  206. }
  207. /// 筛选结束日期
  208. void pickerEndDate() {
  209. DatePickerUtil.showCupertinoDatePicker(
  210. selectedDateTime: selectedEndDate ?? selectedStartDate,
  211. mode: CupertinoDatePickerMode.dateAndTime,
  212. onDateTimeChanged: (date) {
  213. setState(() {
  214. selectedEndDate = date;
  215. });
  216. },
  217. title: "End Date".tr,
  218. );
  219. }
  220. //取消弹框
  221. void onCancel() async {
  222. SmartDialog.dismiss();
  223. }
  224. }