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
Orientation? _currentOrientation;
var _more = true;
var _fn = false;
late final keyboardVisibilityController = KeyboardVisibilityController();
late final StreamSubscription<bool> keyboardSubscription;
final FocusNode _mobileFocusNode = FocusNode();
@ -96,6 +94,8 @@ class _RemotePageState extends State<RemotePage> {
gFFI.invokeMethod("enable_soft_keyboard", false);
}
}
// update for Scaffold
setState(() {});
}
// handle mobile virtual keyboard
@ -478,6 +478,7 @@ class _RemotePageState extends State<RemotePage> {
}
Widget getBodyForMobile() {
final keyboardIsVisible = keyboardVisibilityController.isVisible;
return Container(
color: MyTheme.canvasColor,
child: Stack(children: () {
@ -488,7 +489,7 @@ class _RemotePageState extends State<RemotePage> {
right: 10,
child: QualityMonitor(gFFI.qualityMonitorModel),
),
getHelpTools(),
KeyHelpTools(requestShow: keyboardIsVisible),
SizedBox(
width: 0,
height: 0,
@ -703,14 +704,25 @@ class _RemotePageState extends State<RemotePage> {
// ]));
// }, 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]) {
return TextButton(
style: TextButton.styleFrom(
@ -731,6 +743,13 @@ class _RemotePageState extends State<RemotePage> {
onPressed: onPressed);
}
@override
Widget build(BuildContext context) {
if (!widget.requestShow) {
return SizedBox();
}
final size = MediaQuery.of(context).size;
final pi = gFFI.ffiModel.pi;
final isMac = pi.platform == kPeerPlatformMacOS;
final modifiers = <Widget>[
@ -832,8 +851,7 @@ class _RemotePageState extends State<RemotePage> {
final space = size.width > 320 ? 4.0 : 2.0;
return Container(
color: Color(0xAA000000),
padding: EdgeInsets.only(
top: keyboard ? 24 : 4, left: 0, right: 0, bottom: 8),
padding: EdgeInsets.only(top: widget.requestShow ? 24 : 4, bottom: 8),
child: Wrap(
spacing: space,
runSpacing: space,