update HelpTools, use StatefulWidget

This commit is contained in:
csf 2023-02-12 22:03:43 +09:00
parent 9fb5b2cb5f
commit 6e4e463f5f

View File

@ -41,8 +41,6 @@ class _RemotePageState extends State<RemotePage> {
double _mouseScrollIntegral = 0; // mouse scroll speed controller double _mouseScrollIntegral = 0; // mouse scroll speed controller
Orientation? _currentOrientation; Orientation? _currentOrientation;
var _more = true;
var _fn = false;
late final keyboardVisibilityController = KeyboardVisibilityController(); late final keyboardVisibilityController = KeyboardVisibilityController();
late final StreamSubscription<bool> keyboardSubscription; late final StreamSubscription<bool> keyboardSubscription;
final FocusNode _mobileFocusNode = FocusNode(); final FocusNode _mobileFocusNode = FocusNode();
@ -96,6 +94,8 @@ class _RemotePageState extends State<RemotePage> {
gFFI.invokeMethod("enable_soft_keyboard", false); gFFI.invokeMethod("enable_soft_keyboard", false);
} }
} }
// update for Scaffold
setState(() {});
} }
// handle mobile virtual keyboard // handle mobile virtual keyboard
@ -478,6 +478,7 @@ class _RemotePageState extends State<RemotePage> {
} }
Widget getBodyForMobile() { Widget getBodyForMobile() {
final keyboardIsVisible = keyboardVisibilityController.isVisible;
return Container( return Container(
color: MyTheme.canvasColor, color: MyTheme.canvasColor,
child: Stack(children: () { child: Stack(children: () {
@ -488,7 +489,7 @@ class _RemotePageState extends State<RemotePage> {
right: 10, right: 10,
child: QualityMonitor(gFFI.qualityMonitorModel), child: QualityMonitor(gFFI.qualityMonitorModel),
), ),
getHelpTools(), KeyHelpTools(requestShow: keyboardIsVisible),
SizedBox( SizedBox(
width: 0, width: 0,
height: 0, height: 0,
@ -703,14 +704,25 @@ class _RemotePageState extends State<RemotePage> {
// ])); // ]));
// }, clickMaskDismiss: true); // }, clickMaskDismiss: true);
// } // }
Widget getHelpTools() {
final keyboard = keyboardVisibilityController.isVisible;
if (!keyboard) {
return SizedBox();
} }
final size = MediaQuery.of(context).size;
wrap(String text, void Function() onPressed, class KeyHelpTools extends StatefulWidget {
/// need to show by external request, etc [keyboardIsVisible] or [changeTouchMode]
final bool requestShow;
KeyHelpTools({required this.requestShow});
@override
State<KeyHelpTools> createState() => _KeyHelpToolsState();
}
class _KeyHelpToolsState extends State<KeyHelpTools> {
var _more = true;
var _fn = false;
InputModel get inputModel => gFFI.inputModel;
Widget wrap(String text, void Function() onPressed,
[bool? active, IconData? icon]) { [bool? active, IconData? icon]) {
return TextButton( return TextButton(
style: TextButton.styleFrom( style: TextButton.styleFrom(
@ -731,6 +743,13 @@ class _RemotePageState extends State<RemotePage> {
onPressed: onPressed); onPressed: onPressed);
} }
@override
Widget build(BuildContext context) {
if (!widget.requestShow) {
return SizedBox();
}
final size = MediaQuery.of(context).size;
final pi = gFFI.ffiModel.pi; final pi = gFFI.ffiModel.pi;
final isMac = pi.platform == kPeerPlatformMacOS; final isMac = pi.platform == kPeerPlatformMacOS;
final modifiers = <Widget>[ final modifiers = <Widget>[
@ -832,8 +851,7 @@ class _RemotePageState extends State<RemotePage> {
final space = size.width > 320 ? 4.0 : 2.0; final space = size.width > 320 ? 4.0 : 2.0;
return Container( return Container(
color: Color(0xAA000000), color: Color(0xAA000000),
padding: EdgeInsets.only( padding: EdgeInsets.only(top: widget.requestShow ? 24 : 4, bottom: 8),
top: keyboard ? 24 : 4, left: 0, right: 0, bottom: 8),
child: Wrap( child: Wrap(
spacing: space, spacing: space,
runSpacing: space, runSpacing: space,