feat: gesture back improvement

This commit is contained in:
sBubshait 2025-07-28 10:15:16 +03:00
parent e73bc88879
commit a2abe08d3a
8 changed files with 75 additions and 36 deletions

View File

@ -129,7 +129,12 @@ class _LandingPageState extends State<LandingPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
onWillPop: () async {
// Prevent back navigation from landing page
return false;
},
child: Scaffold(
body: Stack( body: Stack(
children: [ children: [
// Background gradient // Background gradient
@ -234,6 +239,7 @@ class _LandingPageState extends State<LandingPage> {
), ),
], ],
), ),
),
); );
} }
} }
@ -373,8 +379,13 @@ class _SignInPageState extends State<SignInPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
body: Container( onWillPop: () async {
// Prevent back navigation from sign in page
return false;
},
child: Scaffold(
body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
@ -615,6 +626,7 @@ class _SignInPageState extends State<SignInPage> {
], ],
), ),
), ),
),
), ),
); );
} }

View File

@ -70,7 +70,12 @@ class _CreatePostScreenState extends State<CreatePostScreen> {
final remainingChars = _maxCharacters - _bodyController.text.length; final remainingChars = _maxCharacters - _bodyController.text.length;
final isOverLimit = remainingChars < 0; 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( appBar: AppBar(
title: Text('Create Post', style: TextStyle(fontWeight: FontWeight.w600)), title: Text('Create Post', style: TextStyle(fontWeight: FontWeight.w600)),
backgroundColor: Colors.white, backgroundColor: Colors.white,
@ -245,6 +250,7 @@ class _CreatePostScreenState extends State<CreatePostScreen> {
], ],
), ),
), ),
),
), ),
); );
} }

View File

@ -15,11 +15,8 @@ class _HomeScreenState extends State<HomeScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return PopScope(
onWillPop: () async { canPop: false, // Prevent going back to authentication screens
// Prevent going back to authentication screens
return false;
},
child: Scaffold( child: Scaffold(
body: _pages[_currentIndex], body: _pages[_currentIndex],
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(

View File

@ -79,7 +79,12 @@ class _NotificationPermissionScreenState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
onWillPop: () async {
// Prevent back navigation from notification permission screen
return false;
},
child: Scaffold(
body: Container( body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -236,6 +241,7 @@ class _NotificationPermissionScreenState
), ),
), ),
), ),
),
), ),
); );
} }

View File

@ -152,7 +152,12 @@ class _InvitationDetailsPageState extends State<InvitationDetailsPage> {
@override @override
Widget build(BuildContext context) { 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], backgroundColor: Colors.grey[50],
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
@ -545,6 +550,7 @@ class _InvitationDetailsPageState extends State<InvitationDetailsPage> {
], ],
), ),
), ),
),
); );
} }
} }

View File

@ -734,8 +734,13 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
body: Container( onWillPop: () async {
// Allow back navigation to go back to invitations page only
return true;
},
child: Scaffold(
body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
@ -1095,6 +1100,7 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
], ],
), ),
), ),
),
), ),
); );
} }

View File

@ -149,10 +149,7 @@ class _PostViewPageState extends State<PostViewPage> {
final avatarLetter = _getAvatarLetter(user.displayName); final avatarLetter = _getAvatarLetter(user.displayName);
return Transform.translate( return Transform.translate(
offset: Offset( offset: Offset(index < displayUsers.length - 1 ? -8 : 0, 0),
index < displayUsers.length - 1 ? -8 : 0,
0,
),
child: CircleAvatar( child: CircleAvatar(
radius: 16, radius: 16,
backgroundColor: Colors.white, backgroundColor: Colors.white,
@ -437,25 +434,28 @@ class _PostViewPageState extends State<PostViewPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return PopScope(
appBar: AppBar( canPop: true,
backgroundColor: Colors.white, child: Scaffold(
elevation: 0, appBar: AppBar(
leading: IconButton( backgroundColor: Colors.white,
onPressed: () => Navigator.pop(context), elevation: 0,
icon: Icon(Icons.arrow_back, color: Colors.black87), leading: IconButton(
), onPressed: () => Navigator.pop(context),
title: Text( icon: Icon(Icons.arrow_back, color: Colors.black87),
'Post', ),
style: TextStyle( title: Text(
color: Colors.black87, 'Post',
fontSize: 18, style: TextStyle(
fontWeight: FontWeight.w600, color: Colors.black87,
fontSize: 18,
fontWeight: FontWeight.w600,
),
), ),
), ),
backgroundColor: Color(0xFFF5F5F5),
body: _buildBody(),
), ),
backgroundColor: Color(0xFFF5F5F5),
body: _buildBody(),
); );
} }

View File

@ -674,9 +674,14 @@ class _SettingsPageState extends State<SettingsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
appBar: AppBar( onWillPop: () async {
title: Text('Settings', style: TextStyle(fontWeight: FontWeight.w600)), // 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, backgroundColor: Colors.white,
foregroundColor: Color(0xFF6A4C93), foregroundColor: Color(0xFF6A4C93),
elevation: 0, elevation: 0,
@ -823,6 +828,7 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
], ],
), ),
),
), ),
); );
} }