123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import 'package:cs_resources/theme/app_colors_theme.dart';
- import 'package:flutter/material.dart';
- import 'package:auto_route/auto_route.dart';
- import 'package:hooks_riverpod/hooks_riverpod.dart';
- import 'package:router/ext/auto_router_extensions.dart';
- import 'package:shared/utils/color_utils.dart';
- import 'package:shared/utils/log_utils.dart';
- import 'package:widgets/my_load_image.dart';
- import 'package:widgets/ext/ex_widget.dart';
- import 'package:widgets/my_text_view.dart';
- import 'package:widgets/my_appbar.dart';
- import '../../../router/page/property_page_router.dart';
- import '../vm/property_vm.dart';
- @RoutePage()
- class PropertyPage extends HookConsumerWidget {
- const PropertyPage({Key? key}) : super(key: key);
- //启动当前页面
- static void startInstance({BuildContext? context}) {
- if (context != null) {
- context.router.push(const PropertyPageRoute());
- } else {
- appRouter.push(const PropertyPageRoute());
- }
- }
- // 顶部tab 切换
- Widget _buildTopSection(BuildContext context, WidgetRef ref, _vm, tabsRouter) {
- final topSectionsData = _vm.topSectionsData;
- final currentTabIdx = tabsRouter.activeIndex;
- return Container(
- color: Colors.white,
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: List.generate(topSectionsData.length, (index) {
- final item = topSectionsData[index];
- return Flexible(
- flex: 1,
- child: Column(
- children: [
- Container(
- width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
- height: 70,
- decoration: BoxDecoration(
- // color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
- shape: BoxShape.circle, // 设置为圆形
- boxShadow: tabsRouter.activeIndex == index ? [
- BoxShadow(
- color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
- blurRadius: 5, // 设置模糊半径
- spreadRadius: 0.05, // 控制阴影扩散
- offset: const Offset(0, 4), // 设置阴影偏移量
- ),
- ] : [],// 未选中时无阴影,
- ),
- child: MyAssetImage(
- item['icon'],
- width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
- height: 70,
- ).onTap(() {
- tabsRouter.setActiveIndex(index);
- },
- type: ClickType.throttle,
- ),
- ),
- SizedBox.fromSize(size: const Size(0, 9)),
- MyTextView(
- item['title'],
- maxLines: 1, // 设置最大行数为2
- isTextEllipsis: true, // 超出部分用省略号表示
- fontSize: 13,
- textColor: currentTabIdx == index ? ColorUtils.string2Color('#4161D0'):Colors.black,
- isFontMedium: true,
- ),
- ],
- ),
- ).marginOnly(left: 18, right: 18, top: 10, bottom: 10);
- }),
- ),
- ),
- );
- }
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final _vm = ref.read(propertyVmProvider.notifier);
- return Scaffold(
- appBar: MyAppBar.appBar(
- context,
- "Property",
- backgroundColor: context.appColors.whiteBG,
- ),
- body: AutoTabsRouter.pageView(
- routes: const [
- PropertyIoanPageRoute(),
- PropertyNewsPageRoute(),
- PropertySalePageRoute(),
- PropertyRentPageRoute(),
- ],
- builder: (context, child, pageController) {
- final tabsRouter = AutoTabsRouter.of(context);
- return Column(
- children: [
- _buildTopSection(context, ref, _vm, tabsRouter),
- Expanded(
- child: child,
- ),
- ],
- );
- },
- )
- );
- }
- }
|