From 9c61857f9de965b47c0ef1f1d29e8ea2dd146dd6 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 19 Jul 2022 15:19:34 +0200 Subject: [PATCH] #281 viewer: block user swipes from the top status bar gesture insets --- lib/widgets/common/basic/insets.dart | 20 ++++++++++++++++++++ lib/widgets/viewer/entry_viewer_stack.dart | 1 + lib/widgets/viewer/panorama_page.dart | 2 ++ lib/widgets/wallpaper_page.dart | 1 + 4 files changed, 24 insertions(+) diff --git a/lib/widgets/common/basic/insets.dart b/lib/widgets/common/basic/insets.dart index ce6b182d8..671c27738 100644 --- a/lib/widgets/common/basic/insets.dart +++ b/lib/widgets/common/basic/insets.dart @@ -25,6 +25,26 @@ class BottomGestureAreaProtector extends StatelessWidget { } } +// It will prevent the body from scrolling when a user swipe from top to show the status bar when system UI is hidden. +class TopGestureAreaProtector extends StatelessWidget { + const TopGestureAreaProtector({super.key}); + + @override + Widget build(BuildContext context) { + return Positioned( + left: 0, + top: 0, + right: 0, + height: context.select((mq) => mq.systemGestureInsets.top), + child: GestureDetector( + // absorb vertical gestures only + onVerticalDragDown: (details) {}, + behavior: HitTestBehavior.translucent, + ), + ); + } +} + // It will prevent the body from scrolling when a user swipe from edges to use Android Q style navigation gestures. class SideGestureAreaProtector extends StatelessWidget { const SideGestureAreaProtector({super.key}); diff --git a/lib/widgets/viewer/entry_viewer_stack.dart b/lib/widgets/viewer/entry_viewer_stack.dart index 48dae48ac..2005f2174 100644 --- a/lib/widgets/viewer/entry_viewer_stack.dart +++ b/lib/widgets/viewer/entry_viewer_stack.dart @@ -277,6 +277,7 @@ class _EntryViewerStackState extends State with EntryViewContr onViewDisposed: (mainEntry, pageEntry) => viewStateConductor.reset(pageEntry ?? mainEntry), ), ..._buildOverlays(), + const TopGestureAreaProtector(), const SideGestureAreaProtector(), const BottomGestureAreaProtector(), ], diff --git a/lib/widgets/viewer/panorama_page.dart b/lib/widgets/viewer/panorama_page.dart index e692d6e34..f2822b1f8 100644 --- a/lib/widgets/viewer/panorama_page.dart +++ b/lib/widgets/viewer/panorama_page.dart @@ -136,6 +136,8 @@ class _PanoramaPageState extends State { ), ), ), + const TopGestureAreaProtector(), + const SideGestureAreaProtector(), const BottomGestureAreaProtector(), ], ), diff --git a/lib/widgets/wallpaper_page.dart b/lib/widgets/wallpaper_page.dart index fde459e74..390001329 100644 --- a/lib/widgets/wallpaper_page.dart +++ b/lib/widgets/wallpaper_page.dart @@ -144,6 +144,7 @@ class _EntryEditorState extends State with EntryViewControllerMixin bottom: 0, child: _buildBottomOverlay(), ), + const TopGestureAreaProtector(), const SideGestureAreaProtector(), const BottomGestureAreaProtector(), ],