2022-05-29 17:19:50 +08:00
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
2020-11-17 01:22:14 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2022-05-29 17:19:50 +08:00
|
|
|
|
import 'package:flutter/services.dart';
|
2023-04-12 09:41:13 +08:00
|
|
|
|
import 'package:flutter_hbb/common/shared_state.dart';
|
|
|
|
|
import 'package:flutter_hbb/common/widgets/toolbar.dart';
|
2022-11-24 11:19:16 +08:00
|
|
|
|
import 'package:flutter_hbb/consts.dart';
|
2022-05-24 23:33:00 +08:00
|
|
|
|
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
2022-05-29 17:19:50 +08:00
|
|
|
|
import 'package:flutter_hbb/models/chat_model.dart';
|
2023-02-12 20:26:04 +08:00
|
|
|
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
2023-04-12 09:41:13 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2020-11-18 23:15:59 +08:00
|
|
|
|
import 'package:provider/provider.dart';
|
2020-11-23 13:03:51 +08:00
|
|
|
|
import 'package:wakelock/wakelock.dart';
|
2022-05-29 17:19:50 +08:00
|
|
|
|
|
2022-05-24 23:33:00 +08:00
|
|
|
|
import '../../common.dart';
|
2022-09-27 23:05:11 +08:00
|
|
|
|
import '../../common/widgets/overlay.dart';
|
2023-03-24 15:21:14 +08:00
|
|
|
|
import '../../common/widgets/dialog.dart';
|
2022-09-27 22:16:27 +08:00
|
|
|
|
import '../../common/widgets/remote_input.dart';
|
2022-09-27 20:35:02 +08:00
|
|
|
|
import '../../models/input_model.dart';
|
2022-05-24 23:33:00 +08:00
|
|
|
|
import '../../models/model.dart';
|
2022-08-05 20:29:43 +08:00
|
|
|
|
import '../../models/platform_model.dart';
|
2023-02-09 22:00:34 +08:00
|
|
|
|
import '../../utils/image.dart';
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
2023-07-17 20:07:55 +08:00
|
|
|
|
final initText = '1' * 1024;
|
2020-11-28 18:06:27 +08:00
|
|
|
|
|
2020-11-17 01:22:14 +08:00
|
|
|
|
class RemotePage extends StatefulWidget {
|
2022-02-17 15:22:14 +08:00
|
|
|
|
RemotePage({Key? key, required this.id}) : super(key: key);
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
|
|
|
|
final String id;
|
|
|
|
|
|
|
|
|
|
@override
|
2022-09-27 22:16:27 +08:00
|
|
|
|
State<RemotePage> createState() => _RemotePageState();
|
2020-11-17 01:22:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RemotePageState extends State<RemotePage> {
|
2022-02-17 15:22:14 +08:00
|
|
|
|
Timer? _timer;
|
2022-05-23 16:02:37 +08:00
|
|
|
|
bool _showBar = !isWebDesktop;
|
2023-02-12 21:44:53 +08:00
|
|
|
|
bool _showGestureHelp = false;
|
2020-11-25 16:28:46 +08:00
|
|
|
|
String _value = '';
|
2022-06-02 17:16:23 +08:00
|
|
|
|
Orientation? _currentOrientation;
|
2022-02-17 18:00:44 +08:00
|
|
|
|
|
2023-09-01 23:55:43 +08:00
|
|
|
|
final _blockableOverlayState = BlockableOverlayState();
|
|
|
|
|
|
2023-02-12 21:44:53 +08:00
|
|
|
|
final keyboardVisibilityController = KeyboardVisibilityController();
|
2023-02-12 20:26:04 +08:00
|
|
|
|
late final StreamSubscription<bool> keyboardSubscription;
|
2022-04-25 18:25:25 +08:00
|
|
|
|
final FocusNode _mobileFocusNode = FocusNode();
|
|
|
|
|
final FocusNode _physicalFocusNode = FocusNode();
|
2022-05-11 17:06:40 +08:00
|
|
|
|
var _showEdit = false; // use soft keyboard
|
2020-11-17 12:08:31 +08:00
|
|
|
|
|
2022-09-27 22:16:27 +08:00
|
|
|
|
InputModel get inputModel => gFFI.inputModel;
|
2023-06-06 07:39:44 +08:00
|
|
|
|
SessionID get sessionId => gFFI.sessionId;
|
2022-09-27 20:35:02 +08:00
|
|
|
|
|
2020-11-17 11:12:55 +08:00
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.start(widget.id);
|
2022-05-26 18:25:16 +08:00
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
2022-02-24 18:24:52 +08:00
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
2022-08-12 18:42:02 +08:00
|
|
|
|
gFFI.dialogManager
|
2022-08-16 21:27:21 +08:00
|
|
|
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
2020-11-17 12:08:31 +08:00
|
|
|
|
});
|
2020-11-23 12:00:56 +08:00
|
|
|
|
Wakelock.enable();
|
2022-04-25 18:25:25 +08:00
|
|
|
|
_physicalFocusNode.requestFocus();
|
2023-06-06 07:39:44 +08:00
|
|
|
|
gFFI.ffiModel.updateEventListener(sessionId, widget.id);
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.listenToMouse(true);
|
2023-06-06 07:39:44 +08:00
|
|
|
|
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
|
2023-02-12 20:26:04 +08:00
|
|
|
|
keyboardSubscription =
|
|
|
|
|
keyboardVisibilityController.onChange.listen(onSoftKeyboardChanged);
|
2023-04-12 09:41:13 +08:00
|
|
|
|
initSharedStates(widget.id);
|
2023-07-10 16:02:47 +08:00
|
|
|
|
gFFI.chatModel
|
|
|
|
|
.changeCurrentKey(MessageKey(widget.id, ChatModel.clientModeID));
|
2023-09-01 23:55:43 +08:00
|
|
|
|
|
|
|
|
|
_blockableOverlayState.applyFfi(gFFI);
|
2020-11-17 12:08:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
2023-06-28 17:09:23 +08:00
|
|
|
|
Future<void> dispose() async {
|
2023-06-30 14:01:12 +08:00
|
|
|
|
// https://github.com/flutter/flutter/issues/64935
|
|
|
|
|
super.dispose();
|
2022-09-08 22:18:02 +08:00
|
|
|
|
gFFI.dialogManager.hideMobileActionsOverlay();
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.listenToMouse(false);
|
2023-06-28 17:09:23 +08:00
|
|
|
|
await gFFI.invokeMethod("enable_soft_keyboard", true);
|
2022-04-25 18:25:25 +08:00
|
|
|
|
_mobileFocusNode.dispose();
|
|
|
|
|
_physicalFocusNode.dispose();
|
2023-06-28 17:09:23 +08:00
|
|
|
|
await gFFI.close();
|
2020-11-27 16:06:35 +08:00
|
|
|
|
_timer?.cancel();
|
2022-08-12 18:42:02 +08:00
|
|
|
|
gFFI.dialogManager.dismissAll();
|
2023-06-28 17:09:23 +08:00
|
|
|
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
2022-02-24 18:24:52 +08:00
|
|
|
|
overlays: SystemUiOverlay.values);
|
2023-06-28 17:09:23 +08:00
|
|
|
|
await Wakelock.disable();
|
|
|
|
|
await keyboardSubscription.cancel();
|
2023-04-12 09:41:13 +08:00
|
|
|
|
removeSharedStates(widget.id);
|
2020-11-17 12:08:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-04 23:21:47 +08:00
|
|
|
|
// to-do: It should be better to use transparent color instead of the bgColor.
|
|
|
|
|
// But for now, the transparent color will cause the canvas to be white.
|
|
|
|
|
// I'm sure that the white color is caused by the Overlay widget in BlockableOverlay.
|
|
|
|
|
// But I don't know why and how to fix it.
|
|
|
|
|
Widget emptyOverlay(Color bgColor) => BlockableOverlay(
|
2023-09-01 23:55:43 +08:00
|
|
|
|
/// the Overlay key will be set with _blockableOverlayState in BlockableOverlay
|
|
|
|
|
/// see override build() in [BlockableOverlay]
|
|
|
|
|
state: _blockableOverlayState,
|
|
|
|
|
underlying: Container(
|
2023-09-04 23:21:47 +08:00
|
|
|
|
color: bgColor,
|
2023-09-01 23:55:43 +08:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-02-12 20:26:04 +08:00
|
|
|
|
void onSoftKeyboardChanged(bool visible) {
|
|
|
|
|
if (!visible) {
|
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
|
|
|
|
// [pi.version.isNotEmpty] -> check ready or not, avoid login without soft-keyboard
|
|
|
|
|
if (gFFI.chatModel.chatWindowOverlayEntry == null &&
|
|
|
|
|
gFFI.ffiModel.pi.version.isNotEmpty) {
|
|
|
|
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
|
|
|
|
}
|
2020-11-20 17:20:42 +08:00
|
|
|
|
}
|
2023-02-12 21:03:43 +08:00
|
|
|
|
// update for Scaffold
|
|
|
|
|
setState(() {});
|
2020-11-19 21:59:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 18:25:25 +08:00
|
|
|
|
// handle mobile virtual keyboard
|
2022-09-27 23:05:11 +08:00
|
|
|
|
void handleSoftKeyboardInput(String newValue) {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
var oldValue = _value;
|
|
|
|
|
_value = newValue;
|
2022-01-25 18:13:11 +08:00
|
|
|
|
if (isIOS) {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
var i = newValue.length - 1;
|
|
|
|
|
for (; i >= 0 && newValue[i] != '\1'; --i) {}
|
|
|
|
|
var j = oldValue.length - 1;
|
|
|
|
|
for (; j >= 0 && oldValue[j] != '\1'; --j) {}
|
|
|
|
|
if (i < j) j = i;
|
|
|
|
|
newValue = newValue.substring(j + 1);
|
|
|
|
|
oldValue = oldValue.substring(j + 1);
|
|
|
|
|
var common = 0;
|
|
|
|
|
for (;
|
2022-08-02 13:10:09 +08:00
|
|
|
|
common < oldValue.length &&
|
|
|
|
|
common < newValue.length &&
|
|
|
|
|
newValue[common] == oldValue[common];
|
|
|
|
|
++common) {}
|
2021-08-17 22:57:35 +08:00
|
|
|
|
for (i = 0; i < oldValue.length - common; ++i) {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_BACK');
|
2021-08-17 22:57:35 +08:00
|
|
|
|
}
|
|
|
|
|
if (newValue.length > common) {
|
|
|
|
|
var s = newValue.substring(common);
|
|
|
|
|
if (s.length > 1) {
|
2023-06-06 07:39:44 +08:00
|
|
|
|
bind.sessionInputString(sessionId: sessionId, value: s);
|
2021-08-17 22:57:35 +08:00
|
|
|
|
} else {
|
|
|
|
|
inputChar(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-09-27 22:16:27 +08:00
|
|
|
|
if (oldValue.isNotEmpty &&
|
|
|
|
|
newValue.isNotEmpty &&
|
2021-08-17 22:57:35 +08:00
|
|
|
|
oldValue[0] == '\1' &&
|
|
|
|
|
newValue[0] != '\1') {
|
2020-11-28 18:06:27 +08:00
|
|
|
|
// clipboard
|
2021-08-17 22:57:35 +08:00
|
|
|
|
oldValue = '';
|
2020-11-28 18:06:27 +08:00
|
|
|
|
}
|
2021-09-01 01:48:41 +08:00
|
|
|
|
if (newValue.length == oldValue.length) {
|
|
|
|
|
// ?
|
|
|
|
|
} else if (newValue.length < oldValue.length) {
|
2020-11-28 18:06:27 +08:00
|
|
|
|
final char = 'VK_BACK';
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey(char);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
} else {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
final content = newValue.substring(oldValue.length);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
if (content.length > 1) {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
if (oldValue != '' &&
|
2020-12-22 16:00:10 +08:00
|
|
|
|
content.length == 2 &&
|
|
|
|
|
(content == '""' ||
|
|
|
|
|
content == '()' ||
|
|
|
|
|
content == '[]' ||
|
|
|
|
|
content == '<>' ||
|
|
|
|
|
content == "{}" ||
|
|
|
|
|
content == '”“' ||
|
|
|
|
|
content == '《》' ||
|
|
|
|
|
content == '()' ||
|
|
|
|
|
content == '【】')) {
|
2020-12-22 16:07:48 +08:00
|
|
|
|
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
2023-06-06 07:39:44 +08:00
|
|
|
|
bind.sessionInputString(sessionId: sessionId, value: content);
|
2020-12-22 16:00:10 +08:00
|
|
|
|
openKeyboard();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-06-06 07:39:44 +08:00
|
|
|
|
bind.sessionInputString(sessionId: sessionId, value: content);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
} else {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
inputChar(content);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-17 22:57:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void inputChar(String char) {
|
|
|
|
|
if (char == '\n') {
|
|
|
|
|
char = 'VK_RETURN';
|
|
|
|
|
} else if (char == ' ') {
|
|
|
|
|
char = 'VK_SPACE';
|
|
|
|
|
}
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey(char);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openKeyboard() {
|
2022-06-13 21:07:26 +08:00
|
|
|
|
gFFI.invokeMethod("enable_soft_keyboard", true);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
// destroy first, so that our _value trick can work
|
2020-12-22 15:26:35 +08:00
|
|
|
|
_value = initText;
|
2021-09-01 01:35:01 +08:00
|
|
|
|
setState(() => _showEdit = false);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = Timer(Duration(milliseconds: 30), () {
|
|
|
|
|
// show now, and sleep a while to requestFocus to
|
|
|
|
|
// make sure edit ready, so that keyboard wont show/hide/show/hide happen
|
2021-09-01 01:35:01 +08:00
|
|
|
|
setState(() => _showEdit = true);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = Timer(Duration(milliseconds: 30), () {
|
2022-02-24 18:24:52 +08:00
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
|
|
|
|
overlays: SystemUiOverlay.values);
|
2022-04-25 18:25:25 +08:00
|
|
|
|
_mobileFocusNode.requestFocus();
|
2020-11-28 18:06:27 +08:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 23:55:43 +08:00
|
|
|
|
bool get keyboard => gFFI.ffiModel.permissions['keyboard'] != false;
|
|
|
|
|
|
|
|
|
|
Widget _bottomWidget() => _showGestureHelp
|
|
|
|
|
? getGestureHelp()
|
|
|
|
|
: (_showBar && gFFI.ffiModel.pi.displays.isNotEmpty
|
|
|
|
|
? getBottomAppBar(keyboard)
|
|
|
|
|
: Offstage());
|
|
|
|
|
|
2020-11-17 01:22:14 +08:00
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-12 21:44:53 +08:00
|
|
|
|
final keyboardIsVisible =
|
2023-02-12 20:26:04 +08:00
|
|
|
|
keyboardVisibilityController.isVisible && _showEdit;
|
2023-02-12 21:44:53 +08:00
|
|
|
|
final showActionButton = !_showBar || keyboardIsVisible || _showGestureHelp;
|
2022-04-26 21:21:08 +08:00
|
|
|
|
|
2020-11-22 18:29:04 +08:00
|
|
|
|
return WillPopScope(
|
2020-11-29 14:19:01 +08:00
|
|
|
|
onWillPop: () async {
|
2023-06-06 07:39:44 +08:00
|
|
|
|
clientClose(sessionId, gFFI.dialogManager);
|
2020-11-29 14:19:01 +08:00
|
|
|
|
return false;
|
|
|
|
|
},
|
2022-09-27 22:16:27 +08:00
|
|
|
|
child: getRawPointerAndKeyBody(Scaffold(
|
2023-02-09 21:55:56 +08:00
|
|
|
|
// workaround for https://github.com/rustdesk/rustdesk/issues/3131
|
2023-02-12 21:44:53 +08:00
|
|
|
|
floatingActionButtonLocation: keyboardIsVisible
|
2023-02-09 21:55:56 +08:00
|
|
|
|
? FABLocation(FloatingActionButtonLocation.endFloat, 0, -35)
|
|
|
|
|
: null,
|
2022-09-27 22:16:27 +08:00
|
|
|
|
floatingActionButton: !showActionButton
|
|
|
|
|
? null
|
|
|
|
|
: FloatingActionButton(
|
2023-02-12 21:44:53 +08:00
|
|
|
|
mini: !keyboardIsVisible,
|
2022-09-27 22:16:27 +08:00
|
|
|
|
child: Icon(
|
2023-02-12 21:44:53 +08:00
|
|
|
|
(keyboardIsVisible || _showGestureHelp)
|
|
|
|
|
? Icons.expand_more
|
|
|
|
|
: Icons.expand_less,
|
2023-02-09 21:55:56 +08:00
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
2022-09-27 22:16:27 +08:00
|
|
|
|
backgroundColor: MyTheme.accent,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
2023-02-12 21:44:53 +08:00
|
|
|
|
if (keyboardIsVisible) {
|
2022-09-27 22:16:27 +08:00
|
|
|
|
_showEdit = false;
|
|
|
|
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
|
|
|
|
_mobileFocusNode.unfocus();
|
|
|
|
|
_physicalFocusNode.requestFocus();
|
2023-02-12 21:44:53 +08:00
|
|
|
|
} else if (_showGestureHelp) {
|
|
|
|
|
_showGestureHelp = false;
|
2022-09-27 22:16:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
_showBar = !_showBar;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
2023-09-01 23:55:43 +08:00
|
|
|
|
bottomNavigationBar: Obx(() => Stack(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
children: [
|
|
|
|
|
gFFI.ffiModel.pi.isSet.isTrue &&
|
|
|
|
|
gFFI.ffiModel.waitForFirstImage.isTrue
|
2023-09-04 23:21:47 +08:00
|
|
|
|
? emptyOverlay(MyTheme.canvasColor)
|
2023-09-04 14:17:54 +08:00
|
|
|
|
: () {
|
|
|
|
|
gFFI.ffiModel.tryShowAndroidActionsOverlay();
|
|
|
|
|
return Offstage();
|
|
|
|
|
}(),
|
2023-09-01 23:55:43 +08:00
|
|
|
|
_bottomWidget(),
|
2023-09-10 15:32:50 +08:00
|
|
|
|
gFFI.ffiModel.pi.isSet.isFalse
|
|
|
|
|
? emptyOverlay(MyTheme.canvasColor)
|
|
|
|
|
: Offstage(),
|
2023-09-01 23:55:43 +08:00
|
|
|
|
],
|
|
|
|
|
)),
|
2022-09-27 22:16:27 +08:00
|
|
|
|
body: Overlay(
|
|
|
|
|
initialEntries: [
|
|
|
|
|
OverlayEntry(builder: (context) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
child: isWebDesktop
|
|
|
|
|
? getBodyForDesktopWithListener(keyboard)
|
|
|
|
|
: SafeArea(child:
|
|
|
|
|
OrientationBuilder(builder: (ctx, orientation) {
|
|
|
|
|
if (_currentOrientation != orientation) {
|
|
|
|
|
Timer(const Duration(milliseconds: 200), () {
|
|
|
|
|
gFFI.dialogManager
|
|
|
|
|
.resetMobileActionsOverlay(ffi: gFFI);
|
|
|
|
|
_currentOrientation = orientation;
|
|
|
|
|
gFFI.canvasModel.updateViewStyle();
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-07-17 20:07:55 +08:00
|
|
|
|
return Obx(
|
|
|
|
|
() => Container(
|
2022-09-27 22:16:27 +08:00
|
|
|
|
color: MyTheme.canvasColor,
|
|
|
|
|
child: inputModel.isPhysicalMouse.value
|
|
|
|
|
? getBodyForMobile()
|
2023-07-17 20:07:55 +08:00
|
|
|
|
: RawTouchGestureDetectorRegion(
|
|
|
|
|
child: getBodyForMobile(),
|
|
|
|
|
ffi: gFFI,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
2022-09-27 22:16:27 +08:00
|
|
|
|
})));
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
))),
|
2020-11-29 14:19:01 +08:00
|
|
|
|
);
|
2020-11-20 16:37:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-27 22:16:27 +08:00
|
|
|
|
Widget getRawPointerAndKeyBody(Widget child) {
|
|
|
|
|
final keyboard = gFFI.ffiModel.permissions['keyboard'] != false;
|
|
|
|
|
return RawPointerMouseRegion(
|
2023-09-10 15:32:50 +08:00
|
|
|
|
cursor: keyboard ? SystemMouseCursors.none : MouseCursor.defer,
|
|
|
|
|
inputModel: inputModel,
|
2023-09-10 15:41:29 +08:00
|
|
|
|
// Disable RawKeyFocusScope before the connecting is established.
|
|
|
|
|
// The "Delete" key on the soft keyboard may be grabbed when inputting the password dialog.
|
2023-09-10 15:32:50 +08:00
|
|
|
|
child: gFFI.ffiModel.pi.isSet.isTrue
|
|
|
|
|
? RawKeyFocusScope(
|
|
|
|
|
focusNode: _physicalFocusNode,
|
|
|
|
|
inputModel: inputModel,
|
|
|
|
|
child: child)
|
|
|
|
|
: child,
|
|
|
|
|
);
|
2022-04-25 18:25:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 22:44:54 +08:00
|
|
|
|
Widget getBottomAppBar(bool keyboard) {
|
2022-02-02 01:20:14 +08:00
|
|
|
|
return BottomAppBar(
|
|
|
|
|
elevation: 10,
|
|
|
|
|
color: MyTheme.accent,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Row(
|
|
|
|
|
children: <Widget>[
|
2022-08-02 13:10:09 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.clear),
|
|
|
|
|
onPressed: () {
|
2023-06-06 07:39:44 +08:00
|
|
|
|
clientClose(sessionId, gFFI.dialogManager);
|
2022-08-02 13:10:09 +08:00
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
] +
|
2022-02-02 01:20:14 +08:00
|
|
|
|
<Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.tv),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() => _showEdit = false);
|
2022-09-29 18:56:47 +08:00
|
|
|
|
showOptions(context, widget.id, gFFI.dialogManager);
|
2022-02-02 01:20:14 +08:00
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
] +
|
2022-05-23 16:02:37 +08:00
|
|
|
|
(isWebDesktop
|
2022-02-02 01:20:14 +08:00
|
|
|
|
? []
|
2022-06-13 21:07:26 +08:00
|
|
|
|
: gFFI.ffiModel.isPeerAndroid
|
|
|
|
|
? [
|
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
2022-09-08 22:18:02 +08:00
|
|
|
|
icon: const Icon(Icons.build),
|
|
|
|
|
onPressed: () => gFFI.dialogManager
|
|
|
|
|
.toggleMobileActionsOverlay(ffi: gFFI),
|
2022-06-13 21:07:26 +08:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
: [
|
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.keyboard),
|
|
|
|
|
onPressed: openKeyboard),
|
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(gFFI.ffiModel.touchMode
|
|
|
|
|
? Icons.touch_app
|
|
|
|
|
: Icons.mouse),
|
2023-02-12 21:44:53 +08:00
|
|
|
|
onPressed: () => setState(
|
|
|
|
|
() => _showGestureHelp = !_showGestureHelp),
|
2022-06-13 21:07:26 +08:00
|
|
|
|
),
|
2022-08-02 13:10:09 +08:00
|
|
|
|
]) +
|
2022-03-28 00:36:53 +08:00
|
|
|
|
(isWeb
|
|
|
|
|
? []
|
|
|
|
|
: <Widget>[
|
2022-08-02 13:10:09 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.message),
|
|
|
|
|
onPressed: () {
|
2023-07-10 16:02:47 +08:00
|
|
|
|
gFFI.chatModel.changeCurrentKey(MessageKey(
|
2023-07-09 19:14:57 +08:00
|
|
|
|
widget.id, ChatModel.clientModeID));
|
2022-08-11 10:19:12 +08:00
|
|
|
|
gFFI.chatModel.toggleChatOverlay();
|
2022-06-13 21:07:26 +08:00
|
|
|
|
},
|
2022-08-02 13:10:09 +08:00
|
|
|
|
)
|
|
|
|
|
]) +
|
2022-03-28 00:36:53 +08:00
|
|
|
|
[
|
2022-02-02 01:20:14 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.more_vert),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() => _showEdit = false);
|
2022-08-05 20:29:43 +08:00
|
|
|
|
showActions(widget.id);
|
2022-02-02 01:20:14 +08:00
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
]),
|
2023-09-01 23:55:43 +08:00
|
|
|
|
Obx(() => IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.expand_more),
|
|
|
|
|
onPressed: gFFI.ffiModel.waitForFirstImage.isTrue
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
setState(() => _showBar = !_showBar);
|
|
|
|
|
},
|
|
|
|
|
)),
|
2022-02-02 01:20:14 +08:00
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 10:15:20 +08:00
|
|
|
|
bool get showCursorPaint =>
|
|
|
|
|
!gFFI.ffiModel.isPeerAndroid && !gFFI.canvasModel.cursorEmbedded;
|
2023-10-01 12:16:06 +08:00
|
|
|
|
|
2022-02-03 00:53:59 +08:00
|
|
|
|
Widget getBodyForMobile() {
|
2023-02-12 21:03:43 +08:00
|
|
|
|
final keyboardIsVisible = keyboardVisibilityController.isVisible;
|
2022-02-03 00:53:59 +08:00
|
|
|
|
return Container(
|
|
|
|
|
color: MyTheme.canvasColor,
|
2022-11-29 16:36:35 +08:00
|
|
|
|
child: Stack(children: () {
|
|
|
|
|
final paints = [
|
|
|
|
|
ImagePaint(),
|
2023-01-28 21:11:03 +08:00
|
|
|
|
Positioned(
|
|
|
|
|
top: 10,
|
|
|
|
|
right: 10,
|
|
|
|
|
child: QualityMonitor(gFFI.qualityMonitorModel),
|
|
|
|
|
),
|
2023-02-12 21:44:53 +08:00
|
|
|
|
KeyHelpTools(requestShow: (keyboardIsVisible || _showGestureHelp)),
|
2022-11-29 16:36:35 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
width: 0,
|
|
|
|
|
height: 0,
|
|
|
|
|
child: !_showEdit
|
|
|
|
|
? Container()
|
|
|
|
|
: TextFormField(
|
|
|
|
|
textInputAction: TextInputAction.newline,
|
|
|
|
|
autocorrect: false,
|
|
|
|
|
enableSuggestions: false,
|
|
|
|
|
autofocus: true,
|
|
|
|
|
focusNode: _mobileFocusNode,
|
|
|
|
|
maxLines: null,
|
|
|
|
|
initialValue: _value,
|
|
|
|
|
// trick way to make backspace work always
|
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
|
onChanged: handleSoftKeyboardInput,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
];
|
2023-10-01 12:16:06 +08:00
|
|
|
|
if (showCursorPaint) {
|
2022-11-29 16:36:35 +08:00
|
|
|
|
paints.add(CursorPaint());
|
|
|
|
|
}
|
|
|
|
|
return paints;
|
|
|
|
|
}()));
|
2022-02-03 00:53:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 18:25:25 +08:00
|
|
|
|
Widget getBodyForDesktopWithListener(bool keyboard) {
|
2022-02-06 16:29:56 +08:00
|
|
|
|
var paints = <Widget>[ImagePaint()];
|
2023-10-01 12:16:06 +08:00
|
|
|
|
if (showCursorPaint) {
|
2022-11-29 16:36:35 +08:00
|
|
|
|
final cursor = bind.sessionGetToggleOptionSync(
|
2023-06-06 07:39:44 +08:00
|
|
|
|
sessionId: sessionId, arg: 'show-remote-cursor');
|
2022-11-29 16:36:35 +08:00
|
|
|
|
if (keyboard || cursor) {
|
|
|
|
|
paints.add(CursorPaint());
|
|
|
|
|
}
|
2022-02-06 16:29:56 +08:00
|
|
|
|
}
|
2022-04-25 18:25:25 +08:00
|
|
|
|
return Container(
|
|
|
|
|
color: MyTheme.canvasColor, child: Stack(children: paints));
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-05 20:29:43 +08:00
|
|
|
|
void showActions(String id) async {
|
2021-08-21 17:18:14 +08:00
|
|
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
|
final x = 120.0;
|
|
|
|
|
final y = size.height;
|
2023-04-12 09:41:13 +08:00
|
|
|
|
final menus = toolbarControls(context, id, gFFI);
|
|
|
|
|
final more = menus
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) => PopupMenuItem<int>(child: e.value.child, value: e.key))
|
|
|
|
|
.toList();
|
2022-08-02 13:10:09 +08:00
|
|
|
|
() async {
|
2023-04-12 09:41:13 +08:00
|
|
|
|
var index = await showMenu(
|
2021-08-21 17:18:14 +08:00
|
|
|
|
context: context,
|
|
|
|
|
position: RelativeRect.fromLTRB(x, y, x, y),
|
2022-02-02 00:46:21 +08:00
|
|
|
|
items: more,
|
2021-08-21 17:18:14 +08:00
|
|
|
|
elevation: 8,
|
|
|
|
|
);
|
2023-04-12 09:41:13 +08:00
|
|
|
|
if (index != null && index < menus.length) {
|
|
|
|
|
menus[index].onPressed.call();
|
2021-08-21 17:18:14 +08:00
|
|
|
|
}
|
|
|
|
|
}();
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 21:44:53 +08:00
|
|
|
|
/// aka changeTouchMode
|
|
|
|
|
BottomAppBar getGestureHelp() {
|
|
|
|
|
return BottomAppBar(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
controller: ScrollController(),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
|
|
|
child: GestureHelp(
|
|
|
|
|
touchMode: gFFI.ffiModel.touchMode,
|
|
|
|
|
onTouchModeChange: (t) {
|
|
|
|
|
gFFI.ffiModel.toggleTouchMode();
|
|
|
|
|
final v = gFFI.ffiModel.touchMode ? 'Y' : '';
|
|
|
|
|
bind.sessionPeerOption(
|
2023-08-31 20:30:20 +08:00
|
|
|
|
sessionId: sessionId, name: "touch-mode", value: v);
|
2023-02-12 21:44:53 +08:00
|
|
|
|
})));
|
2022-02-24 15:59:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-09 22:14:24 +08:00
|
|
|
|
// * Currently mobile does not enable map mode
|
|
|
|
|
// void changePhysicalKeyboardInputMode() async {
|
|
|
|
|
// var current = await bind.sessionGetKeyboardMode(id: widget.id) ?? "legacy";
|
|
|
|
|
// gFFI.dialogManager.show((setState, close) {
|
|
|
|
|
// void setMode(String? v) async {
|
|
|
|
|
// await bind.sessionSetKeyboardMode(id: widget.id, value: v ?? "");
|
|
|
|
|
// setState(() => current = v ?? '');
|
|
|
|
|
// Future.delayed(Duration(milliseconds: 300), close);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return CustomAlertDialog(
|
|
|
|
|
// title: Text(translate('Physical Keyboard Input Mode')),
|
|
|
|
|
// content: Column(mainAxisSize: MainAxisSize.min, children: [
|
2023-03-30 07:51:29 +08:00
|
|
|
|
// getRadio('Legacy mode', 'legacy', current, setMode),
|
|
|
|
|
// getRadio('Map mode', 'map', current, setMode),
|
2023-02-09 22:14:24 +08:00
|
|
|
|
// ]));
|
|
|
|
|
// }, clickMaskDismiss: true);
|
|
|
|
|
// }
|
2023-02-12 21:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2023-02-12 21:20:51 +08:00
|
|
|
|
var _pin = false;
|
2023-02-12 21:44:53 +08:00
|
|
|
|
final _keyboardVisibilityController = KeyboardVisibilityController();
|
2022-09-27 22:56:18 +08:00
|
|
|
|
|
2023-02-12 21:03:43 +08:00
|
|
|
|
InputModel get inputModel => gFFI.inputModel;
|
|
|
|
|
|
|
|
|
|
Widget wrap(String text, void Function() onPressed,
|
2023-02-12 21:20:51 +08:00
|
|
|
|
{bool? active, IconData? icon}) {
|
2023-02-12 21:03:43 +08:00
|
|
|
|
return TextButton(
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
minimumSize: Size(0, 0),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 9.75),
|
|
|
|
|
//adds padding inside the button
|
|
|
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
//limits the touch area to the button area
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: active == true ? MyTheme.accent80 : null,
|
|
|
|
|
),
|
|
|
|
|
child: icon != null
|
2023-02-12 21:20:51 +08:00
|
|
|
|
? Icon(icon, size: 14, color: Colors.white)
|
2023-02-12 21:03:43 +08:00
|
|
|
|
: Text(translate(text),
|
|
|
|
|
style: TextStyle(color: Colors.white, fontSize: 11)),
|
|
|
|
|
onPressed: onPressed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-12 21:20:51 +08:00
|
|
|
|
final hasModifierOn = inputModel.ctrl ||
|
|
|
|
|
inputModel.alt ||
|
|
|
|
|
inputModel.shift ||
|
|
|
|
|
inputModel.command;
|
|
|
|
|
|
|
|
|
|
if (!_pin && !hasModifierOn && !widget.requestShow) {
|
|
|
|
|
return Offstage();
|
2020-11-25 13:03:48 +08:00
|
|
|
|
}
|
2021-08-17 15:07:01 +08:00
|
|
|
|
final size = MediaQuery.of(context).size;
|
2022-09-27 20:35:02 +08:00
|
|
|
|
|
2022-06-13 21:07:26 +08:00
|
|
|
|
final pi = gFFI.ffiModel.pi;
|
2023-01-10 17:13:40 +08:00
|
|
|
|
final isMac = pi.platform == kPeerPlatformMacOS;
|
2020-11-25 16:28:46 +08:00
|
|
|
|
final modifiers = <Widget>[
|
2021-08-17 15:07:01 +08:00
|
|
|
|
wrap('Ctrl ', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
setState(() => inputModel.ctrl = !inputModel.ctrl);
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, active: inputModel.ctrl),
|
2021-08-17 15:07:01 +08:00
|
|
|
|
wrap(' Alt ', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
setState(() => inputModel.alt = !inputModel.alt);
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, active: inputModel.alt),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
wrap('Shift', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
setState(() => inputModel.shift = !inputModel.shift);
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, active: inputModel.shift),
|
2021-08-17 15:07:01 +08:00
|
|
|
|
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
setState(() => inputModel.command = !inputModel.command);
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, active: inputModel.command),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
];
|
|
|
|
|
final keys = <Widget>[
|
|
|
|
|
wrap(
|
2021-08-17 15:07:01 +08:00
|
|
|
|
' Fn ',
|
2022-08-02 13:10:09 +08:00
|
|
|
|
() => setState(
|
2020-11-25 16:28:46 +08:00
|
|
|
|
() {
|
2022-08-02 13:10:09 +08:00
|
|
|
|
_fn = !_fn;
|
|
|
|
|
if (_fn) {
|
|
|
|
|
_more = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
2023-02-12 21:20:51 +08:00
|
|
|
|
active: _fn),
|
|
|
|
|
wrap(
|
|
|
|
|
'',
|
|
|
|
|
() => setState(
|
|
|
|
|
() => _pin = !_pin,
|
|
|
|
|
),
|
|
|
|
|
active: _pin,
|
|
|
|
|
icon: Icons.push_pin),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
wrap(
|
2021-08-17 15:07:01 +08:00
|
|
|
|
' ... ',
|
2022-08-02 13:10:09 +08:00
|
|
|
|
() => setState(
|
2020-11-25 16:28:46 +08:00
|
|
|
|
() {
|
2022-08-02 13:10:09 +08:00
|
|
|
|
_more = !_more;
|
|
|
|
|
if (_more) {
|
|
|
|
|
_fn = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
2023-02-12 21:20:51 +08:00
|
|
|
|
active: _more),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
];
|
|
|
|
|
final fn = <Widget>[
|
|
|
|
|
SizedBox(width: 9999),
|
|
|
|
|
];
|
|
|
|
|
for (var i = 1; i <= 12; ++i) {
|
2022-09-27 22:16:27 +08:00
|
|
|
|
final name = 'F$i';
|
2020-11-25 16:28:46 +08:00
|
|
|
|
fn.add(wrap(name, () {
|
2022-09-27 22:16:27 +08:00
|
|
|
|
inputModel.inputKey('VK_$name');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
final more = <Widget>[
|
|
|
|
|
SizedBox(width: 9999),
|
|
|
|
|
wrap('Esc', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_ESCAPE');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
|
|
|
|
wrap('Tab', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_TAB');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
|
|
|
|
wrap('Home', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_HOME');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
|
|
|
|
wrap('End', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_END');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
2023-02-09 22:36:24 +08:00
|
|
|
|
wrap('Ins', () {
|
|
|
|
|
inputModel.inputKey('VK_INSERT');
|
|
|
|
|
}),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
wrap('Del', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_DELETE');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
2020-11-27 02:14:27 +08:00
|
|
|
|
wrap('PgUp', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_PRIOR');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
2021-08-17 15:07:01 +08:00
|
|
|
|
wrap('PgDn', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_NEXT');
|
2020-11-25 16:28:46 +08:00
|
|
|
|
}),
|
2020-12-24 10:44:44 +08:00
|
|
|
|
SizedBox(width: 9999),
|
|
|
|
|
wrap('', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_LEFT');
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, icon: Icons.keyboard_arrow_left),
|
2020-12-24 10:44:44 +08:00
|
|
|
|
wrap('', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_UP');
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, icon: Icons.keyboard_arrow_up),
|
2020-12-24 10:44:44 +08:00
|
|
|
|
wrap('', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_DOWN');
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, icon: Icons.keyboard_arrow_down),
|
2020-12-24 10:44:44 +08:00
|
|
|
|
wrap('', () {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
inputModel.inputKey('VK_RIGHT');
|
2023-02-12 21:20:51 +08:00
|
|
|
|
}, icon: Icons.keyboard_arrow_right),
|
2021-08-11 00:22:47 +08:00
|
|
|
|
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
|
|
|
|
sendPrompt(isMac, 'VK_C');
|
2020-12-24 10:44:44 +08:00
|
|
|
|
}),
|
2021-08-11 00:22:47 +08:00
|
|
|
|
wrap(isMac ? 'Cmd+V' : 'Ctrl+V', () {
|
|
|
|
|
sendPrompt(isMac, 'VK_V');
|
2021-08-06 22:45:45 +08:00
|
|
|
|
}),
|
2021-08-11 00:22:47 +08:00
|
|
|
|
wrap(isMac ? 'Cmd+S' : 'Ctrl+S', () {
|
|
|
|
|
sendPrompt(isMac, 'VK_S');
|
2020-12-24 10:44:44 +08:00
|
|
|
|
}),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
];
|
2021-08-17 15:07:01 +08:00
|
|
|
|
final space = size.width > 320 ? 4.0 : 2.0;
|
2020-11-25 16:28:46 +08:00
|
|
|
|
return Container(
|
2020-11-27 02:14:27 +08:00
|
|
|
|
color: Color(0xAA000000),
|
2023-02-12 21:44:53 +08:00
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
top: _keyboardVisibilityController.isVisible ? 24 : 4, bottom: 8),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
child: Wrap(
|
2021-08-17 15:07:01 +08:00
|
|
|
|
spacing: space,
|
|
|
|
|
runSpacing: space,
|
2020-11-25 16:28:46 +08:00
|
|
|
|
children: <Widget>[SizedBox(width: 9999)] +
|
2023-02-12 20:26:04 +08:00
|
|
|
|
modifiers +
|
|
|
|
|
keys +
|
|
|
|
|
(_fn ? fn : []) +
|
|
|
|
|
(_more ? more : []),
|
2020-11-25 16:28:46 +08:00
|
|
|
|
));
|
2020-11-25 13:03:48 +08:00
|
|
|
|
}
|
2020-11-17 11:12:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-18 23:15:59 +08:00
|
|
|
|
class ImagePaint extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final m = Provider.of<ImageModel>(context);
|
2020-11-23 23:18:42 +08:00
|
|
|
|
final c = Provider.of<CanvasModel>(context);
|
2022-06-13 21:07:26 +08:00
|
|
|
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
2020-11-23 23:18:42 +08:00
|
|
|
|
var s = c.scale;
|
2020-11-18 23:15:59 +08:00
|
|
|
|
return CustomPaint(
|
2022-09-27 22:16:27 +08:00
|
|
|
|
painter: ImagePainter(
|
2020-11-25 11:20:40 +08:00
|
|
|
|
image: m.image, x: c.x / s, y: (c.y - adjust) / s, scale: s),
|
2020-11-19 18:22:06 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CursorPaint extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final m = Provider.of<CursorModel>(context);
|
2020-11-23 23:18:42 +08:00
|
|
|
|
final c = Provider.of<CanvasModel>(context);
|
2022-06-13 21:07:26 +08:00
|
|
|
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
2020-11-23 23:18:42 +08:00
|
|
|
|
var s = c.scale;
|
2022-11-13 23:41:07 +08:00
|
|
|
|
double hotx = m.hotx;
|
|
|
|
|
double hoty = m.hoty;
|
|
|
|
|
if (m.image == null) {
|
2022-11-22 21:34:53 +08:00
|
|
|
|
if (preDefaultCursor.image != null) {
|
|
|
|
|
hotx = preDefaultCursor.image!.width / 2;
|
|
|
|
|
hoty = preDefaultCursor.image!.height / 2;
|
2022-11-13 23:41:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-19 18:22:06 +08:00
|
|
|
|
return CustomPaint(
|
2022-09-27 22:16:27 +08:00
|
|
|
|
painter: ImagePainter(
|
2022-11-22 21:34:53 +08:00
|
|
|
|
image: m.image ?? preDefaultCursor.image,
|
2022-11-14 11:35:59 +08:00
|
|
|
|
x: m.x * s - hotx * s + c.x,
|
|
|
|
|
y: m.y * s - hoty * s + c.y - adjust,
|
2020-11-23 23:18:42 +08:00
|
|
|
|
scale: 1),
|
2020-11-18 23:15:59 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 18:56:47 +08:00
|
|
|
|
void showOptions(
|
|
|
|
|
BuildContext context, String id, OverlayDialogManager dialogManager) async {
|
2020-11-25 23:52:58 +08:00
|
|
|
|
var displays = <Widget>[];
|
2022-06-13 21:07:26 +08:00
|
|
|
|
final pi = gFFI.ffiModel.pi;
|
|
|
|
|
final image = gFFI.ffiModel.getConnectionImage();
|
2022-09-16 20:31:01 +08:00
|
|
|
|
if (image != null) {
|
2020-11-29 00:13:55 +08:00
|
|
|
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
2022-09-16 20:31:01 +08:00
|
|
|
|
}
|
2020-11-25 23:52:58 +08:00
|
|
|
|
if (pi.displays.length > 1) {
|
|
|
|
|
final cur = pi.currentDisplay;
|
|
|
|
|
final children = <Widget>[];
|
2022-09-16 20:31:01 +08:00
|
|
|
|
for (var i = 0; i < pi.displays.length; ++i) {
|
2020-11-25 23:52:58 +08:00
|
|
|
|
children.add(InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
if (i == cur) return;
|
2023-06-06 07:39:44 +08:00
|
|
|
|
bind.sessionSwitchDisplay(sessionId: gFFI.sessionId, value: i);
|
2022-08-12 18:42:02 +08:00
|
|
|
|
gFFI.dialogManager.dismissAll();
|
2020-11-25 23:52:58 +08:00
|
|
|
|
},
|
|
|
|
|
child: Ink(
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
|
|
|
|
decoration: BoxDecoration(
|
2022-09-29 18:56:47 +08:00
|
|
|
|
border: Border.all(color: Theme.of(context).hintColor),
|
|
|
|
|
borderRadius: BorderRadius.circular(2),
|
|
|
|
|
color: i == cur
|
|
|
|
|
? Theme.of(context).toggleableActiveColor.withOpacity(0.6)
|
|
|
|
|
: null),
|
2020-11-25 23:52:58 +08:00
|
|
|
|
child: Center(
|
|
|
|
|
child: Text((i + 1).toString(),
|
|
|
|
|
style: TextStyle(
|
2022-09-29 18:56:47 +08:00
|
|
|
|
color: i == cur ? Colors.white : Colors.black87,
|
|
|
|
|
fontWeight: FontWeight.bold))))));
|
2022-09-16 20:31:01 +08:00
|
|
|
|
}
|
2020-11-25 23:52:58 +08:00
|
|
|
|
displays.add(Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 8),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
spacing: 8,
|
|
|
|
|
children: children,
|
|
|
|
|
)));
|
2020-11-29 00:13:55 +08:00
|
|
|
|
}
|
|
|
|
|
if (displays.isNotEmpty) {
|
2022-09-16 20:31:01 +08:00
|
|
|
|
displays.add(const Divider(color: MyTheme.border));
|
2020-11-25 23:52:58 +08:00
|
|
|
|
}
|
2022-03-13 00:32:44 +08:00
|
|
|
|
|
2023-04-12 09:41:13 +08:00
|
|
|
|
List<TRadioMenu<String>> viewStyleRadios =
|
|
|
|
|
await toolbarViewStyle(context, id, gFFI);
|
|
|
|
|
List<TRadioMenu<String>> imageQualityRadios =
|
|
|
|
|
await toolbarImageQuality(context, id, gFFI);
|
|
|
|
|
List<TRadioMenu<String>> codecRadios = await toolbarCodec(context, id, gFFI);
|
|
|
|
|
List<TToggleMenu> displayToggles =
|
|
|
|
|
await toolbarDisplayToggle(context, id, gFFI);
|
2022-09-16 20:31:01 +08:00
|
|
|
|
|
2023-05-08 12:34:19 +08:00
|
|
|
|
dialogManager.show((setState, close, context) {
|
2023-04-12 09:41:13 +08:00
|
|
|
|
var viewStyle =
|
|
|
|
|
(viewStyleRadios.isNotEmpty ? viewStyleRadios[0].groupValue : '').obs;
|
|
|
|
|
var imageQuality =
|
|
|
|
|
(imageQualityRadios.isNotEmpty ? imageQualityRadios[0].groupValue : '')
|
|
|
|
|
.obs;
|
|
|
|
|
var codec = (codecRadios.isNotEmpty ? codecRadios[0].groupValue : '').obs;
|
2022-09-16 20:31:01 +08:00
|
|
|
|
final radios = [
|
2023-04-12 09:41:13 +08:00
|
|
|
|
for (var e in viewStyleRadios)
|
|
|
|
|
Obx(() => getRadio<String>(e.child, e.value, viewStyle.value, (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) viewStyle.value = v;
|
|
|
|
|
})),
|
2022-09-16 20:31:01 +08:00
|
|
|
|
const Divider(color: MyTheme.border),
|
2023-04-12 09:41:13 +08:00
|
|
|
|
for (var e in imageQualityRadios)
|
|
|
|
|
Obx(() => getRadio<String>(e.child, e.value, imageQuality.value, (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) imageQuality.value = v;
|
|
|
|
|
})),
|
|
|
|
|
const Divider(color: MyTheme.border),
|
|
|
|
|
for (var e in codecRadios)
|
|
|
|
|
Obx(() => getRadio<String>(e.child, e.value, codec.value, (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) codec.value = v;
|
|
|
|
|
})),
|
|
|
|
|
if (codecRadios.isNotEmpty) const Divider(color: MyTheme.border),
|
2022-09-16 20:31:01 +08:00
|
|
|
|
];
|
2023-04-12 09:41:13 +08:00
|
|
|
|
final rxToggleValues = displayToggles.map((e) => e.value.obs).toList();
|
|
|
|
|
final toggles = displayToggles
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) => Obx(() => CheckboxListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
value: rxToggleValues[e.key].value,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
e.value.onChanged?.call(v);
|
|
|
|
|
if (v != null) rxToggleValues[e.key].value = v;
|
|
|
|
|
},
|
|
|
|
|
title: e.value.child)))
|
|
|
|
|
.toList();
|
2022-09-16 20:31:01 +08:00
|
|
|
|
|
2022-03-13 00:32:44 +08:00
|
|
|
|
return CustomAlertDialog(
|
2022-03-13 23:07:52 +08:00
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2023-04-12 09:41:13 +08:00
|
|
|
|
children: displays + radios + toggles),
|
2022-03-13 00:32:44 +08:00
|
|
|
|
);
|
2022-04-21 10:02:47 +08:00
|
|
|
|
}, clickMaskDismiss: true, backDismiss: true);
|
2022-08-04 17:24:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-11 00:22:47 +08:00
|
|
|
|
void sendPrompt(bool isMac, String key) {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
final old = isMac ? gFFI.inputModel.command : gFFI.inputModel.ctrl;
|
2021-08-11 00:22:47 +08:00
|
|
|
|
if (isMac) {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.command = true;
|
2021-08-11 00:22:47 +08:00
|
|
|
|
} else {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.ctrl = true;
|
2021-08-11 00:22:47 +08:00
|
|
|
|
}
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.inputKey(key);
|
2021-08-11 00:22:47 +08:00
|
|
|
|
if (isMac) {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.command = old;
|
2021-08-11 00:22:47 +08:00
|
|
|
|
} else {
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.ctrl = old;
|
2021-08-11 00:22:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-09 21:55:56 +08:00
|
|
|
|
|
|
|
|
|
class FABLocation extends FloatingActionButtonLocation {
|
|
|
|
|
FloatingActionButtonLocation location;
|
|
|
|
|
double offsetX;
|
|
|
|
|
double offsetY;
|
|
|
|
|
FABLocation(this.location, this.offsetX, this.offsetY);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
|
|
|
|
|
final offset = location.getOffset(scaffoldGeometry);
|
|
|
|
|
return Offset(offset.dx + offsetX, offset.dy + offsetY);
|
|
|
|
|
}
|
|
|
|
|
}
|