property_page.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 Container(
  30. color: Colors.white,
  31. child: Center(
  32. child: Row(
  33. mainAxisAlignment: MainAxisAlignment.center,
  34. crossAxisAlignment: CrossAxisAlignment.center,
  35. children: List.generate(topSectionsData.length, (index) {
  36. final item = topSectionsData[index];
  37. return Flexible(
  38. flex: 1,
  39. child: Column(
  40. children: [
  41. Container(
  42. width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
  43. height: 70,
  44. decoration: BoxDecoration(
  45. // color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
  46. shape: BoxShape.circle, // 设置为圆形
  47. boxShadow: tabsRouter.activeIndex == index ? [
  48. BoxShadow(
  49. color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
  50. blurRadius: 5, // 设置模糊半径
  51. spreadRadius: 0.05, // 控制阴影扩散
  52. offset: const Offset(0, 4), // 设置阴影偏移量
  53. ),
  54. ] : [],// 未选中时无阴影,
  55. ),
  56. child: MyAssetImage(
  57. item['icon'],
  58. width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
  59. height: 70,
  60. ).onTap(() {
  61. tabsRouter.setActiveIndex(index);
  62. },
  63. type: ClickType.throttle,
  64. ),
  65. ),
  66. SizedBox.fromSize(size: const Size(0, 9)),
  67. MyTextView(
  68. item['title'],
  69. maxLines: 1, // 设置最大行数为2
  70. isTextEllipsis: true, // 超出部分用省略号表示
  71. fontSize: 13,
  72. textColor: currentTabIdx == index ? ColorUtils.string2Color('#4161D0'):Colors.black,
  73. isFontMedium: true,
  74. ),
  75. ],
  76. ),
  77. ).marginOnly(left: 18, right: 18, top: 10, bottom: 10);
  78. }),
  79. ),
  80. ),
  81. );
  82. }
  83. @override
  84. Widget build(BuildContext context, WidgetRef ref) {
  85. final _vm = ref.read(propertyVmProvider.notifier);
  86. return Scaffold(
  87. appBar: MyAppBar.appBar(
  88. context,
  89. "Property",
  90. backgroundColor: context.appColors.whiteBG,
  91. ),
  92. body: AutoTabsRouter.pageView(
  93. routes: const [
  94. PropertyIoanPageRoute(),
  95. PropertyNewsPageRoute(),
  96. PropertySalePageRoute(),
  97. PropertyRentPageRoute(),
  98. ],
  99. builder: (context, child, pageController) {
  100. final tabsRouter = AutoTabsRouter.of(context);
  101. return Column(
  102. children: [
  103. _buildTopSection(context, ref, _vm, tabsRouter),
  104. Expanded(
  105. child: child,
  106. ),
  107. ],
  108. );
  109. },
  110. )
  111. );
  112. }
  113. }