payment_page.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import 'package:cpt_payment/modules/payment/payment_view_model.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:cs_resources/generated/l10n.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:cs_resources/theme/theme_config.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:auto_route/auto_route.dart';
  8. import 'package:flutter/services.dart';
  9. import 'package:hooks_riverpod/hooks_riverpod.dart';
  10. import 'package:router/ext/auto_router_extensions.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/my_appbar.dart';
  13. import 'package:widgets/my_load_image.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import '../../../router/page/payment_page_router.dart';
  16. @RoutePage()
  17. class PaymentPage extends HookConsumerWidget {
  18. const PaymentPage({Key? key}) : super(key: key);
  19. //启动当前页面
  20. static void startInstance({BuildContext? context}) {
  21. if (context != null) {
  22. context.router.push(const PaymentPageRoute());
  23. } else {
  24. appRouter.push(const PaymentPageRoute());
  25. }
  26. }
  27. @override
  28. Widget build(BuildContext context, WidgetRef ref) {
  29. final viewModel = ref.read(paymentViewModelProvider.notifier);
  30. return Scaffold(
  31. appBar: MyAppBar.appBar(
  32. context,
  33. S.current.facility,
  34. backgroundColor: context.appColors.whiteBG,
  35. ),
  36. backgroundColor: context.appColors.backgroundDark,
  37. body: AutoTabsRouter.pageView(
  38. routes: const [
  39. InfoPageRoute(),
  40. CondoPageRoute(),
  41. ManagePageRoute(),
  42. ],
  43. builder: (context, child, pageController) {
  44. final tabsRouter = AutoTabsRouter.of(context);
  45. return Column(
  46. children: [
  47. Container(
  48. color: context.appColors.whiteBG,
  49. height: 120,
  50. child: Row(
  51. mainAxisAlignment: MainAxisAlignment.spaceAround,
  52. children: [
  53. _buildCategory(
  54. context,
  55. Assets.paymentInfoIcon,
  56. 34,
  57. 41,
  58. "Info",
  59. tabsRouter.activeIndex == 0,
  60. ).onTap(
  61. () {
  62. tabsRouter.setActiveIndex(0);
  63. },
  64. ),
  65. _buildCategory(
  66. context,
  67. Assets.paymentCondoIcon,
  68. 48,
  69. 43,
  70. "Condo",
  71. tabsRouter.activeIndex == 1,
  72. ).onTap(
  73. () {
  74. tabsRouter.setActiveIndex(1);
  75. },
  76. ),
  77. _buildCategory(
  78. context,
  79. Assets.paymentManageIcon,
  80. 52,
  81. 46.5,
  82. "Manage",
  83. tabsRouter.activeIndex == 2,
  84. ).onTap(
  85. () {
  86. tabsRouter.setActiveIndex(2);
  87. },
  88. ),
  89. ],
  90. ),
  91. ),
  92. Expanded(
  93. child: child,
  94. ),
  95. ],
  96. );
  97. },
  98. ),
  99. );
  100. }
  101. //顶部的Tab布局
  102. Widget _buildCategory(BuildContext context, String iconPath, double iconWidth, double iconHeight, String title, bool isSelected) {
  103. return Column(
  104. mainAxisAlignment: MainAxisAlignment.center,
  105. crossAxisAlignment: CrossAxisAlignment.center,
  106. children: <Widget>[
  107. Container(
  108. width: 70,
  109. height: 70,
  110. decoration: BoxDecoration(
  111. color: context.appColors.lightBlueBg, // 设置圆形背景颜色
  112. shape: BoxShape.circle, // 设置为圆形
  113. boxShadow: isSelected
  114. ? [
  115. BoxShadow(
  116. color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
  117. blurRadius: 5, // 设置模糊半径
  118. spreadRadius: 0.05, // 控制阴影扩散
  119. offset: const Offset(0, 4), // 设置阴影偏移量
  120. ),
  121. ]
  122. : [], // 未选中时无阴影,
  123. ),
  124. child: Center(
  125. child: MyAssetImage(iconPath, width: iconWidth, height: iconHeight),
  126. ),
  127. ),
  128. const SizedBox(height: 7),
  129. MyTextView(
  130. title,
  131. fontSize: 15,
  132. isFontMedium: true,
  133. textColor: isSelected ? context.appColors.tabTextSelectedDefault : context.appColors.tabTextUnSelectedDefault,
  134. ),
  135. ],
  136. );
  137. }
  138. }