in_progress_page.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:domain/entity/garage_sale_rent_entity.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:auto_route/auto_route.dart';
  5. import 'package:flutter/rendering.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:plugin_basic/provider/app_config/app_config_service.dart';
  9. import 'package:router/ext/auto_router_extensions.dart';
  10. import 'package:shared/utils/color_utils.dart';
  11. import 'package:shared/utils/ext_dart.dart';
  12. import 'package:shared/utils/log_utils.dart';
  13. import 'package:shared/utils/screen_util.dart';
  14. import 'package:widgets/load_state_layout.dart';
  15. import 'package:widgets/my_button.dart';
  16. import 'package:widgets/my_load_image.dart';
  17. import 'package:widgets/ext/ex_widget.dart';
  18. import 'package:widgets/my_text_view.dart';
  19. import 'package:widgets/my_appbar.dart';
  20. import 'package:cs_resources/theme/app_colors_theme.dart';
  21. import 'package:widgets/widget_export.dart';
  22. import '../../../constants_services.dart';
  23. import '../../../router/page/services_page_router.dart';
  24. import 'in_progress_vm.dart';
  25. import '../../../components/status_card_item.dart';
  26. @RoutePage()
  27. class InProgressPage extends HookConsumerWidget {
  28. const InProgressPage({Key? key}) : super(key: key);
  29. //启动当前页面
  30. static void startInstance({BuildContext? context}) {
  31. if (context != null) {
  32. context.router.push(const InProgressPageRoute());
  33. } else {
  34. appRouter.push(const InProgressPageRoute());
  35. }
  36. }
  37. @override
  38. Widget build(BuildContext context, WidgetRef ref) {
  39. final vm = ref.read(inProgressVmProvider.notifier);
  40. final state = ref.watch(inProgressVmProvider);
  41. // final appConfigState = ref.watch(appConfigServiceProvider)
  42. int serviceTypeCode = servicesConstants.servicesType['houseCleaning']?['code'];
  43. int serviceStatusCode = servicesConstants.servicesStatus['1']?['code'];
  44. useEffect(() {
  45. // 组件挂载时执行 - 执行接口请求
  46. Future.microtask(() => vm.initPageData());
  47. return () {
  48. // 组件卸载时执行
  49. Log.d("inProgress_page 组件卸载时执行");
  50. };
  51. }, []);
  52. return Scaffold(
  53. // appBar: MyAppBar.appBar(
  54. // context,
  55. // "InProgress",
  56. // backgroundColor: context.appColors.whiteBG,
  57. // ),
  58. backgroundColor: ColorUtils.string2Color("#F2F3F6"),
  59. body: SizedBox(
  60. width: double.infinity,
  61. height: double.infinity,
  62. child: EasyRefresh(
  63. key: ValueKey('inProgress'),
  64. controller: vm.refreshController,
  65. // 上拉加载
  66. onLoad: () async{
  67. Log.d("----onLoad");
  68. vm.loadMore();
  69. },
  70. // 下拉刷新
  71. onRefresh: () async{
  72. Log.d("----onRefresh");
  73. vm.onRefresh();
  74. },
  75. child: LoadStateLayout(
  76. state: state.loadingState,
  77. errorMessage: state.errorMessage,
  78. errorRetry: () {
  79. vm.retryRequest();
  80. },
  81. successSliverWidget:[
  82. SliverList(
  83. delegate: SliverChildBuilderDelegate(
  84. (context, index) {
  85. return _buildInProgressItem(
  86. context,
  87. ref,
  88. state.list[index],
  89. vm,
  90. serviceTypeCode,
  91. serviceStatusCode
  92. ).onTap((){
  93. vm.gotoCleanOrderDetailPage(
  94. context,
  95. state.list?[index]['id'],
  96. serviceTypeCode,
  97. serviceStatusCode
  98. );
  99. });
  100. },
  101. childCount: state.list.length,
  102. ),
  103. )
  104. ],
  105. ),
  106. ).marginOnly(left: 15,right: 15,top: 0,bottom: 15)
  107. ),
  108. );
  109. }
  110. Widget _buildInProgressItem(BuildContext context, WidgetRef ref, Map<String, dynamic> item, vm, int serviceTypeCode, int serviceStatusCode){
  111. return Container(
  112. margin: const EdgeInsets.only(top: 9),
  113. width: double.infinity,
  114. decoration: BoxDecoration(
  115. color: context.appColors.whiteBG,
  116. borderRadius: BorderRadius.circular(8),
  117. boxShadow: [
  118. BoxShadow(
  119. color: ColorUtils.string2Color('#E5E5E5'),
  120. offset: const Offset(0, 2),
  121. blurRadius: 8,
  122. ),
  123. ],
  124. ),
  125. child: StausCardItem(
  126. key: UniqueKey(),
  127. cardHeight: 175.0,
  128. serviceId: item['id'],
  129. serviceTypeCode: serviceTypeCode,
  130. serviceStatusCode: serviceStatusCode,
  131. itemObj: item.cast<String, dynamic>(),
  132. onClickCard: (dynamic value) async {
  133. // Log.d("点击了喜欢按钮 --id:${item['id']}- $collectionValue");
  134. // int id = item['id'];
  135. // return await vm.handlerClickCollection(id, collectionValue);
  136. },
  137. ),
  138. );
  139. }
  140. }