rewards_code_page.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_code_vm.dart';
  18. @RoutePage()
  19. class RewardsCodePage extends HookConsumerWidget {
  20. final int? code;
  21. const RewardsCodePage({Key? key, @PathParam('code') required this.code}) : super(key: key);
  22. //启动当前页面
  23. static void startInstance({BuildContext? context,
  24. int? code,
  25. }) {
  26. if (context != null) {
  27. context.router.push(RewardsCodePageRoute(code: code));
  28. } else {
  29. appRouter.push(RewardsCodePageRoute(code: code));
  30. }
  31. }
  32. Widget _buildItemLeftSection(BuildContext context, WidgetRef ref, item, _vm) {
  33. int? codes = code ?? 0;
  34. return Column(
  35. children: [
  36. Column(
  37. crossAxisAlignment: CrossAxisAlignment.center,
  38. mainAxisAlignment: MainAxisAlignment.center,
  39. children: [
  40. Center(
  41. child: Text(
  42. S.current.show_verification_cap,
  43. textAlign: TextAlign.center,
  44. style: const TextStyle(
  45. fontSize: 20.0,
  46. color: Colors.black,
  47. fontWeight: FontWeight.w500),
  48. ),
  49. ),
  50. Text(
  51. S.current.verification_code_cap,
  52. style: TextStyle(
  53. fontSize: 18.0,
  54. color: ColorUtils.string2Color('#54638C'),
  55. fontWeight: FontWeight.w500),
  56. ).marginOnly(top: 35, bottom: 20),
  57. Text(
  58. '$codes',
  59. style: TextStyle(
  60. fontSize: 36.0,
  61. color: ColorUtils.string2Color('#4161D0'),
  62. fontWeight: FontWeight.w500),
  63. ),
  64. ],
  65. ),
  66. ],
  67. );
  68. }
  69. // listitem
  70. Widget _buildSaleItem(BuildContext context, WidgetRef ref, item, _vm) {
  71. return Column(
  72. children: [
  73. Container(
  74. decoration: const BoxDecoration(
  75. color: Colors.white,
  76. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  77. boxShadow: [
  78. BoxShadow(
  79. color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)
  80. ],
  81. ),
  82. width: MediaQuery.of(context).size.width - 30,
  83. height: 250,
  84. // margin: const EdgeInsets.only(left: 15, right: 15, top: 12.5),
  85. child: Column(
  86. crossAxisAlignment: CrossAxisAlignment.start,
  87. mainAxisAlignment: MainAxisAlignment.start,
  88. children: [_buildItemLeftSection(context, ref, item, _vm)],
  89. ).paddingOnly(left: 26, right: 26, top: 40),
  90. ),
  91. ],
  92. ).marginOnly(left: 15, bottom: 15, right: 15);
  93. }
  94. // list
  95. Widget _buildSaleList(BuildContext context, WidgetRef ref, _vm) {
  96. List itemsList = _vm.state.list.toList();
  97. return _buildSaleItem(context, ref, itemsList[0], _vm);
  98. }
  99. @override
  100. Widget build(BuildContext context, WidgetRef ref) {
  101. final _vm = ref.read(rewardsCodeVmProvider.notifier);
  102. final state = ref.watch(rewardsCodeVmProvider);
  103. return Scaffold(
  104. appBar: MyAppBar.appBar(
  105. context,
  106. S.current.verification_code,
  107. backgroundColor: context.appColors.whiteBG,
  108. ),
  109. body: Container(
  110. child: Column(
  111. children: [
  112. Expanded(
  113. child:
  114. EasyRefresh(
  115. child:
  116. Container(
  117. color: ColorUtils.string2Color('#F2F3F6'),
  118. padding: const EdgeInsets.only(top: 15),
  119. child: _buildSaleList(context, ref, _vm)),
  120. ),
  121. )
  122. ],
  123. ),
  124. ),
  125. );
  126. }
  127. }