123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import 'package:cs_resources/generated/assets.dart';
- import 'package:cs_resources/generated/l10n.dart';
- 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:widgets/ext/ex_widget.dart';
- import 'package:widgets/my_appbar.dart';
- import 'package:widgets/my_load_image.dart';
- import 'package:widgets/my_text_view.dart';
- import '../../router/page/facility_page_router.dart';
- import 'facility_view_model.dart';
- @RoutePage()
- class FacilityPage extends HookConsumerWidget {
- const FacilityPage({Key? key}) : super(key: key);
- //启动当前页面
- static void startInstance({BuildContext? context}) {
- if (context != null) {
- context.router.push(const FacilityPageRoute());
- } else {
- appRouter.push(const FacilityPageRoute());
- }
- }
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final viewModel = ref.read(facilityViewModelProvider.notifier);
- return Scaffold(
- appBar: MyAppBar.appBar(
- context,
- S.current.facility,
- backgroundColor: context.appColors.whiteBG,
- ),
- backgroundColor: context.appColors.backgroundDark,
- body: AutoTabsRouter.pageView(
- routes: const [
- FacilityBookPageRoute(),
- FacilityActivePageRoute(),
- FacilityDepositPageRoute(),
- FacilityHistoryPageRoute(),
- ],
- builder: (context, child, pageController) {
- final tabsRouter = AutoTabsRouter.of(context);
- return Column(
- children: [
- Container(
- color: context.appColors.whiteBG,
- height: 120,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- _buildFeedbackCategory(
- context,
- Assets.facilityBookIcon,
- 48.5,
- 40,
- S.current.book,
- tabsRouter.activeIndex == 0,
- ).onTap(
- () {
- tabsRouter.setActiveIndex(0);
- },
- ),
- _buildFeedbackCategory(
- context,
- Assets.facilityActiveIcon,
- 39,
- 47.5,
- S.current.facility_active,
- tabsRouter.activeIndex == 1,
- ).onTap(
- () {
- tabsRouter.setActiveIndex(1);
- },
- ),
- _buildFeedbackCategory(
- context,
- Assets.facilityDepositIcon,
- 35.5,
- 41.5,
- S.current.deposit,
- tabsRouter.activeIndex == 2,
- ).onTap(
- () {
- tabsRouter.setActiveIndex(2);
- },
- ),
- _buildFeedbackCategory(
- context,
- Assets.mainLatestPublish,
- 47.5,
- 45,
- S.current.history,
- tabsRouter.activeIndex == 3,
- ).onTap(
- () {
- tabsRouter.setActiveIndex(3);
- },
- ),
- ],
- ),
- ),
- Expanded(
- child: child,
- ),
- ],
- );
- },
- ),
- );
- }
- //顶部的Tab布局
- Widget _buildFeedbackCategory(BuildContext context, String iconPath, double iconWidth, double iconHeight, String title, bool isSelected) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 70,
- height: 70,
- decoration: BoxDecoration(
- color: context.appColors.lightBlueBg, // 设置圆形背景颜色
- shape: BoxShape.circle, // 设置为圆形
- boxShadow: isSelected
- ? [
- BoxShadow(
- color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
- blurRadius: 5, // 设置模糊半径
- spreadRadius: 0.05, // 控制阴影扩散
- offset: const Offset(0, 4), // 设置阴影偏移量
- ),
- ]
- : [], // 未选中时无阴影,
- ),
- child: Center(
- child: MyAssetImage(iconPath, width: iconWidth, height: iconHeight),
- ),
- ),
- const SizedBox(height: 7),
- MyTextView(
- title,
- fontSize: 15,
- isFontMedium: true,
- textColor: isSelected ? context.appColors.tabTextSelectedDefault : context.appColors.tabTextUnSelectedDefault,
- ),
- ],
- );
- }
- }
|