payment_confirm_page.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.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:widgets/ext/ex_widget.dart';
  9. import 'package:widgets/my_appbar.dart';
  10. import 'package:widgets/my_button.dart';
  11. import 'package:widgets/my_load_image.dart';
  12. import 'package:widgets/my_text_view.dart';
  13. import '../../router/page/payment_page_router.dart';
  14. import 'payment_confirm_view_model.dart';
  15. @RoutePage()
  16. class PaymentConfirmPage extends HookConsumerWidget {
  17. const PaymentConfirmPage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.push(const PaymentConfirmPageRoute());
  22. } else {
  23. appRouter.push(const PaymentConfirmPageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.watch(paymentConfirmViewModelProvider.notifier);
  29. final state = ref.watch(paymentConfirmViewModelProvider);
  30. return Scaffold(
  31. appBar: MyAppBar.appBar(context, "付款的标题"),
  32. backgroundColor: context.appColors.whiteBG,
  33. body: Column(
  34. mainAxisSize: MainAxisSize.max,
  35. crossAxisAlignment: CrossAxisAlignment.start,
  36. children: [
  37. SingleChildScrollView(
  38. scrollDirection: Axis.vertical,
  39. physics: const BouncingScrollPhysics(),
  40. child: Column(
  41. crossAxisAlignment: CrossAxisAlignment.start,
  42. children: [
  43. //金额
  44. Row(
  45. children: [
  46. const MyAssetImage(Assets.paymentInfoDetails, width: 27, height: 27),
  47. MyTextView(
  48. S.current.payment_details,
  49. textColor: context.appColors.textBlack,
  50. fontSize: 17,
  51. marginLeft: 14,
  52. isFontMedium: true,
  53. ).expanded(),
  54. ],
  55. ).marginOnly(top: 15, left: 15, right: 15),
  56. Row(
  57. children: [
  58. MyTextView(
  59. "SGD",
  60. textColor: context.appColors.textBlack,
  61. fontSize: 18,
  62. isFontRegular: true,
  63. ),
  64. MyTextView(
  65. "\$21.80",
  66. textColor: context.appColors.textPrimary,
  67. fontSize: 22,
  68. marginLeft: 12,
  69. isFontMedium: true,
  70. ).expanded(),
  71. ],
  72. ).marginOnly(top: 20, left: 15, right: 15),
  73. Container(
  74. height: 0.5,
  75. margin: const EdgeInsets.only(top: 22, bottom: 13.5, left: 15, right: 15),
  76. color: context.appColors.dividerDefault,
  77. ),
  78. // DESC
  79. Row(
  80. children: [
  81. const MyAssetImage(Assets.paymentInfoNotes, width: 27, height: 27),
  82. MyTextView(
  83. S.current.notes_to_recipient,
  84. textColor: context.appColors.textBlack,
  85. fontSize: 17,
  86. marginLeft: 14,
  87. isFontMedium: true,
  88. ).expanded(),
  89. ],
  90. ).marginOnly(left: 15, right: 15),
  91. MyTextView(
  92. "The money has already been paid",
  93. textColor: context.appColors.textPrimary,
  94. fontSize: 16,
  95. marginTop: 15,
  96. marginBottom: 20,
  97. marginLeft: 15,
  98. marginRight: 15,
  99. isFontRegular: true,
  100. ),
  101. _paymentInfo(context,ref),
  102. ],
  103. ),
  104. ).expanded(),
  105. // 底部按钮
  106. MyButton(
  107. onPressed: viewModel.doPayment,
  108. text: S.current.proceed_with_payment,
  109. textColor: Colors.white,
  110. backgroundColor: context.appColors.btnBgDefault,
  111. fontWeight: FontWeight.w500,
  112. type: ClickType.throttle,
  113. fontSize: 16,
  114. minHeight: 50,
  115. radius: 0,
  116. ).marginOnly(top: 15),
  117. ],
  118. ),
  119. );
  120. }
  121. //底部的支付信息
  122. Widget _paymentInfo(BuildContext context,WidgetRef ref) {
  123. final viewModel = ref.watch(paymentConfirmViewModelProvider.notifier);
  124. return Container(
  125. height: 75,
  126. padding: const EdgeInsets.symmetric(horizontal: 20),
  127. color: context.appColors.backgroundDark,
  128. child: Row(
  129. children: [
  130. const MyAssetImage(
  131. Assets.paymentMasterCardIcon,
  132. height: 34,
  133. width: 56,
  134. ),
  135. MyTextView(
  136. "Ending 9423",
  137. marginLeft: 15,
  138. marginRight: 15,
  139. textColor: context.appColors.textBlack,
  140. fontSize: 15,
  141. isFontMedium: true,
  142. ).expanded(),
  143. MyTextView(
  144. S.current.change,
  145. textColor: Colors.white,
  146. backgroundColor: context.appColors.btnBgDefault,
  147. paddingRight: 16,
  148. paddingLeft: 16,
  149. paddingTop: 8,
  150. onClick: viewModel.gotoChooseCardPage,
  151. paddingBottom: 8,
  152. cornerRadius: 7,
  153. fontSize: 15,
  154. isFontMedium: true,
  155. )
  156. ],
  157. ));
  158. }
  159. }