rewards_address_page.dart 5.9 KB

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