rewards_address_page.dart 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import 'package:cs_resources/theme/app_colors_theme.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:auto_route/auto_route.dart';
  5. import 'package:hooks_riverpod/hooks_riverpod.dart';
  6. import 'package:router/ext/auto_router_extensions.dart';
  7. import 'package:shared/utils/log_utils.dart';
  8. import 'package:shared/utils/color_utils.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_load_image.dart';
  12. import 'package:widgets/shatter/picker_container.dart';
  13. import 'package:widgets/widget_export.dart';
  14. import 'package:cs_resources/generated/assets.dart';
  15. import '../../../router/page/rewards_page_router.dart';
  16. import './rewards_address_vm.dart';
  17. @RoutePage()
  18. class RewardsAddressPage extends HookConsumerWidget {
  19. const RewardsAddressPage({Key? key}) : super(key: key);
  20. //启动当前页面
  21. static void startInstance({BuildContext? context}) {
  22. if (context != null) {
  23. context.router.push(const RewardsAddressPageRoute());
  24. } else {
  25. appRouter.push(const RewardsAddressPageRoute());
  26. }
  27. }
  28. Widget _buildItemLeftSection(BuildContext context, WidgetRef ref, item, _vm) {
  29. return Column(
  30. children: [
  31. Column(
  32. crossAxisAlignment: CrossAxisAlignment.start,
  33. children: [
  34. const Text(
  35. maxLines: 1, // 设置最大行数为2
  36. overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
  37. 'Delibowl Group',
  38. style: TextStyle(
  39. fontSize: 16.0,
  40. color: Colors.black,
  41. fontWeight: FontWeight.w500),
  42. ),
  43. Row(
  44. crossAxisAlignment: CrossAxisAlignment.center,
  45. mainAxisAlignment: MainAxisAlignment.center,
  46. children: [
  47. const MyAssetImage(
  48. Assets.rewardsRewardsIconAddes,
  49. width: 15,
  50. height: 19,
  51. ).marginOnly(right: 10),
  52. const Expanded(
  53. child: Text(
  54. maxLines: 2, // 设置最大行数为2
  55. overflow: TextOverflow.ellipsis,
  56. softWrap: true, // 启用自动换行
  57. '176 Orchard Rd, #02-29/30 Song Fa Bak Kut Teh The Centrepoint, Singapore 238843',
  58. style: TextStyle(
  59. fontSize: 15.0,
  60. color: Color.fromARGB(255, 69, 33, 33),
  61. fontWeight: FontWeight.w400),
  62. ),
  63. ),
  64. ],
  65. ).marginOnly(top: 10, bottom: 10),
  66. Container(
  67. height: 40,
  68. decoration: BoxDecoration(
  69. color: Colors.white,
  70. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  71. border: Border.all(
  72. color: ColorUtils.string2Color('#4161D0'), width: 1.0),
  73. ),
  74. child: Center(
  75. child: Text(
  76. '+65 26593458',
  77. style: TextStyle(
  78. fontSize: 15.0,
  79. color: ColorUtils.string2Color('#4161D0'),
  80. fontWeight: FontWeight.w500),
  81. ),
  82. ),
  83. ),
  84. ],
  85. ),
  86. ],
  87. );
  88. }
  89. // listitem
  90. Widget _buildSaleItem(BuildContext context, WidgetRef ref, item, _vm) {
  91. return Container(
  92. decoration: const BoxDecoration(
  93. color: Colors.white,
  94. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  95. boxShadow: [
  96. BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)
  97. ],
  98. ),
  99. child: Column(
  100. children: [
  101. SizedBox(
  102. width: MediaQuery.of(context).size.width - 30,
  103. height: 160,
  104. // margin: const EdgeInsets.only(left: 15, right: 15, top: 12.5),
  105. child: Column(
  106. crossAxisAlignment: CrossAxisAlignment.start,
  107. mainAxisAlignment: MainAxisAlignment.start,
  108. children: [_buildItemLeftSection(context, ref, item, _vm)],
  109. ).paddingOnly(left: 20, right: 20, top: 15),
  110. ).constrained(
  111. minHeight: 160,
  112. ),
  113. ],
  114. ),
  115. ).marginOnly(left: 15, bottom: 15, right: 15);
  116. }
  117. // list
  118. Widget _buildSaleList(BuildContext context, WidgetRef ref, _vm) {
  119. List itemsList = _vm.state.list.toList();
  120. return ListView.builder(
  121. itemCount: itemsList.length,
  122. itemBuilder: (context, index) {
  123. return _buildSaleItem(context, ref, itemsList[index], _vm);
  124. },
  125. );
  126. }
  127. @override
  128. Widget build(BuildContext context, WidgetRef ref) {
  129. final _vm = ref.read(rewardsAddressVmProvider.notifier);
  130. final state = ref.watch(rewardsAddressVmProvider);
  131. return Scaffold(
  132. appBar: MyAppBar.appBar(
  133. context,
  134. "Redeem Deal At",
  135. backgroundColor: context.appColors.whiteBG,
  136. ),
  137. body: Container(
  138. child: Column(
  139. children: [
  140. Expanded(
  141. child: EasyRefresh(
  142. // 上拉加载
  143. onLoad: () async {
  144. Log.d("----onLoad");
  145. _vm.onLoadData();
  146. },
  147. // 下拉刷新
  148. onRefresh: () async {
  149. Log.d("----onRefresh");
  150. _vm.refreshListData();
  151. },
  152. child: Container(
  153. color: ColorUtils.string2Color('#F2F3F6'),
  154. padding: const EdgeInsets.only(top: 15),
  155. child: _buildSaleList(context, ref, _vm)),
  156. ),
  157. )
  158. ],
  159. ),
  160. ),
  161. );
  162. }
  163. }