rewards_transaction_page.dart 19 KB

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