import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; class MainWrapper extends StatelessWidget { final StatefulNavigationShell navigationShell; const MainWrapper({super.key, required this.navigationShell}); @override Widget build(BuildContext context) { return Scaffold( extendBody: true, // 必须开启,让内容流过导航栏下方 body: navigationShell, bottomNavigationBar: Container( margin: const EdgeInsets.fromLTRB(20, 0, 20, 32), // 稍微调高底部间距 decoration: BoxDecoration( borderRadius: BorderRadius.circular(32), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.12), // 强化阴影,增加悬浮感 blurRadius: 30, offset: const Offset(0, 10), ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(32), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16), // 增加模糊半径 child: Container( decoration: BoxDecoration( // 降低白色透明度到 0.4,减少“灰蒙蒙”的白雾感,让背景颜色更亮地透出来 color: Colors.white.withOpacity(0.4), borderRadius: BorderRadius.circular(32), border: Border.all( // 使用极细的深色半透明边框勾勒轮廓 color: Colors.black.withOpacity(0.08), width: 0.5, ), ), child: SafeArea( top: false, child: Padding( padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 8, ), child: GNav( rippleColor: Colors.transparent, hoverColor: Colors.transparent, gap: 10, // 【关键修改】选中状态:纯黑背景 + 纯白图标/文字 activeColor: Colors.white, tabBackgroundColor: Colors.black, // 未选中状态:深黑色 color: Colors.black87, iconSize: 24, padding: const EdgeInsets.symmetric( horizontal: 18, vertical: 10, ), duration: const Duration(milliseconds: 300), selectedIndex: navigationShell.currentIndex, onTabChange: (index) { navigationShell.goBranch(index); }, tabs: const [ GButton(icon: Icons.grid_view_rounded, text: '状态'), GButton(icon: Icons.auto_awesome_rounded, text: 'AI'), GButton(icon: Icons.person_rounded, text: '我的'), ], ), ), ), ), ), ), ), ); } }