book_confirm_page.dart 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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/facility_page_router.dart';
  14. import 'book_confirm_view_model.dart';
  15. @RoutePage()
  16. class BookConfirmPage extends HookConsumerWidget {
  17. const BookConfirmPage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.push(const BookConfirmPageRoute());
  22. } else {
  23. appRouter.push(const BookConfirmPageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.watch(bookConfirmViewModelProvider.notifier);
  29. final state = ref.watch(bookConfirmViewModelProvider);
  30. return Scaffold(
  31. appBar: MyAppBar.appBar(
  32. context,
  33. "Function Room",
  34. showBackButton: true,
  35. backgroundColor: context.appColors.whiteBG,
  36. ),
  37. backgroundColor: context.appColors.backgroundDark,
  38. body: Column(
  39. children: [
  40. Expanded(
  41. child: SingleChildScrollView(
  42. scrollDirection: Axis.vertical,
  43. physics: const BouncingScrollPhysics(),
  44. child: Column(
  45. mainAxisSize: MainAxisSize.max,
  46. crossAxisAlignment: CrossAxisAlignment.center,
  47. children: [
  48. const SizedBox(height: 7.5),
  49. // 预定
  50. _buildConfirmItem(
  51. context,
  52. ref,
  53. S.current.book,
  54. Assets.facilityConfirmDateIcon,
  55. 28.5,
  56. 29,
  57. "Tue,24 Oct 2023",
  58. null,
  59. "05:00 PM-10:00 PM",
  60. null,
  61. ),
  62. // 设施
  63. _buildConfirmItem(
  64. context,
  65. ref,
  66. S.current.facility,
  67. Assets.facilityConfirmFacilityIcon,
  68. 25.0,
  69. 30.5,
  70. "Kids party room",
  71. null,
  72. "Blue room",
  73. null,
  74. ),
  75. // 付款
  76. _buildConfirmItem(
  77. context,
  78. ref,
  79. S.current.payment,
  80. Assets.facilityConfirmPaymentIcon,
  81. 27.0,
  82. 22.0,
  83. S.current.booking_fee,
  84. "10.80",
  85. S.current.total,
  86. "\$10.80",
  87. ),
  88. // 押金
  89. _buildConfirmItem(
  90. context,
  91. ref,
  92. S.current.deposit,
  93. Assets.facilityConfirmDepositIcon,
  94. 28.0,
  95. 26.5,
  96. S.current.deposit_hold,
  97. "\$100.00",
  98. null,
  99. null,
  100. ),
  101. // 添加间隔
  102. const SizedBox(height: 7.5),
  103. ],
  104. ),
  105. ),
  106. ),
  107. // 显示支付信息
  108. _paymentInfo(context,ref),
  109. // 底部按钮
  110. MyButton(
  111. onPressed:viewModel.doPayment,
  112. text: S.current.proceed_with_payment,
  113. textColor: Colors.white,
  114. backgroundColor: context.appColors.btnBgDefault,
  115. fontWeight: FontWeight.w500,
  116. type: ClickType.throttle,
  117. fontSize: 16,
  118. minHeight: 50,
  119. radius: 0,
  120. ).marginOnly(top: 15),
  121. ],
  122. ),
  123. );
  124. }
  125. //展示的Item
  126. Widget _buildConfirmItem(
  127. BuildContext context,
  128. WidgetRef ref,
  129. String title,
  130. String iconPath,
  131. double iconWidth,
  132. double iconHeight,
  133. String line1Txt,
  134. String? line1Content,
  135. String? line2Txt,
  136. String? line2Content,
  137. ) {
  138. return Container(
  139. width: double.infinity,
  140. height: 92.5,
  141. padding: const EdgeInsets.only(left: 20, right: 20),
  142. margin: const EdgeInsets.only(left: 15, right: 15, top: 7.5, bottom: 7.5),
  143. decoration: BoxDecoration(
  144. color: context.appColors.whiteBG,
  145. borderRadius: BorderRadius.circular(6.0), // 圆角
  146. boxShadow: [
  147. BoxShadow(
  148. color: const Color(0xFFB8BFD9).withOpacity(0.3), // 阴影颜色
  149. offset: const Offset(0, 3), // 阴影的偏移量
  150. blurRadius: 8.0, // 模糊半径
  151. spreadRadius: 3.0, // 扩散半径
  152. ),
  153. ],
  154. ),
  155. child: Center(
  156. child: Column(
  157. crossAxisAlignment: CrossAxisAlignment.start,
  158. mainAxisSize: MainAxisSize.min,
  159. children: [
  160. MyTextView(
  161. title,
  162. textColor: context.appColors.textBlack,
  163. fontSize: 16,
  164. marginBottom: 7,
  165. isFontMedium: true,
  166. ),
  167. Row(
  168. mainAxisSize: MainAxisSize.max,
  169. children: [
  170. MyAssetImage(
  171. iconPath,
  172. width: iconWidth,
  173. height: iconHeight,
  174. ).marginOnly(right: 15),
  175. Column(
  176. mainAxisSize: MainAxisSize.min,
  177. children: [
  178. Row(
  179. children: [
  180. MyTextView(
  181. line1Txt,
  182. textColor: context.appColors.textBlack,
  183. fontSize: 14,
  184. isFontRegular: true,
  185. ).expanded(),
  186. MyTextView(
  187. line1Content ?? "",
  188. textColor: context.appColors.textBlack,
  189. fontSize: 14,
  190. isFontRegular: true,
  191. ),
  192. ],
  193. ),
  194. Visibility(
  195. visible: line2Txt != null,
  196. child: Row(
  197. children: [
  198. MyTextView(
  199. line2Txt ?? "",
  200. textColor: context.appColors.textBlack,
  201. fontSize: 14,
  202. isFontRegular: true,
  203. ).expanded(),
  204. MyTextView(
  205. line2Content ?? "",
  206. textColor: context.appColors.textBlack,
  207. fontSize: 14,
  208. isFontRegular: true,
  209. ),
  210. ],
  211. ).marginOnly(top: 6),
  212. ),
  213. ],
  214. ).expanded(),
  215. ],
  216. ),
  217. ],
  218. ),
  219. ),
  220. );
  221. }
  222. //底部的支付信息
  223. Widget _paymentInfo(BuildContext context,WidgetRef ref) {
  224. final viewModel = ref.watch(bookConfirmViewModelProvider.notifier);
  225. return Container(
  226. padding: const EdgeInsets.symmetric(vertical: 17.5, horizontal: 23),
  227. color: context.appColors.whiteBG,
  228. child: Column(
  229. crossAxisAlignment: CrossAxisAlignment.start,
  230. children: [
  231. MyTextView(
  232. S.current.card_caps,
  233. marginBottom: 17,
  234. textColor: context.appColors.textPrimary,
  235. fontSize: 17,
  236. isFontMedium: true,
  237. ),
  238. Row(
  239. children: [
  240. const MyAssetImage(
  241. Assets.facilityConfirmEcardIcon,
  242. height: 38,
  243. ),
  244. MyTextView(
  245. "Ending 9423",
  246. marginLeft: 15,
  247. marginRight: 15,
  248. textColor: context.appColors.textBlack,
  249. fontSize: 15,
  250. isFontMedium: true,
  251. ).expanded(),
  252. MyTextView(
  253. S.current.change,
  254. textColor: Colors.white,
  255. backgroundColor: context.appColors.btnBgDefault,
  256. paddingRight: 16,
  257. onClick: viewModel.gotoChooseCardPage,
  258. paddingLeft: 16,
  259. paddingTop: 8,
  260. paddingBottom: 8,
  261. cornerRadius: 7,
  262. fontSize: 15,
  263. isFontMedium: true,
  264. )
  265. ],
  266. )
  267. ],
  268. ),
  269. );
  270. }
  271. }