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';
|
2024-05-14 09:20:27 +08:00
|
|
|
|
import 'package:flutter_svg/svg.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';
|
2023-10-31 21:10:23 +08:00
|
|
|
|
import 'package:wakelock_plus/wakelock_plus.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';
|
2023-11-14 17:35:16 +08:00
|
|
|
|
import '../widgets/dialog.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 {
|
2024-03-20 15:05:54 +08:00
|
|
|
|
RemotePage({Key? key, required this.id, this.password, this.isSharedPassword})
|
|
|
|
|
: super(key: key);
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
|
|
|
|
final String id;
|
2024-03-20 15:05:54 +08:00
|
|
|
|
final String? password;
|
|
|
|
|
final bool? isSharedPassword;
|
2020-11-17 01:22:14 +08:00
|
|
|
|
|
|
|
|
|
@override
|
2024-07-25 10:45:51 +08:00
|
|
|
|
State<RemotePage> createState() => _RemotePageState(id);
|
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
|
|
|
|
|
2024-06-26 00:24:57 +08:00
|
|
|
|
final TextEditingController _textController =
|
|
|
|
|
TextEditingController(text: initText);
|
|
|
|
|
|
2024-07-25 10:45:51 +08:00
|
|
|
|
_RemotePageState(String id) {
|
|
|
|
|
initSharedStates(id);
|
|
|
|
|
gFFI.chatModel.voiceCallStatus.value = VoiceCallStatus.notStarted;
|
|
|
|
|
gFFI.dialogManager.loadMobileActionsOverlayVisible();
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-17 11:12:55 +08:00
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2024-03-24 11:23:06 +08:00
|
|
|
|
gFFI.ffiModel.updateEventListener(sessionId, widget.id);
|
2024-03-20 15:05:54 +08:00
|
|
|
|
gFFI.start(
|
|
|
|
|
widget.id,
|
|
|
|
|
password: widget.password,
|
|
|
|
|
isSharedPassword: widget.isSharedPassword,
|
|
|
|
|
);
|
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
|
|
|
|
});
|
2024-04-10 21:32:05 +08:00
|
|
|
|
if (!isWeb) {
|
|
|
|
|
WakelockPlus.enable();
|
|
|
|
|
}
|
2022-04-25 18:25:25 +08:00
|
|
|
|
_physicalFocusNode.requestFocus();
|
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-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();
|
2024-06-23 11:06:47 +08:00
|
|
|
|
gFFI.dialogManager.hideMobileActionsOverlay(store: false);
|
2022-09-27 20:35:02 +08:00
|
|
|
|
gFFI.inputModel.listenToMouse(false);
|
2024-05-27 09:27:30 +08:00
|
|
|
|
gFFI.imageModel.disposeImage();
|
|
|
|
|
gFFI.cursorModel.disposeImages();
|
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);
|
2024-04-10 21:32:05 +08:00
|
|
|
|
if (!isWeb) {
|
|
|
|
|
await WakelockPlus.disable();
|
|
|
|
|
}
|
2023-06-28 17:09:23 +08:00
|
|
|
|
await keyboardSubscription.cancel();
|
2023-04-12 09:41:13 +08:00
|
|
|
|
removeSharedStates(widget.id);
|
2024-06-21 16:43:54 +08:00
|
|
|
|
// `on_voice_call_closed` should be called when the connection is ended.
|
|
|
|
|
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
|
|
|
|
|
// Only one client is considered here for now.
|
|
|
|
|
gFFI.chatModel.onVoiceCallClosed("End connetion");
|
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);
|
|
|
|
|
}
|
2023-11-17 14:08:21 +08:00
|
|
|
|
} else {
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
|
|
|
|
overlays: SystemUiOverlay.values);
|
|
|
|
|
_mobileFocusNode.requestFocus();
|
|
|
|
|
});
|
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
|
|
|
|
}
|
|
|
|
|
|
2024-06-26 00:24:57 +08:00
|
|
|
|
void _handleIOSSoftKeyboardInput(String newValue) {
|
2021-08-17 22:57:35 +08:00
|
|
|
|
var oldValue = _value;
|
|
|
|
|
_value = newValue;
|
2024-06-26 00:24:57 +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;
|
|
|
|
|
var subNewValue = newValue.substring(j + 1);
|
|
|
|
|
var subOldValue = oldValue.substring(j + 1);
|
|
|
|
|
|
|
|
|
|
// get common prefix of subNewValue and subOldValue
|
|
|
|
|
var common = 0;
|
|
|
|
|
for (;
|
|
|
|
|
common < subOldValue.length &&
|
|
|
|
|
common < subNewValue.length &&
|
|
|
|
|
subNewValue[common] == subOldValue[common];
|
|
|
|
|
++common) {}
|
|
|
|
|
|
|
|
|
|
// get newStr from subNewValue
|
|
|
|
|
var newStr = "";
|
|
|
|
|
if (subNewValue.length > common) {
|
|
|
|
|
newStr = subNewValue.substring(common);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the value to the old value and early return if is still composing. (1 && 2)
|
|
|
|
|
// 1. The composing range is valid
|
|
|
|
|
// 2. The new string is shorter than the composing range.
|
|
|
|
|
if (_textController.value.isComposingRangeValid) {
|
|
|
|
|
final composingLength = _textController.value.composing.end -
|
|
|
|
|
_textController.value.composing.start;
|
|
|
|
|
if (composingLength > newStr.length) {
|
|
|
|
|
_value = oldValue;
|
|
|
|
|
return;
|
2021-08-17 22:57:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-26 00:24:57 +08:00
|
|
|
|
|
|
|
|
|
// Delete the different part in the old value.
|
|
|
|
|
for (i = 0; i < subOldValue.length - common; ++i) {
|
|
|
|
|
inputModel.inputKey('VK_BACK');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Input the new string.
|
|
|
|
|
if (newStr.length > 1) {
|
|
|
|
|
bind.sessionInputString(sessionId: sessionId, value: newStr);
|
|
|
|
|
} else {
|
|
|
|
|
inputChar(newStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _handleNonIOSSoftKeyboardInput(String newValue) {
|
|
|
|
|
var oldValue = _value;
|
|
|
|
|
_value = newValue;
|
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
|
|
|
|
}
|
|
|
|
|
|
2024-06-26 00:24:57 +08:00
|
|
|
|
// handle mobile virtual keyboard
|
|
|
|
|
void handleSoftKeyboardInput(String newValue) {
|
|
|
|
|
if (isIOS) {
|
|
|
|
|
_handleIOSSoftKeyboardInput(newValue);
|
|
|
|
|
} else {
|
|
|
|
|
_handleNonIOSSoftKeyboardInput(newValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2024-06-26 00:24:57 +08:00
|
|
|
|
_textController.text = _value;
|
2021-09-01 01:35:01 +08:00
|
|
|
|
setState(() => _showEdit = false);
|
2020-11-28 18:06:27 +08:00
|
|
|
|
_timer?.cancel();
|
2023-11-17 14:08:21 +08:00
|
|
|
|
_timer = Timer(kMobileDelaySoftKeyboard, () {
|
2020-11-28 18:06:27 +08:00
|
|
|
|
// show now, and sleep a while to requestFocus to
|
2024-04-24 14:16:19 +08:00
|
|
|
|
// make sure edit ready, so that keyboard won't 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();
|
2023-11-17 14:08:21 +08:00
|
|
|
|
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
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
|
|
|
|
Widget _bottomWidget() => _showGestureHelp
|
|
|
|
|
? getGestureHelp()
|
|
|
|
|
: (_showBar && gFFI.ffiModel.pi.displays.isNotEmpty
|
2024-07-14 15:04:35 +08:00
|
|
|
|
? getBottomAppBar()
|
2023-09-01 23:55:43 +08:00
|
|
|
|
: 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;
|
|
|
|
|
},
|
2023-10-22 20:35:43 +08:00
|
|
|
|
child: 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
|
|
|
|
],
|
|
|
|
|
)),
|
2024-03-26 10:45:06 +08:00
|
|
|
|
body: Obx(
|
|
|
|
|
() => getRawPointerAndKeyBody(Overlay(
|
|
|
|
|
initialEntries: [
|
|
|
|
|
OverlayEntry(builder: (context) {
|
|
|
|
|
return Container(
|
2024-05-27 09:29:31 +08:00
|
|
|
|
color: kColorCanvas,
|
2022-09-27 22:16:27 +08:00
|
|
|
|
child: isWebDesktop
|
2024-07-14 15:04:35 +08:00
|
|
|
|
? getBodyForDesktopWithListener()
|
2024-03-26 10:45:06 +08:00
|
|
|
|
: SafeArea(
|
|
|
|
|
child:
|
|
|
|
|
OrientationBuilder(builder: (ctx, orientation) {
|
|
|
|
|
if (_currentOrientation != orientation) {
|
|
|
|
|
Timer(const Duration(milliseconds: 200), () {
|
|
|
|
|
gFFI.dialogManager
|
|
|
|
|
.resetMobileActionsOverlay(ffi: gFFI);
|
|
|
|
|
_currentOrientation = orientation;
|
|
|
|
|
gFFI.canvasModel.updateViewStyle();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return 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,
|
|
|
|
|
),
|
2024-03-26 10:45:06 +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) {
|
2024-07-14 15:04:35 +08:00
|
|
|
|
final ffiModel = Provider.of<FfiModel>(context);
|
2022-09-27 22:16:27 +08:00
|
|
|
|
return RawPointerMouseRegion(
|
2024-07-14 15:04:35 +08:00
|
|
|
|
cursor: ffiModel.keyboard ? SystemMouseCursors.none : MouseCursor.defer,
|
2023-09-10 15:32:50 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2024-07-14 15:04:35 +08:00
|
|
|
|
Widget getBottomAppBar() {
|
|
|
|
|
final ffiModel = Provider.of<FfiModel>(context);
|
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
|
|
|
|
},
|
2024-05-14 09:20:27 +08:00
|
|
|
|
),
|
2022-02-02 01:20:14 +08:00
|
|
|
|
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
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
] +
|
2024-07-14 15:04:35 +08:00
|
|
|
|
(isWebDesktop || ffiModel.viewOnly || !ffiModel.keyboard
|
2022-02-02 01:20:14 +08:00
|
|
|
|
? []
|
2022-06-13 21:07:26 +08:00
|
|
|
|
: gFFI.ffiModel.isPeerAndroid
|
|
|
|
|
? [
|
2023-10-17 22:12:52 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: Icon(Icons.keyboard),
|
|
|
|
|
onPressed: openKeyboard),
|
2022-06-13 21:07:26 +08:00
|
|
|
|
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>[
|
2024-06-22 08:10:54 +08:00
|
|
|
|
futureBuilder(
|
|
|
|
|
future: gFFI.invokeMethod(
|
|
|
|
|
"get_value", "KEY_IS_SUPPORT_VOICE_CALL"),
|
|
|
|
|
hasData: (isSupportVoiceCall) => IconButton(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
icon: isAndroid && isSupportVoiceCall
|
|
|
|
|
? SvgPicture.asset('assets/chat.svg',
|
|
|
|
|
colorFilter: ColorFilter.mode(
|
|
|
|
|
Colors.white, BlendMode.srcIn))
|
|
|
|
|
: Icon(Icons.message),
|
|
|
|
|
onPressed: () =>
|
|
|
|
|
isAndroid && isSupportVoiceCall
|
|
|
|
|
? showChatOptions(widget.id)
|
|
|
|
|
: onPressedTextChat(widget.id),
|
|
|
|
|
))
|
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()
|
2023-11-17 14:08:21 +08:00
|
|
|
|
: TextFormField(
|
2022-11-29 16:36:35 +08:00
|
|
|
|
textInputAction: TextInputAction.newline,
|
|
|
|
|
autocorrect: false,
|
2024-06-20 20:20:32 +08:00
|
|
|
|
// Flutter 3.16.9 Android.
|
|
|
|
|
// `enableSuggestions` causes secure keyboard to be shown.
|
|
|
|
|
// https://github.com/flutter/flutter/issues/139143
|
|
|
|
|
// https://github.com/flutter/flutter/issues/146540
|
|
|
|
|
// enableSuggestions: false,
|
2022-11-29 16:36:35 +08:00
|
|
|
|
autofocus: true,
|
|
|
|
|
focusNode: _mobileFocusNode,
|
|
|
|
|
maxLines: null,
|
2024-06-26 00:24:57 +08:00
|
|
|
|
controller: _textController,
|
2022-11-29 16:36:35 +08:00
|
|
|
|
// trick way to make backspace work always
|
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
|
onChanged: handleSoftKeyboardInput,
|
2023-11-17 14:08:21 +08:00
|
|
|
|
),
|
2022-11-29 16:36:35 +08:00
|
|
|
|
),
|
|
|
|
|
];
|
2023-10-01 12:16:06 +08:00
|
|
|
|
if (showCursorPaint) {
|
2024-07-14 15:04:35 +08:00
|
|
|
|
paints.add(CursorPaint(widget.id));
|
2022-11-29 16:36:35 +08:00
|
|
|
|
}
|
|
|
|
|
return paints;
|
|
|
|
|
}()));
|
2022-02-03 00:53:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-14 15:04:35 +08:00
|
|
|
|
Widget getBodyForDesktopWithListener() {
|
|
|
|
|
final ffiModel = Provider.of<FfiModel>(context);
|
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');
|
2024-07-14 15:04:35 +08:00
|
|
|
|
if (ffiModel.keyboard || cursor) {
|
|
|
|
|
paints.add(CursorPaint(widget.id));
|
2022-11-29 16:36:35 +08:00
|
|
|
|
}
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-28 00:57:16 +08:00
|
|
|
|
List<TTextMenu> _getMobileActionMenus() {
|
|
|
|
|
if (gFFI.ffiModel.pi.platform != kPeerPlatformAndroid ||
|
|
|
|
|
!gFFI.ffiModel.keyboard) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2024-06-29 11:50:40 +08:00
|
|
|
|
final enabled = versionCmp(gFFI.ffiModel.pi.version, '1.2.7') >= 0;
|
|
|
|
|
if (!enabled) return [];
|
2024-06-28 00:57:16 +08:00
|
|
|
|
return [
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Back')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobileBack(),
|
|
|
|
|
),
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Home')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobileHome(),
|
|
|
|
|
),
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Apps')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobileApps(),
|
|
|
|
|
),
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Volume up')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobileVolumeUp(),
|
|
|
|
|
),
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Volume down')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobileVolumeDown(),
|
|
|
|
|
),
|
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate('Power')),
|
|
|
|
|
onPressed: () => gFFI.inputModel.onMobilePower(),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2024-06-28 00:57:16 +08:00
|
|
|
|
final mobileActionMenus = _getMobileActionMenus();
|
2023-04-12 09:41:13 +08:00
|
|
|
|
final menus = toolbarControls(context, id, gFFI);
|
2023-11-22 16:14:42 +08:00
|
|
|
|
|
2024-06-28 00:57:16 +08:00
|
|
|
|
final List<PopupMenuEntry<int>> more = [
|
|
|
|
|
...mobileActionMenus
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) =>
|
|
|
|
|
PopupMenuItem<int>(child: e.value.getChild(), value: e.key))
|
|
|
|
|
.toList(),
|
|
|
|
|
if (mobileActionMenus.isNotEmpty) PopupMenuDivider(),
|
|
|
|
|
...menus
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) => PopupMenuItem<int>(
|
|
|
|
|
child: e.value.getChild(),
|
|
|
|
|
value: e.key + mobileActionMenus.length))
|
|
|
|
|
.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,
|
|
|
|
|
);
|
2024-06-28 00:57:16 +08:00
|
|
|
|
if (index != null) {
|
|
|
|
|
if (index < mobileActionMenus.length) {
|
|
|
|
|
mobileActionMenus[index].onPressed.call();
|
|
|
|
|
} else if (index < mobileActionMenus.length + more.length) {
|
|
|
|
|
menus[index - mobileActionMenus.length].onPressed.call();
|
|
|
|
|
}
|
2021-08-21 17:18:14 +08:00
|
|
|
|
}
|
|
|
|
|
}();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 09:20:27 +08:00
|
|
|
|
onPressedTextChat(String id) {
|
|
|
|
|
gFFI.chatModel.changeCurrentKey(MessageKey(id, ChatModel.clientModeID));
|
|
|
|
|
gFFI.chatModel.toggleChatOverlay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showChatOptions(String id) async {
|
|
|
|
|
onPressVoiceCall() => bind.sessionRequestVoiceCall(sessionId: sessionId);
|
|
|
|
|
onPressEndVoiceCall() => bind.sessionCloseVoiceCall(sessionId: sessionId);
|
|
|
|
|
|
2024-05-14 15:35:34 +08:00
|
|
|
|
makeTextMenu(String label, Widget icon, VoidCallback onPressed,
|
|
|
|
|
{TextStyle? labelStyle}) =>
|
2024-05-14 09:20:27 +08:00
|
|
|
|
TTextMenu(
|
|
|
|
|
child: Text(translate(label), style: labelStyle),
|
|
|
|
|
trailingIcon: Transform.scale(
|
|
|
|
|
scale: (isDesktop || isWebDesktop) ? 0.8 : 1,
|
2024-06-25 00:31:41 +08:00
|
|
|
|
child: IgnorePointer(
|
|
|
|
|
child: IconButton(
|
|
|
|
|
onPressed: null,
|
|
|
|
|
icon: icon,
|
|
|
|
|
),
|
2024-05-14 09:20:27 +08:00
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: onPressed,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final isInVoice = [
|
|
|
|
|
VoiceCallStatus.waitingForResponse,
|
|
|
|
|
VoiceCallStatus.connected
|
|
|
|
|
].contains(gFFI.chatModel.voiceCallStatus.value);
|
|
|
|
|
final menus = [
|
2024-05-14 15:35:34 +08:00
|
|
|
|
makeTextMenu('Text chat', Icon(Icons.message, color: MyTheme.accent),
|
|
|
|
|
() => onPressedTextChat(widget.id)),
|
2024-05-14 09:20:27 +08:00
|
|
|
|
isInVoice
|
|
|
|
|
? makeTextMenu(
|
2024-05-14 15:35:34 +08:00
|
|
|
|
'End voice call',
|
|
|
|
|
SvgPicture.asset(
|
|
|
|
|
'assets/call_wait.svg',
|
|
|
|
|
colorFilter:
|
|
|
|
|
ColorFilter.mode(Colors.redAccent, BlendMode.srcIn),
|
|
|
|
|
),
|
|
|
|
|
onPressEndVoiceCall,
|
2024-05-14 09:20:27 +08:00
|
|
|
|
labelStyle: TextStyle(color: Colors.redAccent))
|
|
|
|
|
: makeTextMenu(
|
2024-05-14 15:35:34 +08:00
|
|
|
|
'Voice call',
|
|
|
|
|
SvgPicture.asset(
|
|
|
|
|
'assets/call_wait.svg',
|
|
|
|
|
colorFilter: ColorFilter.mode(MyTheme.accent, BlendMode.srcIn),
|
|
|
|
|
),
|
|
|
|
|
onPressVoiceCall),
|
2024-05-14 09:20:27 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
final menuItems = menus
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
2024-06-28 00:57:16 +08:00
|
|
|
|
.map((e) => PopupMenuItem<int>(child: e.value.getChild(), value: e.key))
|
2024-05-14 09:20:27 +08:00
|
|
|
|
.toList();
|
|
|
|
|
Future.delayed(Duration.zero, () async {
|
|
|
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
|
final x = 120.0;
|
|
|
|
|
final y = size.height;
|
|
|
|
|
var index = await showMenu(
|
|
|
|
|
context: context,
|
|
|
|
|
position: RelativeRect.fromLTRB(x, y, x, y),
|
|
|
|
|
items: menuItems,
|
|
|
|
|
elevation: 8,
|
|
|
|
|
);
|
|
|
|
|
if (index != null && index < menus.length) {
|
|
|
|
|
menus[index].onPressed.call();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
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(
|
2024-05-18 23:13:54 +08:00
|
|
|
|
sessionId: sessionId, name: kOptionTouchMode, 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();
|
2024-06-19 15:58:23 +08:00
|
|
|
|
final _key = GlobalKey();
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-19 15:58:23 +08:00
|
|
|
|
_updateRect() {
|
|
|
|
|
RenderObject? renderObject = _key.currentContext?.findRenderObject();
|
|
|
|
|
if (renderObject == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (renderObject is RenderBox) {
|
|
|
|
|
final size = renderObject.size;
|
|
|
|
|
Offset pos = renderObject.localToGlobal(Offset.zero);
|
2024-06-20 22:18:57 +08:00
|
|
|
|
gFFI.cursorModel.keyHelpToolsVisibilityChanged(
|
|
|
|
|
Rect.fromLTWH(pos.dx, pos.dy, size.width, size.height));
|
2024-06-19 15:58:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 21:03:43 +08:00
|
|
|
|
@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) {
|
2024-06-20 22:18:57 +08:00
|
|
|
|
gFFI.cursorModel.keyHelpToolsVisibilityChanged(null);
|
2023-02-12 21:20:51 +08:00
|
|
|
|
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;
|
2024-06-19 15:58:23 +08:00
|
|
|
|
// 500 ms is long enough for this widget to be built!
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
_updateRect();
|
|
|
|
|
});
|
2020-11-25 16:28:46 +08:00
|
|
|
|
return Container(
|
2024-06-19 15:58:23 +08:00
|
|
|
|
key: _key,
|
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);
|
2024-06-20 12:22:36 +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 {
|
2024-07-14 15:04:35 +08:00
|
|
|
|
late final String id;
|
|
|
|
|
CursorPaint(this.id);
|
|
|
|
|
|
2020-11-19 18:22:06 +08:00
|
|
|
|
@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);
|
2024-07-14 15:04:35 +08:00
|
|
|
|
final ffiModel = Provider.of<FfiModel>(context);
|
2024-06-20 12:22:36 +08:00
|
|
|
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
2024-06-26 18:42:08 +08:00
|
|
|
|
final s = c.scale;
|
2022-11-13 23:41:07 +08:00
|
|
|
|
double hotx = m.hotx;
|
|
|
|
|
double hoty = m.hoty;
|
2024-07-14 15:04:35 +08:00
|
|
|
|
var image = m.image;
|
|
|
|
|
if (image == null) {
|
2022-11-22 21:34:53 +08:00
|
|
|
|
if (preDefaultCursor.image != null) {
|
2024-07-14 15:04:35 +08:00
|
|
|
|
image = preDefaultCursor.image;
|
2022-11-22 21:34:53 +08:00
|
|
|
|
hotx = preDefaultCursor.image!.width / 2;
|
|
|
|
|
hoty = preDefaultCursor.image!.height / 2;
|
2022-11-13 23:41:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-14 15:04:35 +08:00
|
|
|
|
if (preForbiddenCursor.image != null &&
|
|
|
|
|
!ffiModel.viewOnly &&
|
|
|
|
|
!ffiModel.keyboard &&
|
|
|
|
|
!ShowRemoteCursorState.find(id).value) {
|
|
|
|
|
image = preForbiddenCursor.image;
|
|
|
|
|
hotx = preForbiddenCursor.image!.width / 2;
|
|
|
|
|
hoty = preForbiddenCursor.image!.height / 2;
|
|
|
|
|
}
|
2024-06-26 19:49:52 +08:00
|
|
|
|
if (image == null) {
|
|
|
|
|
return Offstage();
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 23:19:37 +08:00
|
|
|
|
final minSize = 12.0;
|
2024-06-26 18:42:08 +08:00
|
|
|
|
double mins =
|
2024-06-26 19:49:52 +08:00
|
|
|
|
minSize / (image.width > image.height ? image.width : image.height);
|
2024-06-26 18:42:08 +08:00
|
|
|
|
double factor = 1.0;
|
|
|
|
|
if (s < mins) {
|
|
|
|
|
factor = s / mins;
|
|
|
|
|
}
|
|
|
|
|
final s2 = s < mins ? mins : s;
|
2020-11-19 18:22:06 +08:00
|
|
|
|
return CustomPaint(
|
2022-09-27 22:16:27 +08:00
|
|
|
|
painter: ImagePainter(
|
2024-06-26 18:42:08 +08:00
|
|
|
|
image: image,
|
|
|
|
|
x: (m.x - hotx) * factor + c.x / s2,
|
|
|
|
|
y: (m.y - hoty) * factor + (c.y - adjust) / s2,
|
|
|
|
|
scale: s2),
|
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
|
|
|
|
}
|
2023-10-08 21:44:54 +08:00
|
|
|
|
if (pi.displays.length > 1 && pi.currentDisplay != kAllDisplayValue) {
|
2020-11-25 23:52:58 +08:00
|
|
|
|
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-11-29 12:30:41 +08:00
|
|
|
|
openMonitorInTheSameTab(i, gFFI, pi);
|
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
|
2024-06-21 12:33:05 +08:00
|
|
|
|
? Theme.of(context).primaryColor.withOpacity(0.6)
|
2022-09-29 18:56:47 +08:00
|
|
|
|
: 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);
|
2024-04-25 13:26:02 +08:00
|
|
|
|
List<TToggleMenu> cursorToggles = await toolbarCursor(context, id, gFFI);
|
2023-04-12 09:41:13 +08:00
|
|
|
|
List<TToggleMenu> displayToggles =
|
|
|
|
|
await toolbarDisplayToggle(context, id, gFFI);
|
2022-09-16 20:31:01 +08:00
|
|
|
|
|
2023-11-14 17:35:16 +08:00
|
|
|
|
List<TToggleMenu> privacyModeList = [];
|
|
|
|
|
// privacy mode
|
|
|
|
|
final privacyModeState = PrivacyModeState.find(id);
|
|
|
|
|
if (gFFI.ffiModel.keyboard && gFFI.ffiModel.pi.features.privacyMode) {
|
|
|
|
|
privacyModeList = toolbarPrivacyMode(privacyModeState, context, id, gFFI);
|
|
|
|
|
if (privacyModeList.length == 1) {
|
|
|
|
|
displayToggles.add(privacyModeList[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
2024-07-14 15:04:35 +08:00
|
|
|
|
Obx(() => getRadio<String>(
|
|
|
|
|
e.child,
|
|
|
|
|
e.value,
|
|
|
|
|
viewStyle.value,
|
|
|
|
|
e.onChanged != null
|
|
|
|
|
? (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) viewStyle.value = v;
|
|
|
|
|
}
|
|
|
|
|
: null)),
|
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)
|
2024-07-14 15:04:35 +08:00
|
|
|
|
Obx(() => getRadio<String>(
|
|
|
|
|
e.child,
|
|
|
|
|
e.value,
|
|
|
|
|
imageQuality.value,
|
|
|
|
|
e.onChanged != null
|
|
|
|
|
? (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) imageQuality.value = v;
|
|
|
|
|
}
|
|
|
|
|
: null)),
|
2023-04-12 09:41:13 +08:00
|
|
|
|
const Divider(color: MyTheme.border),
|
|
|
|
|
for (var e in codecRadios)
|
2024-07-14 15:04:35 +08:00
|
|
|
|
Obx(() => getRadio<String>(
|
|
|
|
|
e.child,
|
|
|
|
|
e.value,
|
|
|
|
|
codec.value,
|
|
|
|
|
e.onChanged != null
|
|
|
|
|
? (v) {
|
|
|
|
|
e.onChanged?.call(v);
|
|
|
|
|
if (v != null) codec.value = v;
|
|
|
|
|
}
|
|
|
|
|
: null)),
|
2023-04-12 09:41:13 +08:00
|
|
|
|
if (codecRadios.isNotEmpty) const Divider(color: MyTheme.border),
|
2022-09-16 20:31:01 +08:00
|
|
|
|
];
|
2024-04-25 13:26:02 +08:00
|
|
|
|
final rxCursorToggleValues = cursorToggles.map((e) => e.value.obs).toList();
|
|
|
|
|
final cursorTogglesList = cursorToggles
|
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) => Obx(() => CheckboxListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
value: rxCursorToggleValues[e.key].value,
|
2024-07-14 15:04:35 +08:00
|
|
|
|
onChanged: e.value.onChanged != null
|
|
|
|
|
? (v) {
|
|
|
|
|
e.value.onChanged?.call(v);
|
|
|
|
|
if (v != null) rxCursorToggleValues[e.key].value = v;
|
|
|
|
|
}
|
|
|
|
|
: null,
|
2024-04-25 13:26:02 +08:00
|
|
|
|
title: e.value.child)))
|
|
|
|
|
.toList();
|
|
|
|
|
|
2023-04-12 09:41:13 +08:00
|
|
|
|
final rxToggleValues = displayToggles.map((e) => e.value.obs).toList();
|
2024-04-25 13:26:02 +08:00
|
|
|
|
final displayTogglesList = displayToggles
|
2023-04-12 09:41:13 +08:00
|
|
|
|
.asMap()
|
|
|
|
|
.entries
|
|
|
|
|
.map((e) => Obx(() => CheckboxListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
value: rxToggleValues[e.key].value,
|
2024-07-14 15:04:35 +08:00
|
|
|
|
onChanged: e.value.onChanged != null
|
|
|
|
|
? (v) {
|
|
|
|
|
e.value.onChanged?.call(v);
|
|
|
|
|
if (v != null) rxToggleValues[e.key].value = v;
|
|
|
|
|
}
|
|
|
|
|
: null,
|
2023-04-12 09:41:13 +08:00
|
|
|
|
title: e.value.child)))
|
|
|
|
|
.toList();
|
2024-04-25 13:26:02 +08:00
|
|
|
|
final toggles = [
|
|
|
|
|
...cursorTogglesList,
|
|
|
|
|
if (cursorToggles.isNotEmpty) const Divider(color: MyTheme.border),
|
|
|
|
|
...displayTogglesList,
|
|
|
|
|
];
|
2022-09-16 20:31:01 +08:00
|
|
|
|
|
2023-11-14 17:35:16 +08:00
|
|
|
|
Widget privacyModeWidget = Offstage();
|
|
|
|
|
if (privacyModeList.length > 1) {
|
|
|
|
|
privacyModeWidget = ListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
title: Text(translate('Privacy mode')),
|
|
|
|
|
onTap: () => setPrivacyModeDialog(
|
|
|
|
|
dialogManager, privacyModeList, privacyModeState),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 18:53:14 +08:00
|
|
|
|
var popupDialogMenus = List<Widget>.empty(growable: true);
|
|
|
|
|
final resolution = getResolutionMenu(gFFI, id);
|
|
|
|
|
if (resolution != null) {
|
|
|
|
|
popupDialogMenus.add(ListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
title: resolution.child,
|
|
|
|
|
onTap: () {
|
|
|
|
|
close();
|
|
|
|
|
resolution.onPressed();
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
final virtualDisplayMenu = getVirtualDisplayMenu(gFFI, id);
|
|
|
|
|
if (virtualDisplayMenu != null) {
|
|
|
|
|
popupDialogMenus.add(ListTile(
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
title: virtualDisplayMenu.child,
|
|
|
|
|
onTap: () {
|
|
|
|
|
close();
|
|
|
|
|
virtualDisplayMenu.onPressed();
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
if (popupDialogMenus.isNotEmpty) {
|
|
|
|
|
popupDialogMenus.add(const Divider(color: MyTheme.border));
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-13 00:32:44 +08:00
|
|
|
|
return CustomAlertDialog(
|
2022-03-13 23:07:52 +08:00
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2024-07-15 18:53:14 +08:00
|
|
|
|
children: displays +
|
|
|
|
|
radios +
|
|
|
|
|
popupDialogMenus +
|
|
|
|
|
toggles +
|
|
|
|
|
[privacyModeWidget]),
|
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
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 18:53:14 +08:00
|
|
|
|
TTextMenu? getVirtualDisplayMenu(FFI ffi, String id) {
|
|
|
|
|
if (!showVirtualDisplayMenu(ffi)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return TTextMenu(
|
|
|
|
|
child: Text(translate("Virtual display")),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ffi.dialogManager.show((setState, close, context) {
|
|
|
|
|
final children = getVirtualDisplayMenuChildren(ffi, id, close);
|
|
|
|
|
return CustomAlertDialog(
|
|
|
|
|
title: Text(translate('Virtual display')),
|
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: children,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}, clickMaskDismiss: true, backDismiss: true);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTextMenu? getResolutionMenu(FFI ffi, String id) {
|
|
|
|
|
final ffiModel = ffi.ffiModel;
|
|
|
|
|
final pi = ffiModel.pi;
|
|
|
|
|
final resolutions = pi.resolutions;
|
|
|
|
|
final display = pi.tryGetDisplayIfNotAllDisplay(display: pi.currentDisplay);
|
|
|
|
|
|
|
|
|
|
final visible =
|
|
|
|
|
ffiModel.keyboard && (resolutions.length > 1) && display != null;
|
|
|
|
|
if (!visible) return null;
|
|
|
|
|
|
|
|
|
|
return TTextMenu(
|
|
|
|
|
child: Text(translate("Resolution")),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ffi.dialogManager.show((setState, close, context) {
|
|
|
|
|
final children = resolutions
|
|
|
|
|
.map((e) => getRadio<String>(
|
|
|
|
|
Text('${e.width}x${e.height}'),
|
|
|
|
|
'${e.width}x${e.height}',
|
|
|
|
|
'${display.width}x${display.height}',
|
|
|
|
|
(value) {
|
|
|
|
|
close();
|
|
|
|
|
bind.sessionChangeResolution(
|
|
|
|
|
sessionId: ffi.sessionId,
|
|
|
|
|
display: pi.currentDisplay,
|
|
|
|
|
width: e.width,
|
|
|
|
|
height: e.height,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
.toList();
|
|
|
|
|
return CustomAlertDialog(
|
|
|
|
|
title: Text(translate('Resolution')),
|
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: children,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}, clickMaskDismiss: true, backDismiss: true);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|