facility_page.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_view_model.dart';
  14. @RoutePage()
  15. class FacilityPage extends HookConsumerWidget {
  16. const FacilityPage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const FacilityPageRoute());
  21. } else {
  22. appRouter.push(const FacilityPageRoute());
  23. }
  24. }
  25. @override
  26. Widget build(BuildContext context, WidgetRef ref) {
  27. final viewModel = ref.read(facilityViewModelProvider.notifier);
  28. return Scaffold(
  29. appBar: MyAppBar.appBar(
  30. context,
  31. S.current.facility,
  32. backgroundColor: context.appColors.whiteBG,
  33. ),
  34. backgroundColor: context.appColors.backgroundDark,
  35. body: AutoTabsRouter.pageView(
  36. routes: const [
  37. FacilityBookPageRoute(),
  38. FacilityActivePageRoute(),
  39. FacilityDepositPageRoute(),
  40. FacilityHistoryPageRoute(),
  41. ],
  42. builder: (context, child, pageController) {
  43. final tabsRouter = AutoTabsRouter.of(context);
  44. return Column(
  45. children: [
  46. Container(
  47. color: context.appColors.whiteBG,
  48. height: 120,
  49. child: Row(
  50. mainAxisAlignment: MainAxisAlignment.spaceAround,
  51. children: [
  52. _buildCategory(
  53. context,
  54. Assets.facilityBookIcon,
  55. 48.5,
  56. 40,
  57. S.current.book,
  58. tabsRouter.activeIndex == 0,
  59. ).onTap(
  60. () {
  61. tabsRouter.setActiveIndex(0);
  62. },
  63. ),
  64. _buildCategory(
  65. context,
  66. Assets.facilityActiveIcon,
  67. 39,
  68. 47.5,
  69. S.current.facility_active,
  70. tabsRouter.activeIndex == 1,
  71. ).onTap(
  72. () {
  73. tabsRouter.setActiveIndex(1);
  74. },
  75. ),
  76. _buildCategory(
  77. context,
  78. Assets.facilityDepositIcon,
  79. 35.5,
  80. 41.5,
  81. S.current.deposit,
  82. tabsRouter.activeIndex == 2,
  83. ).onTap(
  84. () {
  85. tabsRouter.setActiveIndex(2);
  86. },
  87. ),
  88. _buildCategory(
  89. context,
  90. Assets.mainLatestPublish,
  91. 47.5,
  92. 45,
  93. S.current.history,
  94. tabsRouter.activeIndex == 3,
  95. ).onTap(
  96. () {
  97. tabsRouter.setActiveIndex(3);
  98. },
  99. ),
  100. ],
  101. ),
  102. ),
  103. Expanded(
  104. child: child,
  105. ),
  106. ],
  107. );
  108. },
  109. ),
  110. );
  111. }
  112. //顶部的Tab布局
  113. Widget _buildCategory(BuildContext context, String iconPath, double iconWidth, double iconHeight, String title, bool isSelected) {
  114. return Column(
  115. mainAxisAlignment: MainAxisAlignment.center,
  116. crossAxisAlignment: CrossAxisAlignment.center,
  117. children: <Widget>[
  118. Container(
  119. width: 70,
  120. height: 70,
  121. decoration: BoxDecoration(
  122. color: context.appColors.lightBlueBg, // 设置圆形背景颜色
  123. shape: BoxShape.circle, // 设置为圆形
  124. boxShadow: isSelected
  125. ? [
  126. BoxShadow(
  127. color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
  128. blurRadius: 5, // 设置模糊半径
  129. spreadRadius: 0.05, // 控制阴影扩散
  130. offset: const Offset(0, 4), // 设置阴影偏移量
  131. ),
  132. ]
  133. : [], // 未选中时无阴影,
  134. ),
  135. child: Center(
  136. child: MyAssetImage(iconPath, width: iconWidth, height: iconHeight),
  137. ),
  138. ),
  139. const SizedBox(height: 7),
  140. MyTextView(
  141. title,
  142. fontSize: 15,
  143. isFontMedium: true,
  144. textColor: isSelected ? context.appColors.tabTextSelectedDefault : context.appColors.tabTextUnSelectedDefault,
  145. ),
  146. ],
  147. );
  148. }
  149. }