diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 43bfdbf..43ff9ec 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -129,11 +129,8 @@ class _LandingPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Prevent back navigation from landing page - return false; - }, + return PopScope( + canPop: false, // Prevent back navigation from landing page child: Scaffold( body: Stack( children: [ @@ -379,11 +376,8 @@ class _SignInPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Prevent back navigation from sign in page - return false; - }, + return PopScope( + canPop: false, // Prevent back navigation from sign in page child: Scaffold( body: Container( decoration: BoxDecoration( diff --git a/frontend/lib/screens/create_post_screen.dart b/frontend/lib/screens/create_post_screen.dart index 536dc5f..09598bb 100644 --- a/frontend/lib/screens/create_post_screen.dart +++ b/frontend/lib/screens/create_post_screen.dart @@ -70,11 +70,8 @@ class _CreatePostScreenState extends State { final remainingChars = _maxCharacters - _bodyController.text.length; final isOverLimit = remainingChars < 0; - return WillPopScope( - onWillPop: () async { - // Allow back navigation to go back to feed page only - return true; - }, + return PopScope( + canPop: true, // Allow back navigation to go back to feed page only child: Scaffold( appBar: AppBar( title: Text('Create Post', style: TextStyle(fontWeight: FontWeight.w600)), diff --git a/frontend/lib/screens/notification_permission_screen.dart b/frontend/lib/screens/notification_permission_screen.dart index 6ccbcc4..3f0cffc 100644 --- a/frontend/lib/screens/notification_permission_screen.dart +++ b/frontend/lib/screens/notification_permission_screen.dart @@ -79,11 +79,8 @@ class _NotificationPermissionScreenState @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Prevent back navigation from notification permission screen - return false; - }, + return PopScope( + canPop: false, // Prevent back navigation from notification permission screen child: Scaffold( body: Container( decoration: BoxDecoration( diff --git a/frontend/lib/screens/pages/feed_page.dart b/frontend/lib/screens/pages/feed_page.dart index a2444d5..271f64c 100644 --- a/frontend/lib/screens/pages/feed_page.dart +++ b/frontend/lib/screens/pages/feed_page.dart @@ -14,7 +14,15 @@ class _FeedPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return PopScope( + canPop: false, // Prevent back navigation from feed page + onPopInvoked: (bool didPop) { + // Prevent any pop behavior, including iOS back gesture + if (!didPop) { + // Do nothing - stay on feed page + } + }, + child: Scaffold( appBar: AppBar( title: Text('Feed', style: TextStyle(fontWeight: FontWeight.w600)), backgroundColor: Colors.white, @@ -45,6 +53,7 @@ class _FeedPageState extends State { backgroundColor: Color(0xFF6A4C93), child: Icon(Icons.edit, color: Colors.white), ), + ), ); } diff --git a/frontend/lib/screens/pages/invitation_details_page.dart b/frontend/lib/screens/pages/invitation_details_page.dart index 471b57d..fb6c195 100644 --- a/frontend/lib/screens/pages/invitation_details_page.dart +++ b/frontend/lib/screens/pages/invitation_details_page.dart @@ -152,11 +152,8 @@ class _InvitationDetailsPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Allow back navigation to go back to invitations page only - return true; - }, + return PopScope( + canPop: true, // Allow back navigation to go back to invitations page only child: Scaffold( backgroundColor: Colors.grey[50], appBar: AppBar( diff --git a/frontend/lib/screens/pages/invitations_page.dart b/frontend/lib/screens/pages/invitations_page.dart index c1b593e..2acb672 100644 --- a/frontend/lib/screens/pages/invitations_page.dart +++ b/frontend/lib/screens/pages/invitations_page.dart @@ -528,7 +528,15 @@ class _InvitationsPageState extends State @override Widget build(BuildContext context) { - return Scaffold( + return PopScope( + canPop: false, // Prevent back navigation from invitations page + onPopInvoked: (bool didPop) { + // Prevent any pop behavior, including iOS back gesture + if (!didPop) { + // Do nothing - stay on invitations page + } + }, + child: Scaffold( appBar: AppBar( title: Text( 'Invitations', @@ -593,6 +601,7 @@ class _InvitationsPageState extends State backgroundColor: Color(0xFF6A4C93), child: Icon(Icons.add, color: Colors.white), ), + ), ); } } @@ -734,11 +743,8 @@ class _CreateInvitationPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Allow back navigation to go back to invitations page only - return true; - }, + return PopScope( + canPop: true, // Allow back navigation to go back to invitations page only child: Scaffold( body: Container( decoration: BoxDecoration( diff --git a/frontend/lib/screens/pages/profile_page.dart b/frontend/lib/screens/pages/profile_page.dart index b761c16..12c0dbb 100644 --- a/frontend/lib/screens/pages/profile_page.dart +++ b/frontend/lib/screens/pages/profile_page.dart @@ -170,7 +170,15 @@ class _ProfilePageState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return PopScope( + canPop: false, // Prevent back navigation from profile page + onPopInvoked: (bool didPop) { + // Prevent any pop behavior, including iOS back gesture + if (!didPop) { + // Do nothing - stay on profile page + } + }, + child: Scaffold( appBar: AppBar( title: Text('Profile', style: TextStyle(fontWeight: FontWeight.w600)), backgroundColor: Colors.white, @@ -318,6 +326,7 @@ class _ProfilePageState extends State { ], ], ), + ), ), ); } @@ -674,11 +683,8 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - // Allow back navigation to go back to profile page only - return true; - }, + return PopScope( + canPop: true, // Allow back navigation to go back to profile page only child: Scaffold( appBar: AppBar( title: Text('Settings', style: TextStyle(fontWeight: FontWeight.w600)), diff --git a/frontend/web/index.html b/frontend/web/index.html index 4eb1b79..136f569 100644 --- a/frontend/web/index.html +++ b/frontend/web/index.html @@ -32,6 +32,21 @@ Wesal + @@ -50,6 +65,23 @@ }); }); } + + // Prevent iOS Safari back gesture + window.addEventListener('touchstart', function (e) { + if (e.touches.length > 1) return; + + const touch = e.touches[0]; + if (touch.clientX < 20) { // Left edge + e.preventDefault(); + } + }, { passive: false }); + + // Override browser back + window.addEventListener('popstate', function (e) { + e.preventDefault(); + // Send message to Flutter + window.dispatchEvent(new CustomEvent('browser-back')); + });