repair_status_card_item.dart 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import 'package:cpt_services/components/status_card_item_vm.dart';
  2. import 'package:cpt_services/modules/services/homeService/home_service_page.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:shared/utils/color_utils.dart';
  9. import 'package:shared/utils/ext_dart.dart';
  10. import 'package:shared/utils/log_utils.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/my_button.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import '../constants_services.dart';
  15. class RepairStausCardItem extends HookConsumerWidget {
  16. int serviceId;
  17. String cleanServiceType;
  18. int serviceStatusCode;
  19. Map<String, dynamic> itemObj;
  20. double? cardHeight ;
  21. final Function(dynamic)? onClickCard;
  22. RepairStausCardItem({
  23. Key? key,
  24. required this.serviceId,
  25. required this.cleanServiceType,
  26. required this.serviceStatusCode,
  27. required this.itemObj,
  28. this.onClickCard,
  29. cardHeight,
  30. }): super(key: key) {
  31. this.cardHeight = cardHeight ?? 180.0;
  32. }
  33. @override
  34. Widget build(BuildContext context, WidgetRef ref) {
  35. final vm = ref.read(statusCardItemVmProvider.notifier);
  36. final title = itemObj.getValue("title", "Repair air Conditioner");
  37. final companyName = itemObj.getValue("company_name", "HONG YE GROUP PTE LTD");
  38. Log.d("serviceStatusCode $serviceStatusCode");
  39. bool isCompletedStatus = servicesConstants.servicesStatus['$serviceStatusCode']['code'] == 2? true:false;
  40. String status_text = servicesConstants.servicesStatus['$serviceStatusCode']['text'];
  41. // final status_text = itemObj.getValue("status_text", "");
  42. // List<Map<String, dynamic>>? actionBtnList = servicesConstants.servicesStatusActionBtnList[serviceStatusCode];
  43. // Log.d("actionBtnList $actionBtnList");
  44. useEffect((){
  45. vm.setInitData(context, serviceId, cleanServiceType, serviceStatusCode);
  46. return () {
  47. };
  48. },[]);
  49. return Container(
  50. width: double.infinity,
  51. height: cardHeight!,
  52. child: Padding(
  53. padding: const EdgeInsets.only(left: 18.0, right: 18.0, top: 22.0, bottom: 22.0),
  54. child: Column(
  55. crossAxisAlignment: CrossAxisAlignment.start,
  56. children: [
  57. Expanded(
  58. child: Column(
  59. crossAxisAlignment: CrossAxisAlignment.start,
  60. children: [
  61. // 标题 和状态
  62. Row(
  63. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  64. children: [
  65. // 标题
  66. Expanded(
  67. child: MyTextView(
  68. title,
  69. fontSize: 16,
  70. maxLines: 1,
  71. isFontMedium: true,
  72. textAlign: TextAlign.left,
  73. ),
  74. ),
  75. // 状态
  76. MyTextView(
  77. status_text,
  78. fontSize: 14,
  79. maxLines: 1,
  80. isFontRegular: true,
  81. textAlign: TextAlign.left,
  82. textColor: context.appColors.textPrimary,
  83. ),
  84. ],
  85. ),
  86. // 公司名称
  87. MyTextView(
  88. companyName,
  89. fontSize: 14,
  90. maxLines: 1,
  91. isFontRegular: true,
  92. textAlign: TextAlign.left,
  93. marginTop: 6,
  94. ),
  95. MyTextView(
  96. 'The staff will contact you soon',
  97. fontSize: 14,
  98. maxLines: 1,
  99. isFontRegular: true,
  100. textAlign: TextAlign.left,
  101. textColor: context.appColors.textDarkGray999,
  102. marginTop: 5,
  103. ),
  104. isCompletedStatus? Row(
  105. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  106. children: [
  107. Expanded(
  108. child: MyTextView(
  109. 'Processing Time',
  110. fontSize: 14,
  111. maxLines: 1,
  112. isFontRegular: true,
  113. textAlign: TextAlign.left,
  114. textColor: context.appColors.textBlack,
  115. marginTop: 5,
  116. ),
  117. ),
  118. Expanded(
  119. child: MyTextView(
  120. '13 0ct 2024 12:00',
  121. fontSize: 14,
  122. maxLines: 1,
  123. isFontRegular: true,
  124. textAlign: TextAlign.end,
  125. textColor: context.appColors.textBlack,
  126. marginTop: 5,
  127. ),
  128. )
  129. ],
  130. ): SizedBox.shrink(),
  131. ],
  132. )
  133. ),
  134. // Container(
  135. // margin: EdgeInsets.only(top: 15),
  136. // child: _buildActionSection(context,actionBtnList!, vm, ref),
  137. // ),
  138. ],
  139. ),
  140. ),
  141. );
  142. }
  143. Widget _buildActionSection(BuildContext context,List<Map<String, dynamic>> actionBtnList, StatusCardItemVm vm, WidgetRef ref ) {
  144. return LayoutBuilder(
  145. builder: (BuildContext context, BoxConstraints constraints) {
  146. final maxHeight = constraints.maxHeight;
  147. final minHeight = constraints.minHeight;
  148. final maxWidth = constraints.maxWidth;
  149. // Log.d("---maxHeight-----$maxHeight-- $minHeight $maxWidth--");
  150. return Container(
  151. height: 50,
  152. // color: Colors.red,
  153. width: maxWidth,
  154. child: Row(
  155. mainAxisAlignment: MainAxisAlignment.end,
  156. mainAxisSize: MainAxisSize.max,
  157. children: List.generate(actionBtnList.length, (index){
  158. var item = actionBtnList[index];
  159. // return Expanded(
  160. // child: _buildBtn(context, item),
  161. // );
  162. return _buildBtn(context, item, vm, ref);
  163. })
  164. ),
  165. ).scrollable(
  166. scrollDirection: Axis.horizontal,
  167. physics: BouncingScrollPhysics(),
  168. );
  169. }
  170. );
  171. }
  172. Widget _buildBtn(BuildContext context, Map<String, dynamic> btnItem, StatusCardItemVm vm, WidgetRef ref) {
  173. // final btnCode = btnItem['code'];
  174. return MyButton(
  175. onPressed: (){
  176. vm.handlerClickActionBtn(context, btnItem);
  177. },
  178. text: btnItem['text'],
  179. radius: 10.0,
  180. textColor: context.appColors.textWhite,
  181. backgroundColor: ColorUtils.string2Color(btnItem['btnColor']),
  182. fontSize: 12,
  183. padding: EdgeInsets.symmetric(horizontal: 5),
  184. minWidth: btnItem['btnWidth']?.toDouble(),
  185. minHeight: btnItem['btnHeight']?.toDouble() + 5,
  186. ).marginOnly(left: 5);
  187. }
  188. }