rewards_successful_page.dart 15 KB

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