diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 5e6c1e1..43bfdbf 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -129,7 +129,12 @@ class _LandingPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return WillPopScope( + onWillPop: () async { + // Prevent back navigation from landing page + return false; + }, + child: Scaffold( body: Stack( children: [ // Background gradient @@ -234,6 +239,7 @@ class _LandingPageState extends State { ), ], ), + ), ); } } @@ -373,8 +379,13 @@ class _SignInPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: Container( + return WillPopScope( + onWillPop: () async { + // Prevent back navigation from sign in page + return false; + }, + child: Scaffold( + body: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, @@ -615,6 +626,7 @@ class _SignInPageState extends State { ], ), ), + ), ), ); } diff --git a/frontend/lib/screens/create_post_screen.dart b/frontend/lib/screens/create_post_screen.dart index 57d0e1a..536dc5f 100644 --- a/frontend/lib/screens/create_post_screen.dart +++ b/frontend/lib/screens/create_post_screen.dart @@ -70,7 +70,12 @@ class _CreatePostScreenState extends State { final remainingChars = _maxCharacters - _bodyController.text.length; final isOverLimit = remainingChars < 0; - return Scaffold( + return WillPopScope( + onWillPop: () async { + // Allow back navigation to go back to feed page only + return true; + }, + child: Scaffold( appBar: AppBar( title: Text('Create Post', style: TextStyle(fontWeight: FontWeight.w600)), backgroundColor: Colors.white, @@ -245,6 +250,7 @@ class _CreatePostScreenState extends State { ], ), ), + ), ), ); } diff --git a/frontend/lib/screens/home_screen.dart b/frontend/lib/screens/home_screen.dart index e34a34b..1a74c6f 100644 --- a/frontend/lib/screens/home_screen.dart +++ b/frontend/lib/screens/home_screen.dart @@ -15,11 +15,8 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Prevent going back to authentication screens - return false; - }, + return PopScope( + canPop: false, // Prevent going back to authentication screens child: Scaffold( body: _pages[_currentIndex], bottomNavigationBar: BottomNavigationBar( diff --git a/frontend/lib/screens/notification_permission_screen.dart b/frontend/lib/screens/notification_permission_screen.dart index 3f5e2f5..6ccbcc4 100644 --- a/frontend/lib/screens/notification_permission_screen.dart +++ b/frontend/lib/screens/notification_permission_screen.dart @@ -79,7 +79,12 @@ class _NotificationPermissionScreenState @override Widget build(BuildContext context) { - return Scaffold( + return WillPopScope( + onWillPop: () async { + // Prevent back navigation from notification permission screen + return false; + }, + child: Scaffold( body: Container( decoration: BoxDecoration( gradient: LinearGradient( @@ -236,6 +241,7 @@ class _NotificationPermissionScreenState ), ), ), + ), ), ); } diff --git a/frontend/lib/screens/pages/invitation_details_page.dart b/frontend/lib/screens/pages/invitation_details_page.dart index 84e25d1..471b57d 100644 --- a/frontend/lib/screens/pages/invitation_details_page.dart +++ b/frontend/lib/screens/pages/invitation_details_page.dart @@ -152,7 +152,12 @@ class _InvitationDetailsPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return WillPopScope( + onWillPop: () async { + // Allow back navigation to go back to invitations page only + return true; + }, + child: Scaffold( backgroundColor: Colors.grey[50], appBar: AppBar( title: Text( @@ -545,6 +550,7 @@ class _InvitationDetailsPageState extends State { ], ), ), + ), ); } } \ No newline at end of file diff --git a/frontend/lib/screens/pages/invitations_page.dart b/frontend/lib/screens/pages/invitations_page.dart index a23501f..c1b593e 100644 --- a/frontend/lib/screens/pages/invitations_page.dart +++ b/frontend/lib/screens/pages/invitations_page.dart @@ -734,8 +734,13 @@ class _CreateInvitationPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: Container( + return WillPopScope( + onWillPop: () async { + // Allow back navigation to go back to invitations page only + return true; + }, + child: Scaffold( + body: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, @@ -1095,6 +1100,7 @@ class _CreateInvitationPageState extends State { ], ), ), + ), ), ); } diff --git a/frontend/lib/screens/pages/post_view_page.dart b/frontend/lib/screens/pages/post_view_page.dart index 060f8c2..c73943e 100644 --- a/frontend/lib/screens/pages/post_view_page.dart +++ b/frontend/lib/screens/pages/post_view_page.dart @@ -149,10 +149,7 @@ class _PostViewPageState extends State { final avatarLetter = _getAvatarLetter(user.displayName); return Transform.translate( - offset: Offset( - index < displayUsers.length - 1 ? -8 : 0, - 0, - ), + offset: Offset(index < displayUsers.length - 1 ? -8 : 0, 0), child: CircleAvatar( radius: 16, backgroundColor: Colors.white, @@ -437,25 +434,28 @@ class _PostViewPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: Colors.white, - elevation: 0, - leading: IconButton( - onPressed: () => Navigator.pop(context), - icon: Icon(Icons.arrow_back, color: Colors.black87), - ), - title: Text( - 'Post', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - fontWeight: FontWeight.w600, + return PopScope( + canPop: true, + child: Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0, + leading: IconButton( + onPressed: () => Navigator.pop(context), + icon: Icon(Icons.arrow_back, color: Colors.black87), + ), + title: Text( + 'Post', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + fontWeight: FontWeight.w600, + ), ), ), + backgroundColor: Color(0xFFF5F5F5), + body: _buildBody(), ), - backgroundColor: Color(0xFFF5F5F5), - body: _buildBody(), ); } diff --git a/frontend/lib/screens/pages/profile_page.dart b/frontend/lib/screens/pages/profile_page.dart index adeb6a8..b761c16 100644 --- a/frontend/lib/screens/pages/profile_page.dart +++ b/frontend/lib/screens/pages/profile_page.dart @@ -674,9 +674,14 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('Settings', style: TextStyle(fontWeight: FontWeight.w600)), + return WillPopScope( + onWillPop: () async { + // Allow back navigation to go back to profile page only + return true; + }, + child: Scaffold( + appBar: AppBar( + title: Text('Settings', style: TextStyle(fontWeight: FontWeight.w600)), backgroundColor: Colors.white, foregroundColor: Color(0xFF6A4C93), elevation: 0, @@ -823,6 +828,7 @@ class _SettingsPageState extends State { ), ], ), + ), ), ); }