payment_page.dart 5.2 KB

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