From b6e8f7a88321915df72dcc438e83213126497350 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 27 Jul 2020 12:32:11 +0200 Subject: [PATCH] FocusMode: Do not accept inputs on the hidden elements Setting the opacity to 0 doesn't meant we cannot interact with them. --- lib/editors/scaffold.dart | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/editors/scaffold.dart b/lib/editors/scaffold.dart index 4b450a4e..8bab761f 100644 --- a/lib/editors/scaffold.dart +++ b/lib/editors/scaffold.dart @@ -58,9 +58,8 @@ class _EditorScaffoldState extends State { return Scaffold( body: Column( children: [ - AnimatedOpacity( - duration: const Duration(milliseconds: 500), - opacity: hideUIElements ? 0.0 : 1.0, + _AnimatedOpacityIgnorePointer( + visible: !hideUIElements, child: EditorAppBar( editor: widget.editor, editorState: widget.editorState, @@ -81,9 +80,8 @@ class _EditorScaffoldState extends State { behavior: HitTestBehavior.translucent, ), ), - AnimatedOpacity( - duration: const Duration(milliseconds: 500), - opacity: hideUIElements ? 0.0 : 1.0, + _AnimatedOpacityIgnorePointer( + visible: !hideUIElements, child: EditorBottomBar( editor: widget.editor, editorState: widget.editorState, @@ -107,3 +105,23 @@ class _EditorScaffoldState extends State { ); } } + +class _AnimatedOpacityIgnorePointer extends StatelessWidget { + final bool visible; + final Widget child; + + _AnimatedOpacityIgnorePointer({@required this.visible, @required this.child}); + + @override + Widget build(BuildContext context) { + var opacity = visible ? 1.0 : 0.0; + return IgnorePointer( + ignoring: !visible, + child: AnimatedOpacity( + duration: const Duration(milliseconds: 500), + opacity: opacity, + child: child, + ), + ); + } +}