facility_page.dart 5.5 KB

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