status_card_item.dart 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. child: Padding(
  42. padding: const EdgeInsets.only(left: 18.0, right: 18.0, top: 22.0, bottom: 22.0),
  43. child: Column(
  44. crossAxisAlignment: CrossAxisAlignment.start,
  45. children: [
  46. Expanded(
  47. child: Column(
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. // 标题 和状态
  51. Row(
  52. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  53. children: [
  54. // 标题
  55. Expanded(
  56. child: MyTextView(
  57. item?.service?.name ?? "-",
  58. fontSize: 16,
  59. maxLines: 1,
  60. isFontMedium: true,
  61. textAlign: TextAlign.left,
  62. ),
  63. ),
  64. // 状态
  65. MyTextView(
  66. item?.orderStatus??"-",
  67. fontSize: 14,
  68. maxLines: 1,
  69. isFontRegular: true,
  70. textAlign: TextAlign.left,
  71. textColor: context.appColors.textPrimary,
  72. ),
  73. ],
  74. ),
  75. // 公司名称
  76. MyTextView(
  77. item?.merchant?.name ?? "-",
  78. fontSize: 14,
  79. maxLines: 1,
  80. isFontRegular: true,
  81. textAlign: TextAlign.left,
  82. marginTop: 6,
  83. ),
  84. // 价格
  85. Row(
  86. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  87. children: [
  88. // 商品/服务名称
  89. MyTextView(
  90. item?.orderProducts[0].productName ?? "-",
  91. fontSize: 14,
  92. maxLines: 1,
  93. isFontRegular: true,
  94. textAlign: TextAlign.left,
  95. ),
  96. // 公司名称
  97. MyTextView(
  98. '\$${item?.orderProducts[0].totalAmount ?? "-"}',
  99. fontSize: 17,
  100. maxLines: 1,
  101. isFontBold: true,
  102. textAlign: TextAlign.left,
  103. textColor: context.appColors.textPrimary,
  104. ),
  105. ],
  106. ),
  107. const SizedBox(
  108. height: 7.5,
  109. ),
  110. // visit time
  111. Row(
  112. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  113. children: [
  114. MyTextView(
  115. 'Visit Time',
  116. fontSize: 14,
  117. maxLines: 1,
  118. isFontRegular: true,
  119. textAlign: TextAlign.left,
  120. ),
  121. MyTextView(
  122. item?.orderProducts[0].plannedServiceAt ?? "-",
  123. fontSize: 14,
  124. maxLines: 1,
  125. isFontRegular: true,
  126. textAlign: TextAlign.left,
  127. textColor: context.appColors.textBlack,
  128. ),
  129. ],
  130. ),
  131. const SizedBox(
  132. height: 7.5,
  133. ),
  134. // order time
  135. Row(
  136. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  137. children: [
  138. MyTextView(
  139. 'Order Time',
  140. fontSize: 14,
  141. maxLines: 1,
  142. isFontRegular: true,
  143. textAlign: TextAlign.left,
  144. ),
  145. MyTextView(
  146. item?.createdAt ?? "-",
  147. fontSize: 14,
  148. maxLines: 1,
  149. isFontRegular: true,
  150. textAlign: TextAlign.left,
  151. textColor: context.appColors.textBlack,
  152. ),
  153. ],
  154. ),
  155. ],
  156. )),
  157. // Container(
  158. // margin: EdgeInsets.only(top: 15),
  159. // child: _buildActionSection(context,actionBtnList!, vm, ref),
  160. // ),
  161. ],
  162. ),
  163. ),
  164. );
  165. }
  166. Widget _buildActionSection(BuildContext context, List<Map<String, dynamic>> actionBtnList, StatusCardItemVm vm, WidgetRef ref) {
  167. return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
  168. final maxHeight = constraints.maxHeight;
  169. final minHeight = constraints.minHeight;
  170. final maxWidth = constraints.maxWidth;
  171. // Log.d("---maxHeight-----$maxHeight-- $minHeight $maxWidth--");
  172. return Container(
  173. height: 50,
  174. // color: Colors.red,
  175. width: maxWidth,
  176. child: Row(
  177. mainAxisAlignment: MainAxisAlignment.end,
  178. mainAxisSize: MainAxisSize.max,
  179. children: List.generate(actionBtnList.length, (index) {
  180. var item = actionBtnList[index];
  181. // return Expanded(
  182. // child: _buildBtn(context, item),
  183. // );
  184. return _buildBtn(context, item, vm, ref);
  185. })),
  186. ).scrollable(
  187. scrollDirection: Axis.horizontal,
  188. physics: BouncingScrollPhysics(),
  189. );
  190. });
  191. }
  192. Widget _buildBtn(BuildContext context, Map<String, dynamic> btnItem, StatusCardItemVm vm, WidgetRef ref) {
  193. // final btnCode = btnItem['code'];
  194. return MyButton(
  195. onPressed: () {
  196. vm.handlerClickActionBtn(context, btnItem);
  197. },
  198. text: btnItem['text'],
  199. radius: 10.0,
  200. textColor: context.appColors.textWhite,
  201. backgroundColor: ColorUtils.string2Color(btnItem['btnColor']),
  202. fontSize: 12,
  203. padding: EdgeInsets.symmetric(horizontal: 5),
  204. minWidth: btnItem['btnWidth']?.toDouble(),
  205. minHeight: btnItem['btnHeight']?.toDouble() + 5,
  206. ).marginOnly(left: 5);
  207. }
  208. }