import 'package:flutter/material.dart'; import 'activity_list_screen.dart'; import 'friends_screen.dart'; import 'services_screen.dart'; import 'ai_chat_screen.dart'; import 'messages_screen.dart'; import 'profile_screen.dart'; import 'create_activity_screen.dart'; class MainScreen extends StatefulWidget { const MainScreen({super.key}); @override State createState() => _MainScreenState(); } class _MainScreenState extends State { int _currentIndex = 0; final _screens = [ ActivityListScreen(), FriendsScreen(), ServicesScreen(), AiChatScreen(), MessagesScreen(), ProfileScreen(), ]; @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack(index: _currentIndex, children: _screens), floatingActionButton: _buildGlobalFab(), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, onTap: (i) => setState(() => _currentIndex = i), items: const [ BottomNavigationBarItem(icon: Icon(Icons.home_outlined), activeIcon: Icon(Icons.home), label: '首页'), BottomNavigationBarItem(icon: Icon(Icons.people_outline), activeIcon: Icon(Icons.people), label: '好友'), BottomNavigationBarItem(icon: Icon(Icons.grid_view_outlined), activeIcon: Icon(Icons.grid_view), label: '服务'), BottomNavigationBarItem(icon: Icon(Icons.smart_toy_outlined), activeIcon: Icon(Icons.smart_toy), label: 'AI管家'), BottomNavigationBarItem(icon: Icon(Icons.message_outlined), activeIcon: Icon(Icons.message), label: '消息'), BottomNavigationBarItem(icon: Icon(Icons.person_outline), activeIcon: Icon(Icons.person), label: '我的'), ], ), ); } Widget _buildGlobalFab() { return Container( width: 56, height: 56, margin: const EdgeInsets.only(top: 30), decoration: BoxDecoration( shape: BoxShape.circle, gradient: const LinearGradient( colors: [Color(0xFFFF6B35), Color(0xFFFFB84D)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( color: const Color(0xFFFF6B35).withOpacity(0.35), blurRadius: 12, offset: const Offset(0, 4), ), ], ), child: Material( color: Colors.transparent, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (_) => CreateActivityScreen()), ); }, customBorder: const CircleBorder(), child: const Icon(Icons.add, color: Colors.white, size: 28), ), ), ); } }