visitor_page.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:plugin_basic/basic_export.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/main_page_router.dart';
  14. import 'visitor_view_model.dart';
  15. @RoutePage()
  16. class VisitorPage extends HookConsumerWidget {
  17. const VisitorPage({Key? key}) : super(key: key);
  18. @override
  19. Widget build(BuildContext context, WidgetRef ref) {
  20. final viewModel = ref.watch(visitorViewModelProvider.notifier);
  21. return Scaffold(
  22. appBar: MyAppBar.appBar(
  23. context,
  24. S.current.visitor,
  25. showBackButton: false,
  26. backgroundColor: context.appColors.whiteBG,
  27. ),
  28. backgroundColor: context.appColors.backgroundDark,
  29. body: AutoTabsRouter.pageView(
  30. routes: const [
  31. VisitorNowPageRoute(),
  32. VisitorActivePageRoute(),
  33. VisitorHistoryPageRoute(),
  34. ],
  35. builder: (context, child, pageController) {
  36. final tabsRouter = AutoTabsRouter.of(context);
  37. return Column(
  38. children: [
  39. Container(
  40. color: context.appColors.whiteBG,
  41. height: 120,
  42. child: Row(
  43. mainAxisAlignment: MainAxisAlignment.spaceAround,
  44. children: [
  45. _buildVisitorCategory(
  46. context,
  47. Assets.mainVisitorNow,
  48. 54.5,
  49. 48,
  50. S.current.visitor_now,
  51. tabsRouter.activeIndex == 0,
  52. ).onTap(
  53. () {
  54. tabsRouter.setActiveIndex(0);
  55. },
  56. ),
  57. _buildVisitorCategory(
  58. context,
  59. Assets.mainVisitorActive,
  60. 36.5,
  61. 48,
  62. S.current.visitor_active,
  63. tabsRouter.activeIndex == 1,
  64. ).onTap(
  65. () {
  66. tabsRouter.setActiveIndex(1);
  67. },
  68. ),
  69. _buildVisitorCategory(
  70. context,
  71. Assets.mainVisitorHistory,
  72. 38,
  73. 45.5,
  74. S.current.history,
  75. tabsRouter.activeIndex == 2,
  76. ).onTap(
  77. () {
  78. tabsRouter.setActiveIndex(2);
  79. },
  80. ),
  81. ],
  82. ),
  83. ),
  84. Expanded(
  85. child: child,
  86. ),
  87. ],
  88. );
  89. },
  90. ),
  91. );
  92. }
  93. //顶部的Tab布局
  94. Widget _buildVisitorCategory(BuildContext context, String iconPath, double iconWidth, double iconHeight, String title, bool isSelected) {
  95. return Column(
  96. mainAxisAlignment: MainAxisAlignment.center,
  97. crossAxisAlignment: CrossAxisAlignment.center,
  98. children: <Widget>[
  99. Container(
  100. width: 70,
  101. height: 70,
  102. decoration: BoxDecoration(
  103. color: context.appColors.lightBlueBg, // 设置圆形背景颜色
  104. shape: BoxShape.circle, // 设置为圆形
  105. boxShadow: isSelected
  106. ? [
  107. BoxShadow(
  108. color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
  109. blurRadius: 5, // 设置模糊半径
  110. spreadRadius: 0.05, // 控制阴影扩散
  111. offset: const Offset(0, 4), // 设置阴影偏移量
  112. ),
  113. ]
  114. : [], // 未选中时无阴影,
  115. ),
  116. child: Center(
  117. child: MyAssetImage(iconPath, width: iconWidth, height: iconHeight),
  118. ),
  119. ),
  120. const SizedBox(height: 7),
  121. MyTextView(
  122. title,
  123. fontSize: 15,
  124. isFontMedium: true,
  125. textColor: isSelected ? context.appColors.tabTextSelectedDefault : context.appColors.tabTextUnSelectedDefault,
  126. ),
  127. ],
  128. );
  129. }
  130. }