rewards_home_page.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. import 'package:cpt_rewards/modules/rewards_address/rewards_address_page.dart';
  2. import 'package:cpt_rewards/modules/rewards_code/rewards_code_page.dart';
  3. import 'package:cpt_rewards/modules/rewards_detail/rewards_detail_page.dart';
  4. import 'package:cpt_rewards/modules/rewards_list/rewards_list_page.dart';
  5. import 'package:cpt_rewards/modules/rewards_my/rewards_my_page.dart';
  6. import 'package:cpt_rewards/modules/rewards_search/rewards_search_page.dart';
  7. import 'package:cs_resources/generated/assets.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:plugin_platform/engine/image/image_nine_grid.dart';
  12. import 'package:router/ext/auto_router_extensions.dart';
  13. import 'package:shared/utils/color_utils.dart';
  14. import 'package:widgets/ext/ex_widget.dart';
  15. import 'package:widgets/my_load_image.dart';
  16. import '../../../router/page/rewards_page_router.dart';
  17. import './rewards_home_vm.dart';
  18. @RoutePage()
  19. class RewardsHomePage extends HookConsumerWidget {
  20. const RewardsHomePage({Key? key}) : super(key: key);
  21. //启动当前页面
  22. static void startInstance({BuildContext? context}) {
  23. if (context != null) {
  24. context.router.push(const RewardsHomePageRoute());
  25. } else {
  26. appRouter.push(const RewardsHomePageRoute());
  27. }
  28. }
  29. Widget _buildTop(BuildContext context, WidgetRef ref, _vm) {
  30. // List itemsList = _vm.state.list.toList();
  31. return Container(
  32. decoration: BoxDecoration(
  33. border: Border(
  34. bottom: BorderSide(
  35. color: ColorUtils.string2Color('#4161D0'), // 设置bottom边框的颜色
  36. width: 45.0, // 设置bottom边框的宽度
  37. )),
  38. borderRadius: const BorderRadius.only(
  39. topLeft: Radius.circular(0.0),
  40. topRight: Radius.circular(0.0),
  41. bottomLeft: Radius.circular(30.0),
  42. bottomRight: Radius.circular(30.0),
  43. ), // 圆角
  44. ),
  45. child: Column(
  46. crossAxisAlignment: CrossAxisAlignment.start,
  47. children: [
  48. const MyAssetImage(
  49. Assets.rewardsRewardsBack,
  50. width: 44,
  51. height: 44,
  52. ),
  53. const Text(
  54. '1526 Available Points',
  55. style: TextStyle(
  56. fontSize: 18.0,
  57. color: Colors.white,
  58. fontWeight: FontWeight.w500), // 设置字体大小
  59. ).paddingOnly(left: 10, top: 20, bottom: 18),
  60. Row(
  61. crossAxisAlignment: CrossAxisAlignment.center,
  62. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  63. children: [
  64. Container(
  65. decoration: BoxDecoration(
  66. border: Border.all(color: Colors.white, width: 1), // 边框
  67. borderRadius: BorderRadius.circular(8), // 圆角
  68. ),
  69. child: const Text(
  70. 'My Rewards',
  71. style: TextStyle(
  72. fontSize: 15.0,
  73. color: Colors.white,
  74. fontWeight: FontWeight.w400), // 设置字体大小
  75. )
  76. .paddingOnly(left: 10, top: 7, bottom: 7, right: 10)
  77. .onTap(() {
  78. RewardsMyPage.startInstance();
  79. }),
  80. ),
  81. Row(
  82. crossAxisAlignment: CrossAxisAlignment.center,
  83. mainAxisAlignment: MainAxisAlignment.center,
  84. children: [
  85. const MyAssetImage(
  86. Assets.rewardsRewardsY,
  87. width: 26,
  88. height: 26,
  89. ),
  90. Text(
  91. 'Bronze',
  92. style: TextStyle(
  93. fontSize: 17.0,
  94. color: ColorUtils.string2Color('#FFCC00'),
  95. fontWeight: FontWeight.w500), // 设置字体大小
  96. ).marginOnly(
  97. left: 9,
  98. right: 7,
  99. ),
  100. const MyAssetImage(
  101. Assets.rewardsRewardsRight,
  102. width: 7,
  103. height: 12,
  104. ),
  105. ],
  106. )
  107. ],
  108. ).paddingOnly(left: 10)
  109. ],
  110. )
  111. .paddingOnly(top: 15, left: 5, right: 15, bottom: 0)
  112. .border(bottom: 0, color: ColorUtils.string2Color('#4161D0'))
  113. .backgroundColor(ColorUtils.string2Color('#4161D0')));
  114. }
  115. Widget _buildSearch(BuildContext context, WidgetRef ref, _vm) {
  116. // List itemsList = _vm.state.list.toList();
  117. return Container(
  118. height: 50,
  119. decoration: BoxDecoration(
  120. color: Colors.white,
  121. borderRadius: BorderRadius.circular(10),
  122. ),
  123. child: Row(
  124. crossAxisAlignment: CrossAxisAlignment.center,
  125. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  126. children: [
  127. Text(
  128. 'Search',
  129. style: TextStyle(
  130. fontSize: 15.0,
  131. color: ColorUtils.string2Color('#C7CDE3'),
  132. fontWeight: FontWeight.w500), // 设置字体大小
  133. ),
  134. const MyAssetImage(
  135. Assets.rewardsRewardsIndexSearch,
  136. width: 21,
  137. height: 21,
  138. ),
  139. ],
  140. ).paddingOnly(left: 15, right: 15),
  141. ).onTap(() {
  142. RewardsSearchPage.startInstance();
  143. });
  144. }
  145. Widget _buildSwiper(BuildContext context, WidgetRef ref, _vm) {
  146. List itemsList = _vm.state.lists.toList();
  147. return Container(
  148. transform: Matrix4.translationValues(0.0, -10.0, 0.0),
  149. // color: Colors.white,
  150. height: 110,
  151. decoration: const BoxDecoration(
  152. color: Colors.white,
  153. borderRadius: const BorderRadius.only(
  154. topLeft: Radius.circular(10.0),
  155. topRight: Radius.circular(0.0),
  156. bottomLeft: Radius.circular(10.0),
  157. bottomRight: Radius.circular(0.0),
  158. ),
  159. boxShadow: [
  160. BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)
  161. ],
  162. ),
  163. child: ClipRect(
  164. child: SingleChildScrollView(
  165. scrollDirection: Axis.horizontal,
  166. physics: const BouncingScrollPhysics(),
  167. clipBehavior: Clip.none,
  168. child: Row(
  169. crossAxisAlignment: CrossAxisAlignment.center,
  170. mainAxisAlignment: MainAxisAlignment.center,
  171. children: List.generate(itemsList.length, (index) {
  172. final item = itemsList[index];
  173. return Column(
  174. crossAxisAlignment: CrossAxisAlignment.center,
  175. mainAxisAlignment: MainAxisAlignment.center,
  176. children: [
  177. MyAssetImage(
  178. item['icon'],
  179. width: 70,
  180. height: 70,
  181. ),
  182. Text(
  183. item['title']!,
  184. style: TextStyle(
  185. fontSize: 14.0,
  186. color: ColorUtils.string2Color('#000001'),
  187. fontWeight: FontWeight.w600), // 设置字体大小
  188. ),
  189. ],
  190. ).marginOnly(right: 5).onTap(() {
  191. RewardsListPage.startInstance();
  192. });
  193. }),
  194. ).marginOnly(left: 15, right: 15),
  195. )),
  196. ).paddingOnly(left: 15);
  197. }
  198. Widget _buildRecommend(BuildContext context, WidgetRef ref, _vm) {
  199. return Container(
  200. child: Column(
  201. children: [
  202. Row(
  203. crossAxisAlignment: CrossAxisAlignment.center,
  204. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  205. children: [
  206. Text(
  207. 'Recommend',
  208. style: TextStyle(
  209. fontSize: 17.0,
  210. color: ColorUtils.string2Color('#000001'),
  211. fontWeight: FontWeight.w500), // 设置字体大小
  212. ),
  213. Text(
  214. 'See All',
  215. style: TextStyle(
  216. fontSize: 17.0,
  217. color: ColorUtils.string2Color('#4161D0'),
  218. fontWeight: FontWeight.w500), // 设置字体大小
  219. ).onTap(() {
  220. RewardsListPage.startInstance();
  221. }),
  222. ],
  223. ).marginOnly(bottom: 15),
  224. Row(
  225. crossAxisAlignment: CrossAxisAlignment.center,
  226. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  227. children: List.generate(2, (index) {
  228. double hg = 70;
  229. return Container(
  230. width: MediaQuery.of(context).size.width / 2 - 25,
  231. height: 185,
  232. decoration: const BoxDecoration(
  233. color: Colors.white,
  234. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  235. boxShadow: [
  236. BoxShadow(
  237. color: Color.fromRGBO(184, 191, 217, 0.3),
  238. blurRadius: 6)
  239. ],
  240. ),
  241. child: _buildItem(context, ref, _vm, hg));
  242. }))
  243. ],
  244. ),
  245. ).paddingOnly(left: 15, right: 15, top: 10);
  246. }
  247. Widget _buildHottest(BuildContext context, WidgetRef ref, _vm) {
  248. return Container(
  249. child: Column(
  250. children: [
  251. Row(
  252. crossAxisAlignment: CrossAxisAlignment.center,
  253. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  254. children: [
  255. Text(
  256. 'Hottest',
  257. style: TextStyle(
  258. fontSize: 17.0,
  259. color: ColorUtils.string2Color('#000001'),
  260. fontWeight: FontWeight.w500), // 设置字体大小
  261. ),
  262. Text(
  263. 'See All',
  264. style: TextStyle(
  265. fontSize: 17.0,
  266. color: ColorUtils.string2Color('#4161D0'),
  267. fontWeight: FontWeight.w500), // 设置字体大小
  268. ).onTap(() {
  269. RewardsListPage.startInstance();
  270. }),
  271. ],
  272. ).marginOnly(bottom: 15),
  273. Row(
  274. crossAxisAlignment: CrossAxisAlignment.center,
  275. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  276. children: List.generate(2, (index) {
  277. double hg = 70;
  278. return Container(
  279. width: MediaQuery.of(context).size.width / 2 - 25,
  280. height: 185,
  281. decoration: const BoxDecoration(
  282. color: Colors.white,
  283. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  284. boxShadow: [
  285. BoxShadow(
  286. color: Color.fromRGBO(184, 191, 217, 0.3),
  287. blurRadius: 6)
  288. ],
  289. ),
  290. child: _buildItem(context, ref, _vm, hg));
  291. }))
  292. ],
  293. ),
  294. ).paddingOnly(left: 15, right: 15, top: 10);
  295. }
  296. Widget _buildItem(BuildContext context, WidgetRef ref, _vm, height) {
  297. double hg = height;
  298. return Column(
  299. children: [
  300. MyAssetImage(
  301. Assets.rewardsRewardsIndex1,
  302. // width: 110,
  303. height: hg,
  304. ),
  305. Column(
  306. crossAxisAlignment: CrossAxisAlignment.start,
  307. children: [
  308. const Text(
  309. maxLines: 2, // 设置最大行数为2
  310. overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
  311. 'Cute children multifunctional ……',
  312. style: TextStyle(
  313. fontSize: 15.0,
  314. color: Colors.black,
  315. fontWeight: FontWeight.w500),
  316. ),
  317. Text(
  318. maxLines: 1, // 设置最大行数为2
  319. overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
  320. 'Hong Ye Group Co., Ltd',
  321. style: TextStyle(
  322. fontSize: 13.0,
  323. color: ColorUtils.string2Color('#808DAF'),
  324. fontWeight: FontWeight.w400),
  325. ).marginOnly(bottom: 5),
  326. Row(
  327. children: [
  328. const Text(
  329. '300',
  330. style: TextStyle(
  331. fontSize: 18.0,
  332. color: Colors.black,
  333. fontWeight: FontWeight.w500),
  334. ),
  335. Text(
  336. '350',
  337. style: TextStyle(
  338. decoration: TextDecoration.lineThrough,
  339. decorationColor: ColorUtils.string2Color('#808DAF'),
  340. decorationStyle: TextDecorationStyle.solid,
  341. fontSize: 13.0,
  342. color: ColorUtils.string2Color('#808DAF'),
  343. fontWeight: FontWeight.w400),
  344. ).marginOnly(left: 5, right: 5),
  345. const Text(
  346. 'Points',
  347. style: TextStyle(
  348. fontSize: 13.0,
  349. color: Colors.black,
  350. fontWeight: FontWeight.w400),
  351. ),
  352. ],
  353. )
  354. ],
  355. ).paddingOnly(top: 12, left: 12, right: 12)
  356. ],
  357. ).onTap(() {
  358. RewardsDetailPage.startInstance();
  359. });
  360. }
  361. Widget _buildFood(BuildContext context, WidgetRef ref, _vm) {
  362. return Container(
  363. child: Column(
  364. children: [
  365. Row(
  366. crossAxisAlignment: CrossAxisAlignment.center,
  367. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  368. children: [
  369. Text(
  370. 'Food & Beverage',
  371. style: TextStyle(
  372. fontSize: 17.0,
  373. color: ColorUtils.string2Color('#000001'),
  374. fontWeight: FontWeight.w500), // 设置字体大小
  375. ),
  376. Text(
  377. 'See All',
  378. style: TextStyle(
  379. fontSize: 17.0,
  380. color: ColorUtils.string2Color('#4161D0'),
  381. fontWeight: FontWeight.w500), // 设置字体大小
  382. ).onTap(() {
  383. RewardsListPage.startInstance();
  384. }),
  385. ],
  386. ).marginOnly(bottom: 15),
  387. Row(
  388. crossAxisAlignment: CrossAxisAlignment.center,
  389. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  390. children: List.generate(2, (index) {
  391. double hg = 70;
  392. return Container(
  393. width: MediaQuery.of(context).size.width / 2 - 25,
  394. height: 185,
  395. decoration: const BoxDecoration(
  396. color: Colors.white,
  397. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  398. boxShadow: [
  399. BoxShadow(
  400. color: Color.fromRGBO(184, 191, 217, 0.3),
  401. blurRadius: 6)
  402. ],
  403. ),
  404. child: _buildItem(context, ref, _vm, hg));
  405. }))
  406. ],
  407. ),
  408. ).paddingOnly(left: 15, right: 15, top: 10);
  409. }
  410. Widget _buildBest(BuildContext context, WidgetRef ref, _vm) {
  411. return Container(
  412. child: Column(
  413. children: [
  414. Row(
  415. crossAxisAlignment: CrossAxisAlignment.center,
  416. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  417. children: [
  418. Text(
  419. 'Best Offers in Singapore',
  420. style: TextStyle(
  421. fontSize: 17.0,
  422. color: ColorUtils.string2Color('#000001'),
  423. fontWeight: FontWeight.w500), // 设置字体大小
  424. ),
  425. Text(
  426. 'See All',
  427. style: TextStyle(
  428. fontSize: 17.0,
  429. color: ColorUtils.string2Color('#4161D0'),
  430. fontWeight: FontWeight.w500), // 设置字体大小
  431. ),
  432. ],
  433. ).marginOnly(bottom: 15),
  434. Column(
  435. crossAxisAlignment: CrossAxisAlignment.center,
  436. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  437. children: List.generate(2, (index) {
  438. double hg = 140;
  439. return Container(
  440. // width: MediaQuery.of(context).size.width / 2 - 25,
  441. height: 240,
  442. decoration: const BoxDecoration(
  443. color: Colors.white,
  444. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  445. boxShadow: [
  446. BoxShadow(
  447. color: Color.fromRGBO(184, 191, 217, 0.3),
  448. blurRadius: 6)
  449. ],
  450. ),
  451. child: _buildItem(context, ref, _vm, hg))
  452. .marginOnly(bottom: 13);
  453. }))
  454. ],
  455. ),
  456. ).paddingOnly(left: 15, right: 15, top: 10);
  457. }
  458. @override
  459. Widget build(BuildContext context, WidgetRef ref) {
  460. final _vm = ref.read(rewardsVmProvider.notifier);
  461. return Scaffold(
  462. // appBar: AppBar(title: Text("奖励")),
  463. body: Column(children: [
  464. Expanded(
  465. child: SingleChildScrollView(
  466. scrollDirection: Axis.vertical,
  467. physics: const BouncingScrollPhysics(),
  468. clipBehavior: Clip.none,
  469. child: Column(
  470. children: [
  471. _buildTop(context, ref, _vm),
  472. Container(
  473. transform: Matrix4.translationValues(0.0, -25.0, 0.0),
  474. child: _buildSearch(context, ref, _vm), // 使用负数margin
  475. ).paddingOnly(left: 15, right: 15),
  476. _buildSwiper(context, ref, _vm),
  477. _buildRecommend(context, ref, _vm).marginOnly(bottom: 15),
  478. _buildHottest(context, ref, _vm).marginOnly(bottom: 15),
  479. _buildFood(context, ref, _vm).marginOnly(bottom: 15),
  480. _buildBest(context, ref, _vm).marginOnly(bottom: 15),
  481. ],
  482. )),
  483. ),
  484. ]).backgroundColor(ColorUtils.string2Color('#F2F3F6')),
  485. );
  486. }
  487. }