applied_butch_modify.dart 8.1 KB

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