feat: fix gesture back to prevent going bakc to login

This commit is contained in:
sBubshait 2025-07-24 14:19:15 +03:00
parent 526cf94360
commit 5eb191e93e

View File

@ -10,42 +10,38 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> { class _HomeScreenState extends State<HomeScreen> {
int _currentIndex = 0; int _currentIndex = 0;
final List<Widget> _pages = [ final List<Widget> _pages = [FeedPage(), InvitationsPage(), ProfilePage()];
FeedPage(),
InvitationsPage(),
ProfilePage(),
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
body: _pages[_currentIndex], onWillPop: () async {
bottomNavigationBar: BottomNavigationBar( // Prevent going back to authentication screens
currentIndex: _currentIndex, return false;
onTap: (index) { },
setState(() { child: Scaffold(
_currentIndex = index; body: _pages[_currentIndex],
}); bottomNavigationBar: BottomNavigationBar(
}, currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed, onTap: (index) {
selectedItemColor: Color(0xFF6A4C93), setState(() {
unselectedItemColor: Colors.grey, _currentIndex = index;
items: [ });
BottomNavigationBarItem( },
icon: Icon(Icons.home), type: BottomNavigationBarType.fixed,
label: 'Feed', selectedItemColor: Color(0xFF6A4C93),
), unselectedItemColor: Colors.grey,
BottomNavigationBarItem( items: [
icon: Icon(Icons.mail), BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Feed'),
label: 'Invitations', BottomNavigationBarItem(
), icon: Icon(Icons.mail),
BottomNavigationBarItem( label: 'Invitations',
icon: Icon(Icons.person), ),
label: 'Profile', BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'),
), ],
], ),
), ),
); );
} }
} }