feedback_detail_page.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:plugin_platform/engine/image/image_nine_grid.dart';
  9. import 'package:router/ext/auto_router_extensions.dart';
  10. import 'package:widgets/ext/ex_widget.dart';
  11. import 'package:widgets/my_appbar.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import '../../../router/page/main_page_router.dart';
  15. import 'feedback_detail_view_model.dart';
  16. @RoutePage()
  17. class FeedbackDetailPage extends HookConsumerWidget {
  18. //Feedback的Id
  19. final String? id;
  20. const FeedbackDetailPage({Key? key, required this.id}) : super(key: key);
  21. //启动当前页面
  22. static void startInstance({BuildContext? context, required String? id}) {
  23. if (context != null) {
  24. context.router.push(FeedbackDetailPageRoute(id: id));
  25. } else {
  26. appRouter.push(FeedbackDetailPageRoute(id: id));
  27. }
  28. }
  29. @override
  30. Widget build(BuildContext context, WidgetRef ref) {
  31. final viewModel = ref.watch(feedbackDetailViewModelProvider.notifier);
  32. final state = ref.watch(feedbackDetailViewModelProvider);
  33. useEffect(() {
  34. // 组件挂载时执行 - 执行接口请求
  35. Future.microtask(() => viewModel.fetchFeedbackDetail(id));
  36. return () {
  37. // 组件卸载时执行
  38. };
  39. }, []);
  40. return Scaffold(
  41. appBar: MyAppBar.appBar(context, S.current.feedback_details, showBottomDivider: true),
  42. backgroundColor: context.appColors.backgroundDark,
  43. body: SingleChildScrollView(
  44. scrollDirection: Axis.vertical,
  45. physics: const BouncingScrollPhysics(),
  46. child: Column(
  47. mainAxisSize: MainAxisSize.max,
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. Container(
  51. color: context.appColors.whiteBG,
  52. width: double.infinity,
  53. padding: const EdgeInsets.symmetric(horizontal: 10),
  54. height: 85,
  55. child: Column(
  56. mainAxisAlignment: MainAxisAlignment.center,
  57. mainAxisSize: MainAxisSize.max,
  58. crossAxisAlignment: CrossAxisAlignment.start,
  59. children: [
  60. MyTextView(
  61. state.detail?.title ?? "-",
  62. fontSize: 21,
  63. isFontMedium: true,
  64. textColor: context.appColors.textBlack,
  65. ),
  66. MyTextView(
  67. "${state.detail?.createdAt ?? ""} | ${state.detail?.category?.name ?? ""} | ${state.detail?.status == 1 ? S.current.in_progress : S.current.replied}",
  68. fontSize: 12,
  69. marginTop: 8,
  70. isFontRegular: true,
  71. textColor: context.appColors.textDarkGray,
  72. ),
  73. ],
  74. ),
  75. ),
  76. //反馈的内容
  77. Container(
  78. width: double.infinity,
  79. margin: const EdgeInsets.only(left: 12.5, right: 12.5, top: 12.5, bottom: 12.5),
  80. padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 25),
  81. decoration: BoxDecoration(
  82. color: context.appColors.whiteBG,
  83. borderRadius: BorderRadius.circular(6.0), // 圆角
  84. boxShadow: [
  85. BoxShadow(
  86. color: const Color(0xFFB8BFD9).withOpacity(0.3), // 阴影颜色
  87. offset: const Offset(0, 3), // 阴影的偏移量
  88. blurRadius: 8.0, // 模糊半径
  89. spreadRadius: 3.0, // 扩散半径
  90. ),
  91. ],
  92. ),
  93. child: Column(
  94. crossAxisAlignment: CrossAxisAlignment.start,
  95. children: [
  96. MyTextView(
  97. state.detail?.content ?? "",
  98. fontSize: 15,
  99. marginBottom: 15,
  100. isFontRegular: true,
  101. textColor: context.appColors.textDarkGray,
  102. ),
  103. //九宫格展示
  104. ImageNineGrid(
  105. isSelectEnable: false,
  106. maxImages: 10,
  107. spacing: 10,
  108. aspectRatio: 108 / 80,
  109. initialImages: state.detail?.resources ?? [],
  110. onImagesChanged: (list) {},
  111. ),
  112. ],
  113. ),
  114. ),
  115. //回复的数据
  116. state.isReplyState ? _buildReplyWidget(context, ref) : _buildWaitingWidget(context)
  117. ],
  118. )),
  119. );
  120. }
  121. Widget _buildReplyWidget(BuildContext context, WidgetRef ref) {
  122. final state = ref.watch(feedbackDetailViewModelProvider);
  123. return Column(
  124. crossAxisAlignment: CrossAxisAlignment.start,
  125. children: [
  126. Row(
  127. mainAxisSize: MainAxisSize.max,
  128. mainAxisAlignment: MainAxisAlignment.start,
  129. crossAxisAlignment: CrossAxisAlignment.center,
  130. children: [
  131. MyTextView(
  132. S.current.administrator_reply,
  133. fontSize: 18,
  134. isFontRegular: true,
  135. textColor: context.appColors.textBlack,
  136. ).expanded(),
  137. MyTextView(
  138. state.detail?.replies?[0].createdAt ?? "-",
  139. fontSize: 12,
  140. isFontRegular: true,
  141. textColor: context.appColors.textDarkGray,
  142. )
  143. ],
  144. ).marginOnly(left: 12.5, right: 12.5, bottom: 14, top: 2.5),
  145. //回复的内容
  146. Container(
  147. width: double.infinity,
  148. margin: const EdgeInsets.only(left: 12.5, right: 12.5, bottom: 13.5),
  149. padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 25),
  150. decoration: BoxDecoration(
  151. color: context.appColors.whiteBG,
  152. borderRadius: BorderRadius.circular(6.0), // 圆角
  153. boxShadow: [
  154. BoxShadow(
  155. color: const Color(0xFFB8BFD9).withOpacity(0.3), // 阴影颜色
  156. offset: const Offset(0, 3), // 阴影的偏移量
  157. blurRadius: 8.0, // 模糊半径
  158. spreadRadius: 3.0, // 扩散半径
  159. ),
  160. ],
  161. ),
  162. child: Column(
  163. crossAxisAlignment: CrossAxisAlignment.start,
  164. children: [
  165. MyTextView(
  166. state.detail?.replies?[0].content ?? "",
  167. fontSize: 15,
  168. marginBottom: 15,
  169. isFontRegular: true,
  170. textColor: context.appColors.textDarkGray,
  171. ),
  172. //九宫格展示
  173. ImageNineGrid(
  174. isSelectEnable: false,
  175. maxImages: 10,
  176. spacing: 10,
  177. aspectRatio: 108 / 80,
  178. initialImages: state.detail?.replies?[0].resources ?? [],
  179. onImagesChanged: (list) {},
  180. ),
  181. ],
  182. ),
  183. )
  184. ],
  185. );
  186. }
  187. Widget _buildWaitingWidget(BuildContext context) {
  188. return SizedBox(
  189. width: double.infinity,
  190. child: Column(
  191. children: [
  192. const SizedBox(height: 40),
  193. const MyAssetImage(Assets.mainFeedbackWaitingIcon, width: 38, height: 38),
  194. MyTextView(
  195. S.current.waiting_for_the_administrator,
  196. fontSize: 15,
  197. marginTop: 11,
  198. marginBottom: 40,
  199. isFontRegular: true,
  200. textColor: context.appColors.textDarkGray,
  201. )
  202. ],
  203. ),
  204. );
  205. }
  206. }