minor system gesture insets handling improvements
This commit is contained in:
parent
718b4749a0
commit
7699c77044
2 changed files with 43 additions and 17 deletions
|
@ -1,5 +1,3 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:aves/widgets/common/extensions/media_query.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -13,21 +11,48 @@ class BottomGestureAreaProtector extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<MediaQueryData, double>(
|
||||
selector: (context, mq) => mq.systemGestureInsets.bottom,
|
||||
builder: (context, systemGestureBottom, child) {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: systemGestureBottom,
|
||||
child: GestureDetector(
|
||||
// absorb vertical gestures only
|
||||
onVerticalDragDown: (details) {},
|
||||
behavior: HitTestBehavior.translucent,
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: context.select<MediaQueryData, double>((mq) => mq.systemGestureInsets.bottom),
|
||||
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({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Positioned.fill(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.select<MediaQueryData, double>((mq) => mq.systemGestureInsets.left),
|
||||
child: GestureDetector(
|
||||
// absorb horizontal gestures only
|
||||
onHorizontalDragDown: (details) {},
|
||||
behavior: HitTestBehavior.translucent,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
width: context.select<MediaQueryData, double>((mq) => mq.systemGestureInsets.right),
|
||||
child: GestureDetector(
|
||||
// absorb horizontal gestures only
|
||||
onHorizontalDragDown: (details) {},
|
||||
behavior: HitTestBehavior.translucent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +83,7 @@ class BottomPaddingSliver extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return SliverToBoxAdapter(
|
||||
child: Selector<MediaQueryData, double>(
|
||||
selector: (context, mq) => max(mq.effectiveBottomPadding, mq.systemGestureInsets.bottom),
|
||||
selector: (context, mq) => mq.effectiveBottomPadding,
|
||||
builder: (context, mqPaddingBottom, child) {
|
||||
return SizedBox(height: mqPaddingBottom);
|
||||
},
|
||||
|
|
|
@ -214,6 +214,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with FeedbackMixin,
|
|||
),
|
||||
_buildTopOverlay(),
|
||||
_buildBottomOverlay(),
|
||||
const SideGestureAreaProtector(),
|
||||
const BottomGestureAreaProtector(),
|
||||
],
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue