fix: 修复底部导航栏被覆盖和FAB消失问题
This commit is contained in:
parent
f4c5369792
commit
c87a6756db
@ -13,6 +13,7 @@ class ActivityListScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _ActivityListScreenState extends State<ActivityListScreen> {
|
class _ActivityListScreenState extends State<ActivityListScreen> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
bool _showFriendsOverlay = false;
|
||||||
final _feedKey = GlobalKey<RefreshIndicatorState>();
|
final _feedKey = GlobalKey<RefreshIndicatorState>();
|
||||||
String? _selectedTime;
|
String? _selectedTime;
|
||||||
|
|
||||||
@ -83,10 +84,6 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
void _onItemTapped(int index) {
|
||||||
if (index == 0 && _selectedIndex == 0) {
|
|
||||||
_feedKey.currentState?.show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (index == 2) {
|
if (index == 2) {
|
||||||
// 中间按钮 - 跳转到发布页面
|
// 中间按钮 - 跳转到发布页面
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@ -95,24 +92,26 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const FriendsScreen()),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (index == 3 || index == 4) {
|
|
||||||
if (_selectedIndex != index) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedIndex = index;
|
_showFriendsOverlay = !_showFriendsOverlay;
|
||||||
|
if (_showFriendsOverlay) {
|
||||||
|
_selectedIndex = 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_selectedIndex != index) {
|
|
||||||
|
if (index == 0 && _selectedIndex == 0 && !_showFriendsOverlay) {
|
||||||
|
_feedKey.currentState?.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_selectedIndex != index || _showFriendsOverlay) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedIndex = index;
|
_selectedIndex = index;
|
||||||
|
_showFriendsOverlay = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,13 +122,15 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
if (_selectedIndex == 3 || _selectedIndex == 4) {
|
if (_selectedIndex == 3 || _selectedIndex == 4) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFFFF8F0),
|
backgroundColor: const Color(0xFFFFF8F0),
|
||||||
body: _buildBody(),
|
body: _buildBodyWithFriendsOverlay(),
|
||||||
bottomNavigationBar: _buildBottomNavigationBar(),
|
bottomNavigationBar: _buildBottomNavigationBar(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFFFF8F0),
|
backgroundColor: const Color(0xFFFFF8F0),
|
||||||
appBar: AppBar(
|
appBar: _showFriendsOverlay
|
||||||
|
? null
|
||||||
|
: AppBar(
|
||||||
title: Text('伴享', style: TextStyle(fontWeight: FontWeight.bold)),
|
title: Text('伴享', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
actions: [
|
actions: [
|
||||||
@ -143,7 +144,7 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: _buildBody(),
|
body: _buildBodyWithFriendsOverlay(),
|
||||||
bottomNavigationBar: _buildBottomNavigationBar(),
|
bottomNavigationBar: _buildBottomNavigationBar(),
|
||||||
floatingActionButton: _buildFloatingActionButton(),
|
floatingActionButton: _buildFloatingActionButton(),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
@ -161,6 +162,15 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildBodyWithFriendsOverlay() {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
_buildBody(),
|
||||||
|
if (_showFriendsOverlay) const Positioned.fill(child: FriendsScreen()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFeed() {
|
Widget _buildFeed() {
|
||||||
final filteredActivities = _getFilteredActivities();
|
final filteredActivities = _getFilteredActivities();
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
@ -413,7 +423,7 @@ class _ActivityListScreenState extends State<ActivityListScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildNavItem(int index, IconData icon, String label) {
|
Widget _buildNavItem(int index, IconData icon, String label) {
|
||||||
final isSelected = _selectedIndex == index;
|
final isSelected = index == 1 ? _showFriendsOverlay : _selectedIndex == index;
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => _onItemTapped(index),
|
onTap: () => _onItemTapped(index),
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'services_screen.dart';
|
|||||||
import 'ai_chat_screen.dart';
|
import 'ai_chat_screen.dart';
|
||||||
import 'messages_screen.dart';
|
import 'messages_screen.dart';
|
||||||
import 'profile_screen.dart';
|
import 'profile_screen.dart';
|
||||||
|
import 'create_activity_screen.dart';
|
||||||
|
|
||||||
class MainScreen extends StatefulWidget {
|
class MainScreen extends StatefulWidget {
|
||||||
const MainScreen({super.key});
|
const MainScreen({super.key});
|
||||||
@ -26,6 +27,8 @@ class _MainScreenState extends State<MainScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: IndexedStack(index: _currentIndex, children: _screens),
|
body: IndexedStack(index: _currentIndex, children: _screens),
|
||||||
|
floatingActionButton: _buildGlobalFab(),
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
currentIndex: _currentIndex,
|
currentIndex: _currentIndex,
|
||||||
onTap: (i) => setState(() => _currentIndex = i),
|
onTap: (i) => setState(() => _currentIndex = i),
|
||||||
@ -39,4 +42,23 @@ class _MainScreenState extends State<MainScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
releases/banxiang-v1.2.0-bugfix.apk
Normal file
BIN
releases/banxiang-v1.2.0-bugfix.apk
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user