facility_detail_page.dart 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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_load_image.dart';
  11. import 'package:widgets/my_text_view.dart';
  12. import '../../router/page/facility_page_router.dart';
  13. import 'facility_detail_view_model.dart';
  14. @RoutePage()
  15. class FacilityDetailPage extends HookConsumerWidget {
  16. const FacilityDetailPage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const FacilityDetailPageRoute());
  21. } else {
  22. appRouter.push(const FacilityDetailPageRoute());
  23. }
  24. }
  25. //启动当前页面并回退至设施首页
  26. static void startWithPop2Main() {
  27. appRouter.pushAndPopUntil(
  28. const FacilityDetailPageRoute(),
  29. predicate: (route) {
  30. return route.settings.name == 'FacilityPageRoute';
  31. },
  32. );
  33. }
  34. @override
  35. Widget build(BuildContext context, WidgetRef ref) {
  36. final viewModel = ref.watch(facilityDetailViewModelProvider.notifier);
  37. final state = ref.watch(facilityDetailViewModelProvider);
  38. return Scaffold(
  39. appBar: MyAppBar.appBar(context, "Kids party room", backgroundColor: context.appColors.whiteBG),
  40. backgroundColor: context.appColors.backgroundDark,
  41. body: SingleChildScrollView(
  42. scrollDirection: Axis.vertical,
  43. physics: const BouncingScrollPhysics(),
  44. child: Column(
  45. mainAxisSize: MainAxisSize.max,
  46. crossAxisAlignment: CrossAxisAlignment.center,
  47. children: [
  48. //顶部的信息展示
  49. _buildHeaderWidget(context, ref),
  50. //预定
  51. _buildDetailItem(
  52. context,
  53. ref,
  54. S.current.book,
  55. Assets.facilityConfirmDateIcon,
  56. 28.5,
  57. 29,
  58. "Tue,24 Oct 2023",
  59. null,
  60. "05:00 PM-10:00 PM",
  61. null,
  62. ),
  63. //设施
  64. _buildDetailItem(
  65. context,
  66. ref,
  67. S.current.facility,
  68. Assets.facilityConfirmFacilityIcon,
  69. 25.0,
  70. 30.5,
  71. "Kids party room",
  72. null,
  73. "Blue room",
  74. null,
  75. ),
  76. //付款
  77. _buildDetailItem(
  78. context,
  79. ref,
  80. S.current.payment,
  81. Assets.facilityConfirmPaymentIcon,
  82. 27.0,
  83. 22.0,
  84. S.current.booking_fee,
  85. "10.80",
  86. S.current.total,
  87. "\$10.80",
  88. ),
  89. // 押金
  90. _buildDetailItem(
  91. context,
  92. ref,
  93. S.current.deposit,
  94. Assets.facilityConfirmDepositIcon,
  95. 28.0,
  96. 26.5,
  97. S.current.on_hold,
  98. "\$100.00",
  99. null,
  100. null,
  101. ),
  102. ],
  103. ),
  104. ),
  105. );
  106. }
  107. Widget _buildHeaderWidget(BuildContext context, WidgetRef ref) {
  108. return Container(
  109. width: double.infinity,
  110. color: context.appColors.whiteBG,
  111. margin: const EdgeInsets.only(bottom: 7.5),
  112. child: Column(
  113. children: [
  114. //成功图片
  115. const MyAssetImage(
  116. Assets.facilityPaymentSuccessIcon,
  117. width: 54,
  118. height: 54,
  119. ).marginOnly(top: 11, bottom: 13),
  120. //支付成功
  121. MyTextView(
  122. S.current.booking_successful,
  123. fontSize: 18,
  124. marginBottom: 3,
  125. isFontMedium: true,
  126. textColor: context.appColors.textPrimary,
  127. ),
  128. MyTextView(
  129. S.current.have_fun,
  130. fontSize: 18,
  131. marginBottom: 19,
  132. isFontMedium: true,
  133. textColor: context.appColors.textPrimary,
  134. ),
  135. //支付金额
  136. MyTextView(
  137. S.current.fee_paid,
  138. fontSize: 15,
  139. isFontRegular: true,
  140. textColor: context.appColors.textBlack,
  141. ),
  142. MyTextView(
  143. "\$10.80",
  144. fontSize: 15,
  145. isFontRegular: true,
  146. textColor: context.appColors.textPrimary,
  147. ),
  148. //付款类型与时间
  149. Row(
  150. mainAxisSize: MainAxisSize.min,
  151. children: [
  152. MyTextView(
  153. "Master card ending",
  154. fontSize: 15,
  155. isFontRegular: true,
  156. textColor: context.appColors.textBlack,
  157. ),
  158. MyTextView(
  159. "9423",
  160. fontSize: 15,
  161. isFontMedium: true,
  162. textColor: context.appColors.textBlack,
  163. ),
  164. ],
  165. ).marginOnly(top: 12),
  166. Row(
  167. mainAxisSize: MainAxisSize.min,
  168. children: [
  169. MyTextView(
  170. S.current.paid_on,
  171. fontSize: 15,
  172. isFontRegular: true,
  173. textColor: context.appColors.textBlack,
  174. ),
  175. MyTextView(
  176. "24 Oct 2023 at 02:19 PM",
  177. fontSize: 15,
  178. isFontMedium: true,
  179. textColor: context.appColors.textBlack,
  180. ),
  181. ],
  182. ).marginOnly(top: 5),
  183. Divider(height: 0.5, color: context.appColors.dividerDefault).marginOnly(top: 14, bottom: 14),
  184. //押金
  185. MyTextView(
  186. S.current.deposit_released_caps,
  187. fontSize: 15,
  188. isFontRegular: true,
  189. textColor: context.appColors.textBlack,
  190. ),
  191. MyTextView(
  192. "\$100.00",
  193. fontSize: 15,
  194. marginTop: 5,
  195. isFontRegular: true,
  196. textColor: context.appColors.textPrimary,
  197. ),
  198. const SizedBox(height: 23),
  199. ],
  200. ),
  201. );
  202. }
  203. //Item的列表
  204. Widget _buildDetailItem(
  205. BuildContext context,
  206. WidgetRef ref,
  207. String title,
  208. String iconPath,
  209. double iconWidth,
  210. double iconHeight,
  211. String line1Txt,
  212. String? line1Content,
  213. String? line2Txt,
  214. String? line2Content,
  215. ) {
  216. return Container(
  217. width: double.infinity,
  218. height: 92.5,
  219. padding: const EdgeInsets.only(left: 20, right: 20),
  220. margin: const EdgeInsets.only(left: 15, right: 15, top: 7.5, bottom: 7.5),
  221. decoration: BoxDecoration(
  222. color: context.appColors.whiteBG,
  223. borderRadius: BorderRadius.circular(6.0), // 圆角
  224. boxShadow: [
  225. BoxShadow(
  226. color: const Color(0xFFB8BFD9).withOpacity(0.3), // 阴影颜色
  227. offset: const Offset(0, 3), // 阴影的偏移量
  228. blurRadius: 8.0, // 模糊半径
  229. spreadRadius: 3.0, // 扩散半径
  230. ),
  231. ],
  232. ),
  233. child: Center(
  234. child: Column(
  235. crossAxisAlignment: CrossAxisAlignment.start,
  236. mainAxisSize: MainAxisSize.min,
  237. children: [
  238. MyTextView(
  239. title,
  240. textColor: context.appColors.textBlack,
  241. fontSize: 16,
  242. marginBottom: 7,
  243. isFontMedium: true,
  244. ),
  245. Row(
  246. mainAxisSize: MainAxisSize.max,
  247. children: [
  248. MyAssetImage(
  249. iconPath,
  250. width: iconWidth,
  251. height: iconHeight,
  252. ).marginOnly(right: 15),
  253. Column(
  254. mainAxisSize: MainAxisSize.min,
  255. children: [
  256. Row(
  257. children: [
  258. MyTextView(
  259. line1Txt,
  260. textColor: context.appColors.textBlack,
  261. fontSize: 14,
  262. isFontRegular: true,
  263. ).expanded(),
  264. MyTextView(
  265. line1Content ?? "",
  266. textColor: context.appColors.textBlack,
  267. fontSize: 14,
  268. isFontRegular: true,
  269. ),
  270. ],
  271. ),
  272. Visibility(
  273. visible: line2Txt != null,
  274. child: Row(
  275. children: [
  276. MyTextView(
  277. line2Txt ?? "",
  278. textColor: context.appColors.textBlack,
  279. fontSize: 14,
  280. isFontRegular: true,
  281. ).expanded(),
  282. MyTextView(
  283. line2Content ?? "",
  284. textColor: context.appColors.textBlack,
  285. fontSize: 14,
  286. isFontRegular: true,
  287. ),
  288. ],
  289. ).marginOnly(top: 6),
  290. ),
  291. ],
  292. ).expanded(),
  293. ],
  294. ),
  295. ],
  296. ),
  297. ),
  298. );
  299. }
  300. }