FocusMode: Do not accept inputs on the hidden elements

Setting the opacity to 0 doesn't meant we cannot interact with them.
This commit is contained in:
Vishesh Handa
2020-07-27 12:32:11 +02:00
parent 73e3f7d5bc
commit b6e8f7a883

View File

@ -58,9 +58,8 @@ class _EditorScaffoldState extends State<EditorScaffold> {
return Scaffold(
body: Column(
children: <Widget>[
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<EditorScaffold> {
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<EditorScaffold> {
);
}
}
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,
),
);
}
}