feat: disable native safari swipe navigation on IOS for gesture back
This commit is contained in:
parent
a2abe08d3a
commit
c9316b5190
@ -129,11 +129,8 @@ class _LandingPageState extends State<LandingPage> {
|
||||
|
||||
@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<SignInPage> {
|
||||
|
||||
@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(
|
||||
|
||||
@ -70,11 +70,8 @@ class _CreatePostScreenState extends State<CreatePostScreen> {
|
||||
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)),
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -14,7 +14,15 @@ class _FeedPageState extends State<FeedPage> {
|
||||
|
||||
@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<FeedPage> {
|
||||
backgroundColor: Color(0xFF6A4C93),
|
||||
child: Icon(Icons.edit, color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -152,11 +152,8 @@ class _InvitationDetailsPageState extends State<InvitationDetailsPage> {
|
||||
|
||||
@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(
|
||||
|
||||
@ -528,7 +528,15 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
|
||||
@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<InvitationsPage>
|
||||
backgroundColor: Color(0xFF6A4C93),
|
||||
child: Icon(Icons.add, color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -734,11 +743,8 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
||||
|
||||
@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(
|
||||
|
||||
@ -170,7 +170,15 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
|
||||
@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<ProfilePage> {
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -674,11 +683,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
|
||||
@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)),
|
||||
|
||||
@ -32,6 +32,21 @@
|
||||
|
||||
<title>Wesal</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<style>
|
||||
body {
|
||||
overscroll-behavior-x: none;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/* Prevent pull-to-refresh and back gesture */
|
||||
html,
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -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'));
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user