rewards_home_page.dart 18 KB

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