Refact. Flutter web, mid commit (#7494)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-03-24 11:23:06 +08:00
committed by GitHub
parent 96e1b5b0f6
commit 85cafda168
33 changed files with 298 additions and 152 deletions

View File

@@ -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 ?

View File

@@ -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;

View File

@@ -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,