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