in_progress_page.dart 5.0 KB

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