payment_confirm_page.dart 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 'package:widgets/utils/dark_theme_util.dart';
  14. import '../../router/page/payment_page_router.dart';
  15. import 'payment_confirm_view_model.dart';
  16. @RoutePage()
  17. class PaymentConfirmPage extends HookConsumerWidget {
  18. final String? title;
  19. final String? orderId;
  20. final String? amount;
  21. final String? deposit;
  22. const PaymentConfirmPage({
  23. Key? key,
  24. @PathParam() required this.title,
  25. @PathParam() required this.orderId,
  26. @PathParam() required this.amount,
  27. @PathParam() this.deposit,
  28. }) : super(key: key);
  29. //启动当前页面
  30. static void startInstance({
  31. BuildContext? context,
  32. required String? title,
  33. required String? orderId,
  34. required String? amount,
  35. String? deposit,
  36. }) {
  37. if (context != null) {
  38. context.router.push(PaymentConfirmPageRoute(title: title, orderId: orderId, amount: amount, deposit: deposit));
  39. } else {
  40. appRouter.push(PaymentConfirmPageRoute(title: title, orderId: orderId, amount: amount, deposit: deposit));
  41. }
  42. }
  43. @override
  44. Widget build(BuildContext context, WidgetRef ref) {
  45. final viewModel = ref.watch(paymentConfirmViewModelProvider.notifier);
  46. final state = ref.watch(paymentConfirmViewModelProvider);
  47. return Scaffold(
  48. appBar: MyAppBar.appBar(context, title ?? "Payment"),
  49. backgroundColor: context.appColors.backgroundWhite,
  50. body: Column(
  51. mainAxisSize: MainAxisSize.max,
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. children: [
  54. SingleChildScrollView(
  55. scrollDirection: Axis.vertical,
  56. physics: const BouncingScrollPhysics(),
  57. child: Column(
  58. crossAxisAlignment: CrossAxisAlignment.start,
  59. children: [
  60. //支付
  61. Visibility(
  62. visible: true,
  63. child: Row(
  64. children: [
  65. MyAssetImage(
  66. Assets.paymentInfoDetails,
  67. width: 27,
  68. height: 27,
  69. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  70. ),
  71. MyTextView(
  72. S.current.payment,
  73. textColor: context.appColors.textBlack,
  74. fontSize: 17,
  75. marginLeft: 14,
  76. isFontMedium: true,
  77. ).expanded(),
  78. ],
  79. ).marginOnly(top: 15, left: 15, right: 15),
  80. ),
  81. //支付金额
  82. Visibility(
  83. visible: true,
  84. child: Row(
  85. mainAxisSize: MainAxisSize.max,
  86. children: [
  87. MyTextView(
  88. S.current.fee,
  89. textColor: context.appColors.textBlack,
  90. fontSize: 18,
  91. isFontRegular: true,
  92. ),
  93. const Spacer(),
  94. MyTextView(
  95. "SGD",
  96. textColor: context.appColors.textBlack,
  97. fontSize: 18,
  98. isFontRegular: true,
  99. ),
  100. MyTextView(
  101. "\$${amount ?? "0.00"}",
  102. textColor: context.appColors.textPrimary,
  103. fontSize: 22,
  104. marginLeft: 8,
  105. isFontMedium: true,
  106. ),
  107. ],
  108. ).marginOnly(top: 20, left: 15, right: 15, bottom: 20),
  109. ),
  110. //分割线
  111. Visibility(
  112. visible: deposit != null && int.parse(deposit!) > 0,
  113. child: Divider(
  114. color: context.appColors.dividerDefault,
  115. height: 0.5,
  116. ),
  117. ),
  118. //押金
  119. Visibility(
  120. visible: deposit != null && int.parse(deposit!) > 0,
  121. child: Row(
  122. children: [
  123. MyAssetImage(
  124. Assets.paymentInfoDetails,
  125. width: 27,
  126. height: 27,
  127. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  128. ),
  129. MyTextView(
  130. S.current.deposit,
  131. textColor: context.appColors.textBlack,
  132. fontSize: 17,
  133. marginLeft: 14,
  134. isFontMedium: true,
  135. ).expanded(),
  136. ],
  137. ).marginOnly(top: 15, left: 15, right: 15),
  138. ),
  139. //押金金额
  140. Visibility(
  141. visible: deposit != null && int.parse(deposit!) > 0,
  142. child: Row(
  143. children: [
  144. MyTextView(
  145. S.current.deposit_hold,
  146. textColor: context.appColors.textBlack,
  147. fontSize: 18,
  148. isFontRegular: true,
  149. ),
  150. const Spacer(),
  151. MyTextView(
  152. "SGD",
  153. textColor: context.appColors.textBlack,
  154. fontSize: 18,
  155. isFontRegular: true,
  156. ),
  157. MyTextView(
  158. "\$${deposit ?? "0.00"}",
  159. textColor: context.appColors.textPrimary,
  160. fontSize: 22,
  161. marginLeft: 8,
  162. isFontMedium: true,
  163. ),
  164. ],
  165. ).marginOnly(top: 20, left: 15, right: 15, bottom: 20),
  166. ),
  167. // // DESC
  168. // Row(
  169. // children: [
  170. // MyAssetImage(
  171. // Assets.paymentInfoNotes,
  172. // width: 27,
  173. // height: 27,
  174. // color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  175. // ),
  176. // MyTextView(
  177. // S.current.notes_to_recipient,
  178. // textColor: context.appColors.textBlack,
  179. // fontSize: 17,
  180. // marginLeft: 14,
  181. // isFontMedium: true,
  182. // ).expanded(),
  183. // ],
  184. // ).marginOnly(left: 15, right: 15),
  185. // MyTextView(
  186. // "The money has already been paid",
  187. // textColor: context.appColors.textPrimary,
  188. // fontSize: 16,
  189. // marginTop: 15,
  190. // marginBottom: 20,
  191. // marginLeft: 15,
  192. // marginRight: 15,
  193. // isFontRegular: true,
  194. // ),
  195. // _paymentInfo(context, ref),
  196. ],
  197. ),
  198. ).expanded(),
  199. // 底部按钮
  200. MyButton(
  201. onPressed: () {
  202. viewModel.doPaymentOrder(orderId ?? "");
  203. },
  204. text: S.current.proceed_with_payment,
  205. textColor: Colors.white,
  206. backgroundColor: context.appColors.btnBgDefault,
  207. fontWeight: FontWeight.w500,
  208. type: ClickType.throttle,
  209. fontSize: 16,
  210. minHeight: 50,
  211. radius: 0,
  212. ).marginOnly(top: 15),
  213. ],
  214. ),
  215. );
  216. }
  217. //底部的支付信息
  218. Widget _paymentInfo(BuildContext context, WidgetRef ref) {
  219. final viewModel = ref.watch(paymentConfirmViewModelProvider.notifier);
  220. return Container(
  221. height: 75,
  222. padding: const EdgeInsets.symmetric(horizontal: 20),
  223. color: context.appColors.backgroundDark,
  224. child: Row(
  225. children: [
  226. const MyAssetImage(
  227. Assets.paymentMasterCardIcon,
  228. height: 34,
  229. width: 56,
  230. ),
  231. MyTextView(
  232. "Ending 9423",
  233. marginLeft: 15,
  234. marginRight: 15,
  235. textColor: context.appColors.textBlack,
  236. fontSize: 15,
  237. isFontMedium: true,
  238. ).expanded(),
  239. MyTextView(
  240. S.current.change,
  241. textColor: Colors.white,
  242. backgroundColor: context.appColors.btnBgDefault,
  243. paddingRight: 16,
  244. paddingLeft: 16,
  245. paddingTop: 8,
  246. paddingBottom: 8,
  247. cornerRadius: 7,
  248. fontSize: 15,
  249. isFontMedium: true,
  250. )
  251. ],
  252. ));
  253. }
  254. }