mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-10 06:41:29 +03:00
Refact. Flutter web, mid commit (#7494)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -231,7 +230,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
if (eventName == 'minimize') {
|
||||
isWindowMinimized = true;
|
||||
} else if (eventName == 'maximize' || eventName == 'restore') {
|
||||
if (isWindowMinimized && Platform.isWindows) {
|
||||
if (isWindowMinimized && isWindows) {
|
||||
// windows can't update when minimized.
|
||||
Get.forceAppUpdate();
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
return buildInstallCard("", systemError, "", () {});
|
||||
}
|
||||
|
||||
if (Platform.isWindows && !bind.isDisableInstallation()) {
|
||||
if (isWindows && !bind.isDisableInstallation()) {
|
||||
if (!bind.mainIsInstalled()) {
|
||||
return buildInstallCard(
|
||||
"", bind.isOutgoingOnly() ? "" : "install_tip", "Install",
|
||||
@@ -485,7 +485,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
bind.mainUpdateMe();
|
||||
});
|
||||
}
|
||||
} else if (Platform.isMacOS) {
|
||||
} else if (isMacOS) {
|
||||
if (!(bind.isOutgoingOnly() ||
|
||||
bind.mainIsCanScreenRecording(prompt: false))) {
|
||||
return buildInstallCard("Permissions", "config_screen", "Configure",
|
||||
@@ -521,7 +521,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
// watchIsCanRecordAudio = true;
|
||||
// });
|
||||
// }
|
||||
} else if (Platform.isLinux) {
|
||||
} else if (isLinux) {
|
||||
if (bind.isOutgoingOnly()) {
|
||||
return Container();
|
||||
}
|
||||
@@ -570,7 +570,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
onPressed: () {
|
||||
SystemNavigator.pop(); // Close the application
|
||||
// https://github.com/flutter/flutter/issues/66631
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
exit(0);
|
||||
}
|
||||
},
|
||||
@@ -740,7 +740,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
}
|
||||
if (watchIsCanRecordAudio) {
|
||||
if (Platform.isMacOS) {
|
||||
if (isMacOS) {
|
||||
Future.microtask(() async {
|
||||
if ((await osxCanRecordAudio() ==
|
||||
PermissionAuthorizeType.authorized)) {
|
||||
|
||||
@@ -414,7 +414,7 @@ class _GeneralState extends State<_General> {
|
||||
}
|
||||
|
||||
String getDefault() {
|
||||
if (Platform.isWindows) return translate('System Sound');
|
||||
if (isWindows) return translate('System Sound');
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ class _GeneralState extends State<_General> {
|
||||
|
||||
return futureBuilder(future: () async {
|
||||
List<String> devices = (await bind.mainGetSoundInputs()).toList();
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
devices.insert(0, translate('System Sound'));
|
||||
}
|
||||
String current = await getValue();
|
||||
@@ -705,7 +705,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
_OptionCheckBox(
|
||||
context, 'Enable recording session', 'enable-record-session',
|
||||
enabled: enabled, fakeValue: fakeValue),
|
||||
if (Platform.isWindows)
|
||||
if (isWindows)
|
||||
_OptionCheckBox(
|
||||
context, 'Enable blocking user input', 'enable-block-input',
|
||||
enabled: enabled, fakeValue: fakeValue),
|
||||
@@ -845,7 +845,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
|
||||
bool value = bind.mainIsShareRdp();
|
||||
return Offstage(
|
||||
offstage: !(Platform.isWindows && bind.mainIsInstalled()),
|
||||
offstage: !(isWindows && bind.mainIsInstalled()),
|
||||
child: GestureDetector(
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -90,7 +90,7 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
),
|
||||
),
|
||||
)));
|
||||
return Platform.isMacOS || kUseCompatibleUiMode
|
||||
return isMacOS || kUseCompatibleUiMode
|
||||
? tabWidget
|
||||
: Obx(
|
||||
() => DragToResizeArea(
|
||||
|
||||
@@ -93,7 +93,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||
});
|
||||
Get.put(_ffi, tag: 'ft_${widget.id}');
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
debugPrint("File manager page init success with id ${widget.id}");
|
||||
@@ -106,7 +106,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
model.close().whenComplete(() {
|
||||
_ffi.close();
|
||||
_ffi.dialogManager.dismissAll();
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.disable();
|
||||
}
|
||||
Get.delete<FFI>(tag: 'ft_${widget.id}');
|
||||
@@ -1298,7 +1298,7 @@ class _FileManagerViewState extends State<FileManagerView> {
|
||||
onPointerSignal: (e) {
|
||||
if (e is PointerScrollEvent) {
|
||||
final sc = _breadCrumbScroller;
|
||||
final scale = Platform.isWindows ? 2 : 4;
|
||||
final scale = isWindows ? 2 : 4;
|
||||
sc.jumpTo(sc.offset + e.scrollDelta.dy / scale);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -104,7 +103,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
labelGetter: DesktopTab.tablabelGetter,
|
||||
)),
|
||||
);
|
||||
return Platform.isMacOS || kUseCompatibleUiMode
|
||||
return isMacOS || kUseCompatibleUiMode
|
||||
? tabWidget
|
||||
: SubWindowDragToResizeArea(
|
||||
child: tabWidget,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -113,7 +112,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
labelGetter: DesktopTab.tablabelGetter,
|
||||
)),
|
||||
);
|
||||
return Platform.isMacOS || kUseCompatibleUiMode
|
||||
return isMacOS || kUseCompatibleUiMode
|
||||
? tabWidget
|
||||
: Obx(
|
||||
() => SubWindowDragToResizeArea(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -125,7 +124,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
_ffi.dialogManager
|
||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||
});
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
|
||||
@@ -160,7 +159,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
// On windows, we use `focus` way to handle keyboard better.
|
||||
// Now on Linux, there's some rdev issues which will break the input.
|
||||
// We disable the `focus` way for non-Windows temporarily.
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
_isWindowBlur = true;
|
||||
// unfocus the primary-focus when the whole window is lost focus,
|
||||
// and let OS to handle events instead.
|
||||
@@ -172,7 +171,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
void onWindowFocus() {
|
||||
super.onWindowFocus();
|
||||
// See [onWindowBlur].
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
_isWindowBlur = false;
|
||||
}
|
||||
}
|
||||
@@ -182,10 +181,10 @@ class _RemotePageState extends State<RemotePage>
|
||||
super.onWindowRestore();
|
||||
// On windows, we use `onWindowRestore` way to handle window restore from
|
||||
// a minimized state.
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
_isWindowBlur = false;
|
||||
}
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
}
|
||||
@@ -194,7 +193,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
void onWindowMaximize() {
|
||||
super.onWindowMaximize();
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
}
|
||||
@@ -202,7 +201,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
void onWindowMinimize() {
|
||||
super.onWindowMinimize();
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
WakelockPlus.disable();
|
||||
}
|
||||
}
|
||||
@@ -228,7 +227,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||
overlays: SystemUiOverlay.values);
|
||||
}
|
||||
if (!Platform.isLinux) {
|
||||
if (!isLinux) {
|
||||
await WakelockPlus.disable();
|
||||
}
|
||||
await Get.delete<FFI>(tag: widget.id);
|
||||
@@ -266,7 +265,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
debugPrint(
|
||||
"onFocusChange(window active:${!_isWindowBlur}) $imageFocused");
|
||||
// See [onWindowBlur].
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
if (_isWindowBlur) {
|
||||
imageFocused = false;
|
||||
Future.delayed(Duration.zero, () {
|
||||
@@ -362,7 +361,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
}
|
||||
}
|
||||
// See [onWindowBlur].
|
||||
if (!Platform.isWindows) {
|
||||
if (!isWindows) {
|
||||
if (!_rawKeyFocusNode.hasFocus) {
|
||||
_rawKeyFocusNode.requestFocus();
|
||||
}
|
||||
@@ -385,7 +384,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
}
|
||||
}
|
||||
// See [onWindowBlur].
|
||||
if (!Platform.isWindows) {
|
||||
if (!isWindows) {
|
||||
_ffi.inputModel.enterOrLeave(false);
|
||||
}
|
||||
}
|
||||
@@ -537,7 +536,7 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
double getCursorScale() {
|
||||
var c = Provider.of<CanvasModel>(context);
|
||||
var cursorScale = 1.0;
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
// debug win10
|
||||
if (zoomCursor.value && isViewAdaptive()) {
|
||||
cursorScale = s * c.devicePixelRatio;
|
||||
@@ -604,8 +603,8 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
c,
|
||||
s,
|
||||
Offset(
|
||||
Platform.isLinux ? c.x.toInt().toDouble() : c.x,
|
||||
Platform.isLinux ? c.y.toInt().toDouble() : c.y,
|
||||
isLinux ? c.x.toInt().toDouble() : c.x,
|
||||
isLinux ? c.y.toInt().toDouble() : c.y,
|
||||
),
|
||||
c.size,
|
||||
isViewOriginal())
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
@@ -127,7 +126,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
tryMoveToScreenAndSetFullscreen(screenRect);
|
||||
if (tabController.length == 0) {
|
||||
// Show the hidden window.
|
||||
if (Platform.isMacOS && stateGlobal.closeOnFullscreen == true) {
|
||||
if (isMacOS && stateGlobal.closeOnFullscreen == true) {
|
||||
stateGlobal.setFullscreen(true);
|
||||
}
|
||||
// Reset the state
|
||||
@@ -328,7 +327,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
),
|
||||
),
|
||||
);
|
||||
return Platform.isMacOS || kUseCompatibleUiMode
|
||||
return isMacOS || kUseCompatibleUiMode
|
||||
? tabWidget
|
||||
: Obx(() => SubWindowDragToResizeArea(
|
||||
key: contentKey,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// original cm window in Sciter version.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -52,7 +51,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
|
||||
@override
|
||||
void onWindowClose() {
|
||||
Future.wait([gFFI.serverModel.closeAll(), gFFI.close()]).then((_) {
|
||||
if (Platform.isMacOS) {
|
||||
if (isMacOS) {
|
||||
RdPlatformChannel.instance.terminate();
|
||||
} else {
|
||||
windowManager.setPreventClose(false);
|
||||
@@ -651,7 +650,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
||||
translate('Enable recording session'),
|
||||
),
|
||||
// only windows support block input
|
||||
if (Platform.isWindows)
|
||||
if (isWindows)
|
||||
buildPermissionIcon(
|
||||
client.blockInput,
|
||||
Icons.block,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/remote_tab_page.dart';
|
||||
@@ -28,7 +26,7 @@ class DesktopRemoteScreen extends StatelessWidget {
|
||||
child: Scaffold(
|
||||
// Set transparent background for padding the resize area out of the flutter view.
|
||||
// This allows the wallpaper goes through our resize area. (Linux only now).
|
||||
backgroundColor: Platform.isLinux ? Colors.transparent : null,
|
||||
backgroundColor: isLinux ? Colors.transparent : null,
|
||||
body: ConnectionTabPage(
|
||||
params: params,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
@@ -175,9 +174,9 @@ String getLocalPlatformForKBLayoutType(String peerPlatform) {
|
||||
return localPlatform;
|
||||
}
|
||||
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
localPlatform = kPeerPlatformWindows;
|
||||
} else if (Platform.isLinux) {
|
||||
} else if (isLinux) {
|
||||
localPlatform = kPeerPlatformLinux;
|
||||
}
|
||||
// to-do: web desktop support ?
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -112,10 +111,10 @@ class _ToolbarTheme {
|
||||
static const double iconRadius = 8;
|
||||
static const double elevation = 3;
|
||||
|
||||
static double dividerSpaceToAction = Platform.isWindows ? 8 : 14;
|
||||
static double dividerSpaceToAction = isWindows ? 8 : 14;
|
||||
|
||||
static double menuBorderRadius = Platform.isWindows ? 5.0 : 7.0;
|
||||
static EdgeInsets menuPadding = Platform.isWindows
|
||||
static double menuBorderRadius = isWindows ? 5.0 : 7.0;
|
||||
static EdgeInsets menuPadding = isWindows
|
||||
? EdgeInsets.fromLTRB(4, 12, 4, 12)
|
||||
: EdgeInsets.fromLTRB(6, 14, 6, 14);
|
||||
static const double menuButtonBorderRadius = 3.0;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
@@ -392,12 +391,12 @@ class DesktopTab extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !Platform.isMacOS,
|
||||
offstage: !isMacOS,
|
||||
child: const SizedBox(
|
||||
width: 78,
|
||||
)),
|
||||
Offstage(
|
||||
offstage: kUseCompatibleUiMode || Platform.isMacOS,
|
||||
offstage: kUseCompatibleUiMode || isMacOS,
|
||||
child: Row(children: [
|
||||
Offstage(
|
||||
offstage: !showLogo,
|
||||
@@ -585,7 +584,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
notMainWindowClose(WindowController controller) async {
|
||||
if (widget.tabController.length != 0) {
|
||||
debugPrint("close not emtpy multiwindow from taskbar");
|
||||
if (Platform.isWindows) {
|
||||
if (isWindows) {
|
||||
await controller.show();
|
||||
await controller.focus();
|
||||
final res = await widget.onClose?.call() ?? true;
|
||||
@@ -620,7 +619,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
await rustDeskWinManager.unregisterActiveWindow(kMainWindowId);
|
||||
}
|
||||
// macOS specific workaround, the window is not hiding when in fullscreen.
|
||||
if (Platform.isMacOS && await windowManager.isFullScreen()) {
|
||||
if (isMacOS && await windowManager.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen ??= true;
|
||||
await windowManager.setFullScreen(false);
|
||||
await macOSWindowClose(
|
||||
@@ -634,7 +633,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
} else {
|
||||
// it's safe to hide the subwindow
|
||||
final controller = WindowController.fromWindowId(kWindowId!);
|
||||
if (Platform.isMacOS) {
|
||||
if (isMacOS) {
|
||||
// onWindowClose() maybe called multiple times because of loopCloseWindow() in remote_tab_page.dart.
|
||||
// use ??= to make sure the value is set on first call.
|
||||
|
||||
@@ -670,7 +669,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
child: Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !widget.showMinimize || Platform.isMacOS,
|
||||
offstage: !widget.showMinimize || isMacOS,
|
||||
child: ActionIcon(
|
||||
message: 'Minimize',
|
||||
icon: IconFont.min,
|
||||
@@ -684,7 +683,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
isClose: false,
|
||||
)),
|
||||
Offstage(
|
||||
offstage: !widget.showMaximize || Platform.isMacOS,
|
||||
offstage: !widget.showMaximize || isMacOS,
|
||||
child: Obx(() => ActionIcon(
|
||||
message: stateGlobal.isMaximized.isTrue
|
||||
? 'Restore'
|
||||
@@ -698,7 +697,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
isClose: false,
|
||||
))),
|
||||
Offstage(
|
||||
offstage: !widget.showClose || Platform.isMacOS,
|
||||
offstage: !widget.showClose || isMacOS,
|
||||
child: ActionIcon(
|
||||
message: 'Close',
|
||||
icon: IconFont.close,
|
||||
|
||||
Reference in New Issue
Block a user