rewards_transaction_page.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.dart';
  3. import 'package:domain/entity/rewards_detail_entity.dart';
  4. import 'package:domain/entity/rewards_my_detail_entity.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:auto_route/auto_route.dart';
  8. import 'package:flutter_hooks/flutter_hooks.dart';
  9. import 'package:hooks_riverpod/hooks_riverpod.dart';
  10. import 'package:router/ext/auto_router_extensions.dart';
  11. import 'package:shared/utils/log_utils.dart';
  12. import 'package:shared/utils/color_utils.dart';
  13. import 'package:widgets/ext/ex_widget.dart';
  14. import 'package:widgets/my_appbar.dart';
  15. import 'package:widgets/my_load_image.dart';
  16. import 'package:widgets/my_text_view.dart';
  17. import 'package:widgets/shatter/picker_container.dart';
  18. import 'package:widgets/utils/dark_theme_util.dart';
  19. import 'package:widgets/widget_export.dart';
  20. import 'package:cs_resources/generated/assets.dart';
  21. import '../../../router/page/rewards_page_router.dart';
  22. import './rewards_transaction_vm.dart';
  23. @RoutePage()
  24. class RewardsTransactionPage extends HookConsumerWidget {
  25. final int? id;
  26. final String? type;
  27. const RewardsTransactionPage({Key? key, @PathParam('id') required this.id, @PathParam('type') required this.type}) : super(key: key);
  28. //启动当前页面
  29. static void startInstance({BuildContext? context, int? id, String? type = ''}) {
  30. if (context != null) {
  31. context.router.push(RewardsTransactionPageRoute(id: id, type: type));
  32. } else {
  33. appRouter.push(RewardsTransactionPageRoute(id: id, type: type));
  34. }
  35. }
  36. // listitem
  37. Widget _buildSaleItem(BuildContext context, WidgetRef ref, _vm, detailInfo) {
  38. String title = detailInfo!.reward.title ?? "";
  39. List? resources = detailInfo!.reward.resources ?? [];
  40. int point = detailInfo.reward.point ?? 0;
  41. int originalPoint = detailInfo.reward.originalPoint ?? 0;
  42. return Column(
  43. children: [
  44. Container(
  45. decoration: BoxDecoration(
  46. color: context.appColors.whiteBG,
  47. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  48. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  49. ),
  50. width: MediaQuery.of(context).size.width - 30,
  51. // height: 420,
  52. // margin: const EdgeInsets.only(left: 15, right: 15, top: 12.5),
  53. child: Column(
  54. crossAxisAlignment: CrossAxisAlignment.start,
  55. mainAxisAlignment: MainAxisAlignment.start,
  56. children: [
  57. resources!.length > 0
  58. ? MyLoadImage(
  59. resources[0] ?? '',
  60. width: MediaQuery.of(context).size.width,
  61. height: 150,
  62. )
  63. : Container(),
  64. Column(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. mainAxisAlignment: MainAxisAlignment.start,
  67. children: [
  68. Text(
  69. maxLines: 1, // 设置最大行数为2
  70. overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
  71. title,
  72. style: TextStyle(fontSize: 17.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  73. ).marginOnly(bottom: 5),
  74. Row(
  75. children: [
  76. Text(
  77. '$point',
  78. style: TextStyle(fontSize: 19.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  79. ),
  80. Text(
  81. '$originalPoint',
  82. style: TextStyle(
  83. decoration: TextDecoration.lineThrough,
  84. decorationColor: ColorUtils.string2Color('#808DAF'),
  85. decorationStyle: TextDecorationStyle.solid,
  86. fontSize: 12.0,
  87. color: ColorUtils.string2Color('#808DAF'),
  88. fontWeight: FontWeight.w400),
  89. ).marginOnly(left: 5, right: 5),
  90. Text(
  91. S.current.points,
  92. style: TextStyle(fontSize: 13.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  93. ),
  94. ],
  95. ),
  96. ],
  97. ).paddingOnly(left: 15, right: 15, top: 10, bottom: 20),
  98. ],
  99. )),
  100. ],
  101. ).marginOnly(left: 15, bottom: 15, right: 15);
  102. }
  103. Widget _buildDeal(BuildContext context, WidgetRef ref, _vm, detailInfo) {
  104. String redeemedStart = detailInfo.reward.redeemedStart ?? "";
  105. String redeemedEnd = detailInfo.reward.redeemedEnd ?? "";
  106. String redeemedDate = '$redeemedStart until $redeemedEnd';
  107. int code = detailInfo.redemptionCode ?? 0;
  108. return Column(
  109. children: [
  110. Container(
  111. decoration: BoxDecoration(
  112. color: context.appColors.whiteBG,
  113. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  114. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  115. ),
  116. width: MediaQuery.of(context).size.width - 30,
  117. child: Column(
  118. crossAxisAlignment: CrossAxisAlignment.start,
  119. children: [
  120. Row(
  121. mainAxisSize: MainAxisSize.min,
  122. mainAxisAlignment: MainAxisAlignment.start,
  123. crossAxisAlignment: CrossAxisAlignment.center,
  124. children: [
  125. MyAssetImage(
  126. Assets.rewardsRewardsIconDatd,
  127. width: 25,
  128. height: 25,
  129. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  130. ).marginOnly(right: 15),
  131. Text(
  132. redeemedEnd,
  133. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  134. )
  135. ],
  136. ).marginOnly(bottom: 20),
  137. Row(
  138. // mainAxisSize: MainAxisSize.min,
  139. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  140. crossAxisAlignment: CrossAxisAlignment.center,
  141. children: [
  142. Row(
  143. children: [
  144. MyAssetImage(
  145. Assets.rewardsRewardsIcon123,
  146. width: 25,
  147. height: 25,
  148. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  149. ).marginOnly(right: 15),
  150. Text(
  151. S.current.verification_code,
  152. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  153. ),
  154. ],
  155. ),
  156. Text(
  157. '$code',
  158. style: TextStyle(fontSize: 15.0, color: context.appColors.textPrimary, fontWeight: FontWeight.w500),
  159. ),
  160. ],
  161. ),
  162. ],
  163. ).paddingOnly(left: 15, right: 15, top: 12, bottom: 20),
  164. ),
  165. ],
  166. ).marginOnly(left: 15, bottom: 15, right: 15);
  167. }
  168. Widget _buildPackage(BuildContext context, WidgetRef ref, _vm) {
  169. return Column(
  170. children: [
  171. Container(
  172. decoration: BoxDecoration(
  173. color: context.appColors.whiteBG,
  174. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  175. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  176. ),
  177. width: MediaQuery.of(context).size.width - 30,
  178. child: Column(
  179. crossAxisAlignment: CrossAxisAlignment.start,
  180. children: [
  181. Row(
  182. mainAxisSize: MainAxisSize.min,
  183. mainAxisAlignment: MainAxisAlignment.start,
  184. crossAxisAlignment: CrossAxisAlignment.center,
  185. children: [
  186. Expanded(
  187. child: Text(
  188. S.current.issue_contact_phone,
  189. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  190. ),
  191. )
  192. ],
  193. ).marginOnly(bottom: 10, top: 10),
  194. ],
  195. ).paddingOnly(left: 15, right: 35, top: 12, bottom: 20),
  196. ),
  197. ],
  198. ).marginOnly(left: 15, bottom: 25, right: 15);
  199. }
  200. Widget _buildNotice(BuildContext context, WidgetRef ref, _vm, String? types, RewardsMyDetailEntity? detailInfo) {
  201. int phone = detailInfo?.account.phone ?? 0;
  202. String createdAt = detailInfo?.createdAt ?? "";
  203. String usedAt = detailInfo?.usedAt ?? "";
  204. int point = detailInfo?.reward.point ?? 0;
  205. int originalPoint = detailInfo?.reward.originalPoint ?? 0;
  206. int quantity = detailInfo?.quantity ?? 0;
  207. return Column(
  208. children: [
  209. Container(
  210. decoration: BoxDecoration(
  211. color: context.appColors.whiteBG,
  212. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  213. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  214. ),
  215. width: MediaQuery.of(context).size.width - 30,
  216. child: Column(
  217. crossAxisAlignment: CrossAxisAlignment.start,
  218. children: [
  219. Row(
  220. mainAxisSize: MainAxisSize.min,
  221. mainAxisAlignment: MainAxisAlignment.start,
  222. crossAxisAlignment: CrossAxisAlignment.center,
  223. children: [
  224. MyAssetImage(
  225. Assets.rewardsRewardsIconFile,
  226. width: 25,
  227. height: 25,
  228. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  229. ).marginOnly(right: 10),
  230. Text(
  231. S.current.transaction_details,
  232. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  233. )
  234. ],
  235. ).marginOnly(bottom: 12),
  236. Row(
  237. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  238. crossAxisAlignment: CrossAxisAlignment.center,
  239. children: [
  240. Text(
  241. '${S.current.purchase_mobile_no} :',
  242. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  243. ),
  244. Row(
  245. children: [
  246. Text(
  247. '$phone',
  248. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  249. ),
  250. ],
  251. ),
  252. ],
  253. ).marginOnly(bottom: 25),
  254. Row(
  255. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  256. crossAxisAlignment: CrossAxisAlignment.center,
  257. children: [
  258. Text(
  259. '${S.current.purchase_date} :',
  260. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  261. ),
  262. Row(
  263. children: [
  264. Text(
  265. createdAt,
  266. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  267. ),
  268. ],
  269. ),
  270. ],
  271. ).marginOnly(bottom: 25),
  272. types != "expired"
  273. ? Row(
  274. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  275. crossAxisAlignment: CrossAxisAlignment.center,
  276. children: [
  277. Text(
  278. '${S.current.redeemed_date} :',
  279. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  280. ),
  281. Row(
  282. children: [
  283. Text(
  284. usedAt,
  285. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  286. ),
  287. ],
  288. ),
  289. ],
  290. ).marginOnly(bottom: 25)
  291. : Container(),
  292. Row(
  293. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  294. crossAxisAlignment: CrossAxisAlignment.center,
  295. children: [
  296. Text(
  297. '${S.current.quantity} :',
  298. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  299. ),
  300. Row(
  301. children: [
  302. Text(
  303. '$quantity',
  304. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  305. ),
  306. ],
  307. ),
  308. ],
  309. ).marginOnly(bottom: 25),
  310. Row(
  311. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  312. crossAxisAlignment: CrossAxisAlignment.center,
  313. children: [
  314. Text(
  315. '${S.current.points} :',
  316. style: TextStyle(fontSize: 15.0, color: context.appColors.tabTextUnSelectedPrimary, fontWeight: FontWeight.w400),
  317. ),
  318. Row(
  319. children: [
  320. Text(
  321. '$originalPoint',
  322. style: TextStyle(
  323. decoration: TextDecoration.lineThrough,
  324. decorationColor: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#54638C'), darkColor: Colors.white),
  325. decorationStyle: TextDecorationStyle.solid,
  326. fontSize: 14.0,
  327. color: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#54638C'), darkColor: Colors.white),
  328. fontWeight: FontWeight.w400),
  329. ),
  330. Text(
  331. '$point',
  332. style: TextStyle(fontSize: 19.0, color: context.appColors.tabTextUnSelectedPrimary, fontWeight: FontWeight.w500),
  333. ).marginOnly(left: 10),
  334. ],
  335. ),
  336. ],
  337. ).marginOnly(bottom: 25),
  338. ],
  339. ).paddingOnly(left: 15, right: 15, top: 15, bottom: 5),
  340. ),
  341. ],
  342. ).marginOnly(left: 15, bottom: 15, right: 15);
  343. }
  344. @override
  345. Widget build(BuildContext context, WidgetRef ref) {
  346. final _vm = ref.read(rewardsTransactionVmProvider.notifier);
  347. final state = ref.watch(rewardsTransactionVmProvider);
  348. RewardsMyDetailEntity? detailInfo = state.detailInfo;
  349. String? types = type;
  350. useEffect(() {
  351. // 组件挂载时执行 - 执行接口请求
  352. Future.microtask(() => _vm.initPageData(id: id));
  353. return () {
  354. // 组件卸载时执行
  355. Log.d("property_news_page 组件卸载时执行");
  356. };
  357. }, []);
  358. return Scaffold(
  359. appBar: MyAppBar.appBar(
  360. context,
  361. S.current.my_rewards_details,
  362. backgroundColor: context.appColors.whiteBG,
  363. ),
  364. body: detailInfo?.createdAt != ''
  365. ? Column(
  366. children: [
  367. Expanded(
  368. child: SingleChildScrollView(
  369. scrollDirection: Axis.vertical,
  370. physics: const BouncingScrollPhysics(),
  371. clipBehavior: Clip.none,
  372. child: Column(
  373. children: [
  374. Container(
  375. color: context.appColors.backgroundDark,
  376. padding: const EdgeInsets.only(top: 15),
  377. child: Column(
  378. children: [
  379. _buildSaleItem(context, ref, _vm, detailInfo),
  380. _buildDeal(context, ref, _vm, detailInfo),
  381. _buildNotice(context, ref, _vm, types, detailInfo),
  382. _buildPackage(context, ref, _vm),
  383. ],
  384. )),
  385. ],
  386. ))),
  387. ],
  388. )
  389. : const SizedBox.shrink(),
  390. );
  391. }
  392. }