mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-06 01:11:28 +03:00
flutter_desktop: remote rxbool of fullscreen
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_setting_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/models/state_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
@@ -62,8 +63,6 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
RxBool fullscreen = false.obs;
|
||||
Get.put(fullscreen, tag: 'fullscreen');
|
||||
final tabWidget = Container(
|
||||
child: Overlay(initialEntries: [
|
||||
OverlayEntry(builder: (context) {
|
||||
@@ -84,9 +83,7 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
);
|
||||
return Platform.isMacOS
|
||||
? tabWidget
|
||||
: Obx(() => DragToResizeArea(
|
||||
resizeEdgeSize:
|
||||
fullscreen.value ? kFullScreenEdgeSize : kWindowEdgeSize,
|
||||
child: tabWidget));
|
||||
: DragToResizeArea(
|
||||
resizeEdgeSize: stateGlobal.resizeEdgeSize, child: tabWidget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
print(
|
||||
"[FileTransfer] call ${call.method} with args ${call.arguments} from window ${fromWindowId} to ${windowId()}");
|
||||
"[FileTransfer] call ${call.method} with args ${call.arguments} from window $fromWindowId to ${windowId()}");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_file_transfer") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
@@ -86,11 +86,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
);
|
||||
return Platform.isMacOS
|
||||
? tabWidget
|
||||
: SubWindowDragToResizeArea(
|
||||
resizeEdgeSize: kWindowEdgeSize,
|
||||
windowId: windowId(),
|
||||
child: tabWidget,
|
||||
);
|
||||
: SubWindowDragToResizeArea(child: tabWidget);
|
||||
}
|
||||
|
||||
void onRemoveId(String id) {
|
||||
|
||||
@@ -50,7 +50,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
debugPrint(
|
||||
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
|
||||
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_port_forward") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
@@ -97,11 +97,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
);
|
||||
return Platform.isMacOS
|
||||
? tabWidget
|
||||
: SubWindowDragToResizeArea(
|
||||
resizeEdgeSize: kWindowEdgeSize,
|
||||
windowId: windowId(),
|
||||
child: tabWidget,
|
||||
);
|
||||
: SubWindowDragToResizeArea(child: tabWidget);
|
||||
}
|
||||
|
||||
void onRemoveId(String id) {
|
||||
|
||||
@@ -28,15 +28,9 @@ class RemotePage extends StatefulWidget {
|
||||
const RemotePage({
|
||||
Key? key,
|
||||
required this.id,
|
||||
required this.windowId,
|
||||
required this.tabBarHeight,
|
||||
required this.windowBorderWidth,
|
||||
}) : super(key: key);
|
||||
|
||||
final String id;
|
||||
final int windowId;
|
||||
final double tabBarHeight;
|
||||
final double windowBorderWidth;
|
||||
|
||||
@override
|
||||
State<RemotePage> createState() => _RemotePageState();
|
||||
@@ -58,11 +52,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
|
||||
late FFI _ffi;
|
||||
|
||||
void _updateTabBarHeight() {
|
||||
_ffi.canvasModel.tabBarHeight = widget.tabBarHeight;
|
||||
_ffi.canvasModel.windowBorderWidth = widget.windowBorderWidth;
|
||||
}
|
||||
|
||||
void _initStates(String id) {
|
||||
PrivacyModeState.init(id);
|
||||
BlockInputState.init(id);
|
||||
@@ -91,7 +80,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
|
||||
_ffi = FFI();
|
||||
|
||||
_updateTabBarHeight();
|
||||
Get.put(_ffi, tag: widget.id);
|
||||
_ffi.start(widget.id);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
@@ -164,7 +152,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
_updateTabBarHeight();
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
clientClose(_ffi.dialogManager);
|
||||
@@ -241,7 +228,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
paints.add(QualityMonitor(_ffi.qualityMonitorModel));
|
||||
paints.add(RemoteMenubar(
|
||||
id: widget.id,
|
||||
windowId: widget.windowId,
|
||||
ffi: _ffi,
|
||||
onEnterOrLeaveImageSetter: (func) => _onEnterOrLeaveImage4Menubar = func,
|
||||
onEnterOrLeaveImageCleaner: () => _onEnterOrLeaveImage4Menubar = null,
|
||||
|
||||
@@ -34,24 +34,20 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
|
||||
_ConnectionTabPageState(Map<String, dynamic> params) {
|
||||
RemoteCountState.init();
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
final peerId = params['id'];
|
||||
if (peerId != null) {
|
||||
ConnectionTypeState.init(peerId);
|
||||
tabController.add(TabInfo(
|
||||
key: peerId,
|
||||
label: peerId,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => tabController.closeBy(peerId),
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
windowId: windowId(),
|
||||
tabBarHeight:
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
windowBorderWidth: fullscreen.isTrue ? 0 : kWindowBorderWidth,
|
||||
))));
|
||||
key: peerId,
|
||||
label: peerId,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => tabController.closeBy(peerId),
|
||||
page: RemotePage(
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
),
|
||||
));
|
||||
_update_remote_count();
|
||||
}
|
||||
}
|
||||
@@ -66,7 +62,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
print(
|
||||
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_remote_desktop") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
@@ -75,22 +70,13 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
window_on_top(windowId());
|
||||
ConnectionTypeState.init(id);
|
||||
tabController.add(TabInfo(
|
||||
key: id,
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => tabController.closeBy(id),
|
||||
page: ObxValue<RxBool>(
|
||||
(fullscreen) => RemotePage(
|
||||
id: id,
|
||||
windowId: windowId(),
|
||||
tabBarHeight:
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
windowBorderWidth: fullscreen.isTrue ? 0 : kWindowBorderWidth,
|
||||
),
|
||||
fullscreen,
|
||||
key: ValueKey(id),
|
||||
)));
|
||||
key: id,
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => tabController.closeBy(id),
|
||||
page: RemotePage(key: ValueKey(id), id: id),
|
||||
));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
@@ -105,7 +91,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
final tabWidget = Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
@@ -113,61 +98,52 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
width: kWindowBorderWidth)),
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).backgroundColor,
|
||||
body: Obx(() => DesktopTab(
|
||||
controller: tabController,
|
||||
showTabBar: fullscreen.isFalse,
|
||||
onWindowCloseButton: handleWindowCloseButton,
|
||||
tail: const AddButton().paddingOnly(left: 10),
|
||||
pageViewBuilder: (pageView) {
|
||||
WindowController.fromWindowId(windowId())
|
||||
.setFullscreen(fullscreen.isTrue);
|
||||
return pageView;
|
||||
},
|
||||
tabBuilder: (key, icon, label, themeConf) => Obx(() {
|
||||
final connectionType = ConnectionTypeState.find(key);
|
||||
if (!connectionType.isValid()) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
label,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
final msgDirect = translate(
|
||||
connectionType.direct.value == ConnectionType.strDirect
|
||||
? 'Direct Connection'
|
||||
: 'Relay Connection');
|
||||
final msgSecure = translate(
|
||||
connectionType.secure.value == ConnectionType.strSecure
|
||||
? 'Secure Connection'
|
||||
: 'Insecure Connection');
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
Tooltip(
|
||||
message: '$msgDirect\n$msgSecure',
|
||||
child: SvgPicture.asset(
|
||||
'assets/${connectionType.secure.value}${connectionType.direct.value}.svg',
|
||||
width: themeConf.iconSize,
|
||||
height: themeConf.iconSize,
|
||||
).paddingOnly(right: 5),
|
||||
),
|
||||
label,
|
||||
],
|
||||
);
|
||||
}
|
||||
}),
|
||||
))),
|
||||
body: DesktopTab(
|
||||
controller: tabController,
|
||||
onWindowCloseButton: handleWindowCloseButton,
|
||||
tail: const AddButton().paddingOnly(left: 10),
|
||||
pageViewBuilder: (pageView) => pageView,
|
||||
tabBuilder: (key, icon, label, themeConf) => Obx(() {
|
||||
final connectionType = ConnectionTypeState.find(key);
|
||||
if (!connectionType.isValid()) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
label,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
final msgDirect = translate(
|
||||
connectionType.direct.value == ConnectionType.strDirect
|
||||
? 'Direct Connection'
|
||||
: 'Relay Connection');
|
||||
final msgSecure = translate(
|
||||
connectionType.secure.value == ConnectionType.strSecure
|
||||
? 'Secure Connection'
|
||||
: 'Insecure Connection');
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
Tooltip(
|
||||
message: '$msgDirect\n$msgSecure',
|
||||
child: SvgPicture.asset(
|
||||
'assets/${connectionType.secure.value}${connectionType.direct.value}.svg',
|
||||
width: themeConf.iconSize,
|
||||
height: themeConf.iconSize,
|
||||
).paddingOnly(right: 5),
|
||||
),
|
||||
label,
|
||||
],
|
||||
);
|
||||
}
|
||||
}),
|
||||
)),
|
||||
);
|
||||
return Platform.isMacOS
|
||||
? tabWidget
|
||||
: Obx(() => SubWindowDragToResizeArea(
|
||||
resizeEdgeSize:
|
||||
fullscreen.value ? kFullScreenEdgeSize : kWindowEdgeSize,
|
||||
windowId: windowId(),
|
||||
child: tabWidget));
|
||||
: SubWindowDragToResizeArea(child: tabWidget);
|
||||
}
|
||||
|
||||
void onRemoveId(String id) {
|
||||
|
||||
Reference in New Issue
Block a user