From 96d9604fe1cbe8b07c8a078969f495517cab6cb0 Mon Sep 17 00:00:00 2001 From: fufesou Date: Fri, 1 Sep 2023 23:55:43 +0800 Subject: [PATCH] enable bottom actions before first image is reached Signed-off-by: fufesou --- flutter/lib/mobile/pages/home_page.dart | 3 -- flutter/lib/mobile/pages/remote_page.dart | 54 +++++++++++++++++------ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/flutter/lib/mobile/pages/home_page.dart b/flutter/lib/mobile/pages/home_page.dart index 1fb75c1d1..a0f2fee65 100644 --- a/flutter/lib/mobile/pages/home_page.dart +++ b/flutter/lib/mobile/pages/home_page.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter_hbb/common/widgets/overlay.dart'; import 'package:flutter_hbb/mobile/pages/server_page.dart'; import 'package:flutter_hbb/mobile/pages/settings_page.dart'; import 'package:get/get.dart'; @@ -26,7 +25,6 @@ class _HomePageState extends State { var _selectedIndex = 0; int get selectedIndex => _selectedIndex; final List _pages = []; - final _blockableOverlayState = BlockableOverlayState(); void refreshPages() { setState(() { @@ -38,7 +36,6 @@ class _HomePageState extends State { void initState() { super.initState(); initPages(); - _blockableOverlayState.applyFfi(gFFI); } void initPages() { diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index 84426a307..cac59ec8f 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -39,6 +39,8 @@ class _RemotePageState extends State { String _value = ''; Orientation? _currentOrientation; + final _blockableOverlayState = BlockableOverlayState(); + final keyboardVisibilityController = KeyboardVisibilityController(); late final StreamSubscription keyboardSubscription; final FocusNode _mobileFocusNode = FocusNode(); @@ -67,6 +69,8 @@ class _RemotePageState extends State { initSharedStates(widget.id); gFFI.chatModel .changeCurrentKey(MessageKey(widget.id, ChatModel.clientModeID)); + + _blockableOverlayState.applyFfi(gFFI); } @override @@ -88,6 +92,15 @@ class _RemotePageState extends State { removeSharedStates(widget.id); } + Widget emptyOverlay() => BlockableOverlay( + /// the Overlay key will be set with _blockableOverlayState in BlockableOverlay + /// see override build() in [BlockableOverlay] + state: _blockableOverlayState, + underlying: Container( + color: Colors.transparent, + ), + ); + void onSoftKeyboardChanged(bool visible) { if (!visible) { SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); @@ -198,13 +211,19 @@ class _RemotePageState extends State { }); } + bool get keyboard => gFFI.ffiModel.permissions['keyboard'] != false; + + Widget _bottomWidget() => _showGestureHelp + ? getGestureHelp() + : (_showBar && gFFI.ffiModel.pi.displays.isNotEmpty + ? getBottomAppBar(keyboard) + : Offstage()); + @override Widget build(BuildContext context) { - final pi = Provider.of(context).pi; final keyboardIsVisible = keyboardVisibilityController.isVisible && _showEdit; final showActionButton = !_showBar || keyboardIsVisible || _showGestureHelp; - final keyboard = gFFI.ffiModel.permissions['keyboard'] != false; return WillPopScope( onWillPop: () async { @@ -241,11 +260,17 @@ class _RemotePageState extends State { } }); }), - bottomNavigationBar: _showGestureHelp - ? getGestureHelp() - : (_showBar && pi.displays.isNotEmpty - ? getBottomAppBar(keyboard) - : null), + bottomNavigationBar: Obx(() => Stack( + alignment: Alignment.bottomCenter, + children: [ + gFFI.ffiModel.pi.isSet.isTrue && + gFFI.ffiModel.waitForFirstImage.isTrue + ? emptyOverlay() + : Offstage(), + _bottomWidget(), + gFFI.ffiModel.pi.isSet.isFalse ? emptyOverlay() : Offstage(), + ], + )), body: Overlay( initialEntries: [ OverlayEntry(builder: (context) { @@ -368,12 +393,15 @@ class _RemotePageState extends State { }, ), ]), - IconButton( - color: Colors.white, - icon: Icon(Icons.expand_more), - onPressed: () { - setState(() => _showBar = !_showBar); - }), + Obx(() => IconButton( + color: Colors.white, + icon: Icon(Icons.expand_more), + onPressed: gFFI.ffiModel.waitForFirstImage.isTrue + ? null + : () { + setState(() => _showBar = !_showBar); + }, + )), ], ), );