import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart'; class AppShell extends StatelessWidget { final Widget child; const AppShell({super.key, required this.child}); @override Widget build(BuildContext context) { final location = GoRouterState.of(context).uri.toString(); return Scaffold( body: child, bottomNavigationBar: TDBottomTabBar( TDBottomTabBarBasicType.iconText, currentIndex: _currentIndex(location), navigationTabs: [ TDBottomTabBarTabConfig( selectedIcon: const Icon(Icons.notifications, color: Color(0xFF00ABF3)), unselectedIcon: const Icon(Icons.notifications_outlined, color: Color(0xFF999999)), tabText: '消息', onTap: () => context.go('/messages'), ), TDBottomTabBarTabConfig( selectedIcon: const Icon(Icons.dashboard, color: Color(0xFF00ABF3)), unselectedIcon: const Icon(Icons.dashboard_outlined, color: Color(0xFF999999)), tabText: '工作台', onTap: () => context.go('/'), ), TDBottomTabBarTabConfig( selectedIcon: const Icon(Icons.person, color: Color(0xFF00ABF3)), unselectedIcon: const Icon(Icons.person_outline, color: Color(0xFF999999)), tabText: '我的', onTap: () => context.go('/profile'), ), ], ), ); } int _currentIndex(String location) { if (location.startsWith('/messages')) return 0; if (location.startsWith('/profile')) return 2; return 1; } }