property_page.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import 'package:cs_resources/theme/app_colors_theme.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:auto_route/auto_route.dart';
  4. import 'package:hooks_riverpod/hooks_riverpod.dart';
  5. import 'package:router/ext/auto_router_extensions.dart';
  6. import 'package:shared/utils/color_utils.dart';
  7. import 'package:shared/utils/log_utils.dart';
  8. import 'package:widgets/my_load_image.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_text_view.dart';
  11. import 'package:widgets/my_appbar.dart';
  12. import '../../../router/page/property_page_router.dart';
  13. import '../vm/property_vm.dart';
  14. @RoutePage()
  15. class PropertyPage extends HookConsumerWidget {
  16. const PropertyPage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const PropertyPageRoute());
  21. } else {
  22. appRouter.push(const PropertyPageRoute());
  23. }
  24. }
  25. // 顶部tab 切换
  26. Widget _buildTopSection(BuildContext context, WidgetRef ref, _vm, tabsRouter) {
  27. final topSectionsData = _vm.topSectionsData;
  28. final currentTabIdx = tabsRouter.activeIndex;
  29. return Center(
  30. child: Container(
  31. color: context.appColors.whiteBG,
  32. width: MediaQuery.of(context).size.width,
  33. padding: const EdgeInsets.only(top: 25, bottom: 25),
  34. child: Row(
  35. mainAxisAlignment: MainAxisAlignment.center,
  36. crossAxisAlignment: CrossAxisAlignment.center,
  37. mainAxisSize: MainAxisSize.max,
  38. children: List.generate(topSectionsData.length, (index) {
  39. final item = topSectionsData[index];
  40. return Expanded(
  41. child: Column(
  42. mainAxisSize: MainAxisSize.max,
  43. mainAxisAlignment: MainAxisAlignment.spaceAround,
  44. children: [
  45. Container(
  46. width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
  47. height: 70,
  48. decoration: BoxDecoration(
  49. // color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
  50. shape: BoxShape.circle, // 设置为圆形
  51. boxShadow: tabsRouter.activeIndex == index ? [
  52. BoxShadow(
  53. color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
  54. blurRadius: 5, // 设置模糊半径
  55. spreadRadius: 0.05, // 控制阴影扩散
  56. offset: const Offset(0, 4), // 设置阴影偏移量
  57. ),
  58. ] : [],// 未选中时无阴影,
  59. ),
  60. child: MyAssetImage(
  61. item['icon'],
  62. width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
  63. height: 70,
  64. ).onTap(() {
  65. tabsRouter.setActiveIndex(index);
  66. },
  67. type: ClickType.throttle,
  68. ),
  69. ),
  70. SizedBox.fromSize(size: const Size(0, 9)),
  71. MyTextView(
  72. item['title'],
  73. maxLines: 1, // 设置最大行数为2
  74. isTextEllipsis: true, // 超出部分用省略号表示
  75. fontSize: 13,
  76. textColor: currentTabIdx == index ? ColorUtils.string2Color('#4161D0'):Colors.black,
  77. isFontMedium: true,
  78. ),
  79. ],
  80. ),
  81. );
  82. }),
  83. ),
  84. ),
  85. );
  86. }
  87. @override
  88. Widget build(BuildContext context, WidgetRef ref) {
  89. final _vm = ref.read(propertyVmProvider.notifier);
  90. return Scaffold(
  91. appBar: MyAppBar.appBar(
  92. context,
  93. "Property",
  94. backgroundColor: context.appColors.whiteBG,
  95. ),
  96. body: AutoTabsRouter.pageView(
  97. routes: const [
  98. PropertyIoanPageRoute(),
  99. PropertyNewsPageRoute(),
  100. PropertySalePageRoute(),
  101. PropertyRentPageRoute(),
  102. ],
  103. builder: (context, child, pageController) {
  104. final tabsRouter = AutoTabsRouter.of(context);
  105. return Column(
  106. children: [
  107. _buildTopSection(context, ref, _vm, tabsRouter),
  108. Expanded(
  109. child: child,
  110. ),
  111. ],
  112. );
  113. },
  114. )
  115. );
  116. }
  117. }