diff --git a/lib/screens/activity_list_screen.dart b/lib/screens/activity_list_screen.dart index f87fc27..f7bf091 100644 --- a/lib/screens/activity_list_screen.dart +++ b/lib/screens/activity_list_screen.dart @@ -1,10 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; -import 'publish_screen.dart'; import 'activity_detail_screen.dart'; -import 'friends_screen.dart'; -import 'messages_screen.dart'; -import 'profile_screen.dart'; class ActivityListScreen extends StatefulWidget { @override @@ -12,9 +8,6 @@ class ActivityListScreen extends StatefulWidget { } class _ActivityListScreenState extends State { - int _selectedIndex = 0; - bool _showFriendsOverlay = false; - final _feedKey = GlobalKey(); String? _selectedTime; // 模拟活动数据 @@ -83,98 +76,31 @@ class _ActivityListScreenState extends State { await Future.delayed(const Duration(milliseconds: 200)); } - void _onItemTapped(int index) { - if (index == 2) { - // 中间按钮 - 跳转到发布页面 - Navigator.push( - context, - MaterialPageRoute(builder: (context) => PublishScreen()), - ); - return; - } - - if (index == 1) { - setState(() { - _showFriendsOverlay = !_showFriendsOverlay; - if (_showFriendsOverlay) { - _selectedIndex = 0; - } - }); - return; - } - - if (index == 0 && _selectedIndex == 0 && !_showFriendsOverlay) { - _feedKey.currentState?.show(); - return; - } - - if (_selectedIndex != index || _showFriendsOverlay) { - setState(() { - _selectedIndex = index; - _showFriendsOverlay = false; - }); - } - } - @override Widget build(BuildContext context) { - // When showing messages or profile, use their own Scaffold directly - if (_selectedIndex == 3 || _selectedIndex == 4) { - return Scaffold( - backgroundColor: const Color(0xFFFFF8F0), - body: _buildBodyWithFriendsOverlay(), - bottomNavigationBar: _buildBottomNavigationBar(), - ); - } return Scaffold( backgroundColor: const Color(0xFFFFF8F0), - appBar: _showFriendsOverlay - ? null - : AppBar( - title: Text('伴享', style: TextStyle(fontWeight: FontWeight.bold)), - centerTitle: true, - actions: [ - IconButton( - icon: Icon(Icons.search), - onPressed: () {}, - ), - IconButton( - icon: Icon(Icons.notifications_none), - onPressed: () {}, - ), - ], - ), - body: _buildBodyWithFriendsOverlay(), - bottomNavigationBar: _buildBottomNavigationBar(), - floatingActionButton: _buildFloatingActionButton(), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - ); - } - - Widget _buildBody() { - switch (_selectedIndex) { - case 3: - return const MessagesScreen(); - case 4: - return const ProfileScreen(); - default: - return _buildFeed(); - } - } - - Widget _buildBodyWithFriendsOverlay() { - return Stack( - children: [ - _buildBody(), - if (_showFriendsOverlay) const Positioned.fill(child: FriendsScreen()), - ], + appBar: AppBar( + title: Text('伴享', style: TextStyle(fontWeight: FontWeight.bold)), + centerTitle: true, + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () {}, + ), + IconButton( + icon: Icon(Icons.notifications_none), + onPressed: () {}, + ), + ], + ), + body: _buildFeed(), ); } Widget _buildFeed() { final filteredActivities = _getFilteredActivities(); return RefreshIndicator( - key: _feedKey, onRefresh: _refreshActivities, child: ListView( physics: const AlwaysScrollableScrollPhysics(), @@ -393,91 +319,4 @@ class _ActivityListScreenState extends State { ); } - Widget _buildBottomNavigationBar() { - return Container( - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.05), - blurRadius: 10, - offset: Offset(0, -2), - ), - ], - ), - child: SafeArea( - child: Container( - height: 60, - child: Row( - children: [ - _buildNavItem(0, Icons.home, '首页'), - _buildNavItem(1, Icons.people, '好友'), - SizedBox(width: 60), // 中间按钮占位 - _buildNavItem(3, Icons.message, '消息'), - _buildNavItem(4, Icons.person, '我的'), - ], - ), - ), - ), - ); - } - - Widget _buildNavItem(int index, IconData icon, String label) { - final isSelected = index == 1 ? _showFriendsOverlay : _selectedIndex == index; - return Expanded( - child: GestureDetector( - onTap: () => _onItemTapped(index), - behavior: HitTestBehavior.opaque, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - icon, - color: isSelected ? Color(0xFFFF6B35) : Color(0xFF999999), - size: 24, - ), - SizedBox(height: 4), - Text( - label, - style: TextStyle( - fontSize: 11, - color: isSelected ? Color(0xFFFF6B35) : Color(0xFF999999), - ), - ), - ], - ), - ), - ); - } - - Widget _buildFloatingActionButton() { - return Container( - width: 56, - height: 56, - margin: EdgeInsets.only(top: 30), - decoration: BoxDecoration( - shape: BoxShape.circle, - gradient: LinearGradient( - colors: [Color(0xFFFF6B35), Color(0xFFFFB84D)], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - boxShadow: [ - BoxShadow( - color: Color(0xFFFF6B35).withOpacity(0.4), - blurRadius: 12, - offset: Offset(0, 4), - ), - ], - ), - child: Material( - color: Colors.transparent, - child: InkWell( - onTap: () => _onItemTapped(2), - customBorder: CircleBorder(), - child: Icon(Icons.add, color: Colors.white, size: 28), - ), - ), - ); - } } diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index 9c9bfcf..26c3209 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'home_screen.dart'; +import 'activity_list_screen.dart'; +import 'friends_screen.dart'; import 'services_screen.dart'; import 'ai_chat_screen.dart'; import 'messages_screen.dart'; @@ -14,9 +15,10 @@ class MainScreen extends StatefulWidget { class _MainScreenState extends State { int _currentIndex = 0; - + final _screens = [ - HomeScreen(), + ActivityListScreen(), + FriendsScreen(), ServicesScreen(), AiChatScreen(), MessagesScreen(), @@ -28,12 +30,13 @@ class _MainScreenState extends State { return Scaffold( body: IndexedStack(index: _currentIndex, children: _screens), floatingActionButton: _buildGlobalFab(), - floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, + 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: '消息'), @@ -43,22 +46,39 @@ class _MainScreenState extends State { ); } - Widget? _buildGlobalFab() { - if (_currentIndex == 0) { - return null; - } - - return FloatingActionButton.extended( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (_) => CreateActivityScreen()), - ); - }, - icon: const Icon(Icons.add), - label: const Text('发起活动', style: TextStyle(fontSize: 16)), - backgroundColor: const Color(0xFF1976D2), - foregroundColor: Colors.white, + 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), + ), + ), ); } } diff --git a/releases/banxiang-v1.2.0-navfix.apk b/releases/banxiang-v1.2.0-navfix.apk new file mode 100644 index 0000000..d877cfb Binary files /dev/null and b/releases/banxiang-v1.2.0-navfix.apk differ