status_card_item.dart 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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:domain/entity/garage_sale_history_entity.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_hooks/flutter_hooks.dart';
  8. import 'package:hooks_riverpod/hooks_riverpod.dart';
  9. import 'package:shared/utils/color_utils.dart';
  10. import 'package:shared/utils/ext_dart.dart';
  11. import 'package:shared/utils/log_utils.dart';
  12. import 'package:widgets/ext/ex_widget.dart';
  13. import 'package:widgets/my_button.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import '../constants_services.dart';
  16. class StausCardItem extends HookConsumerWidget {
  17. GarageSaleHistoryList? item;
  18. double? cardHeight;
  19. final Function(dynamic)? onClickCard;
  20. StausCardItem({
  21. Key? key,
  22. required this.item,
  23. this.onClickCard,
  24. cardHeight,
  25. }) : super(key: key) {
  26. this.cardHeight = cardHeight ?? 180.0;
  27. }
  28. @override
  29. Widget build(BuildContext context, WidgetRef ref) {
  30. // final vm = ref.read(statusCardItemVmProvider.notifier);
  31. // List<Map<String, dynamic>>? actionBtnList = servicesConstants.servicesStatusActionBtnList[serviceStatusCode];
  32. // Log.d("actionBtnList $actionBtnList");
  33. // useEffect((){
  34. // vm.setInitData(context, serviceId, serviceTypeCode, serviceStatusCode);
  35. // return () {
  36. // };
  37. // },[]);
  38. return Container(
  39. width: double.infinity,
  40. height: cardHeight,
  41. alignment: Alignment.center,
  42. child: Padding(
  43. padding: EdgeInsets.only(left: 18.0, right: 18.0, top: 10, bottom: 10.0),
  44. child: Column(
  45. crossAxisAlignment: CrossAxisAlignment.start,
  46. children: [
  47. Expanded(
  48. child: Column(
  49. crossAxisAlignment: CrossAxisAlignment.start,
  50. children: [
  51. // 标题 和状态
  52. Row(
  53. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  54. children: [
  55. // 标题
  56. Expanded(
  57. child: MyTextView(
  58. item?.service?.name ?? "-",
  59. fontSize: 16,
  60. maxLines: 1,
  61. isFontMedium: true,
  62. textAlign: TextAlign.left,
  63. ),
  64. ),
  65. // 状态
  66. MyTextView(
  67. item?.orderStatus??"-",
  68. fontSize: 14,
  69. maxLines: 1,
  70. isFontRegular: true,
  71. textAlign: TextAlign.left,
  72. textColor: context.appColors.textPrimary,
  73. ),
  74. ],
  75. ),
  76. // 公司名称
  77. MyTextView(
  78. item?.merchant?.name ?? "-",
  79. fontSize: 14,
  80. maxLines: 1,
  81. isFontRegular: true,
  82. textAlign: TextAlign.left,
  83. marginTop: 5,
  84. ),
  85. // 价格
  86. Row(
  87. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  88. children: [
  89. // 商品/服务名称
  90. MyTextView(
  91. item?.orderProducts[0].productName ?? "-",
  92. fontSize: 14,
  93. maxLines: 1,
  94. isFontRegular: true,
  95. textAlign: TextAlign.left,
  96. ),
  97. // 公司名称
  98. MyTextView(
  99. '\$${item?.orderProducts[0].totalAmount ?? "-"}',
  100. fontSize: 17,
  101. maxLines: 1,
  102. isFontBold: true,
  103. textAlign: TextAlign.left,
  104. textColor: context.appColors.textPrimary,
  105. ),
  106. ],
  107. ),
  108. const SizedBox(
  109. height: 5,
  110. ),
  111. // visit time
  112. Row(
  113. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  114. children: [
  115. MyTextView(
  116. 'Visit Time',
  117. fontSize: 14,
  118. maxLines: 1,
  119. isFontRegular: true,
  120. textAlign: TextAlign.left,
  121. ),
  122. MyTextView(
  123. item?.orderProducts[0].plannedServiceAt ?? "-",
  124. fontSize: 14,
  125. maxLines: 1,
  126. isFontRegular: true,
  127. textAlign: TextAlign.left,
  128. textColor: context.appColors.textBlack,
  129. ),
  130. ],
  131. ),
  132. const SizedBox(
  133. height: 5,
  134. ),
  135. // order time
  136. Row(
  137. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  138. children: [
  139. MyTextView(
  140. 'Order Time',
  141. fontSize: 14,
  142. maxLines: 1,
  143. isFontRegular: true,
  144. textAlign: TextAlign.left,
  145. ),
  146. MyTextView(
  147. item?.createdAt ?? "-",
  148. fontSize: 14,
  149. maxLines: 1,
  150. isFontRegular: true,
  151. textAlign: TextAlign.left,
  152. textColor: context.appColors.textBlack,
  153. ),
  154. ],
  155. ),
  156. ],
  157. )),
  158. // Container(
  159. // margin: EdgeInsets.only(top: 15),
  160. // child: _buildActionSection(context,actionBtnList!, vm, ref),
  161. // ),
  162. ],
  163. ),
  164. ),
  165. );
  166. }
  167. Widget _buildActionSection(BuildContext context, List<Map<String, dynamic>> actionBtnList, StatusCardItemVm vm, WidgetRef ref) {
  168. return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
  169. final maxHeight = constraints.maxHeight;
  170. final minHeight = constraints.minHeight;
  171. final maxWidth = constraints.maxWidth;
  172. // Log.d("---maxHeight-----$maxHeight-- $minHeight $maxWidth--");
  173. return Container(
  174. height: 50,
  175. // color: Colors.red,
  176. width: maxWidth,
  177. child: Row(
  178. mainAxisAlignment: MainAxisAlignment.end,
  179. mainAxisSize: MainAxisSize.max,
  180. children: List.generate(actionBtnList.length, (index) {
  181. var item = actionBtnList[index];
  182. // return Expanded(
  183. // child: _buildBtn(context, item),
  184. // );
  185. return _buildBtn(context, item, vm, ref);
  186. })),
  187. ).scrollable(
  188. scrollDirection: Axis.horizontal,
  189. physics: BouncingScrollPhysics(),
  190. );
  191. });
  192. }
  193. Widget _buildBtn(BuildContext context, Map<String, dynamic> btnItem, StatusCardItemVm vm, WidgetRef ref) {
  194. // final btnCode = btnItem['code'];
  195. return MyButton(
  196. onPressed: () {
  197. vm.handlerClickActionBtn(context, btnItem);
  198. },
  199. text: btnItem['text'],
  200. radius: 10.0,
  201. textColor: context.appColors.textWhite,
  202. backgroundColor: ColorUtils.string2Color(btnItem['btnColor']),
  203. fontSize: 12,
  204. padding: EdgeInsets.symmetric(horizontal: 5),
  205. minWidth: btnItem['btnWidth']?.toDouble(),
  206. minHeight: btnItem['btnHeight']?.toDouble() + 5,
  207. ).marginOnly(left: 5);
  208. }
  209. }