facility_page.dart 5.6 KB

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