From 05771e65e2377c5bd668c20756b768c98ffea58f Mon Sep 17 00:00:00 2001 From: Kingtous Date: Mon, 22 Aug 2022 13:51:05 +0800 Subject: [PATCH] feat: can resize window when without title bar Signed-off-by: Kingtous --- .../desktop/pages/connection_tab_page.dart | 59 ++++++++++--------- .../lib/desktop/pages/desktop_tab_page.dart | 59 ++++++++++--------- .../desktop/pages/file_manager_tab_page.dart | 44 +++++++------- flutter/pubspec.lock | 4 +- flutter/pubspec.yaml | 3 +- 5 files changed, 89 insertions(+), 80 deletions(-) diff --git a/flutter/lib/desktop/pages/connection_tab_page.dart b/flutter/lib/desktop/pages/connection_tab_page.dart index 5dd4a829a..be5ec82af 100644 --- a/flutter/lib/desktop/pages/connection_tab_page.dart +++ b/flutter/lib/desktop/pages/connection_tab_page.dart @@ -72,34 +72,37 @@ class _ConnectionTabPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: Column( - children: [ - Obx(() => Visibility( - visible: _fullscreenID.value.isEmpty, - child: DesktopTabBar( - tabs: tabs, - onTabClose: onRemoveId, - dark: isDarkTheme(), - mainTab: false, - ))), - Expanded(child: Obx(() { - WindowController.fromWindowId(windowId()) - .setFullscreen(_fullscreenID.value.isNotEmpty); - return PageView( - controller: DesktopTabBar.controller.value, - children: tabs - .map((tab) => RemotePage( - key: ValueKey(tab.label), - id: tab.label, - tabBarHeight: _fullscreenID.value.isNotEmpty - ? 0 - : kDesktopRemoteTabBarHeight, - fullscreenID: _fullscreenID, - )) //RemotePage(key: ValueKey(e), id: e)) - .toList()); - })), - ], + return SubWindowDragToResizeArea( + windowId: windowId(), + child: Scaffold( + body: Column( + children: [ + Obx(() => Visibility( + visible: _fullscreenID.value.isEmpty, + child: DesktopTabBar( + tabs: tabs, + onTabClose: onRemoveId, + dark: isDarkTheme(), + mainTab: false, + ))), + Expanded(child: Obx(() { + WindowController.fromWindowId(windowId()) + .setFullscreen(_fullscreenID.value.isNotEmpty); + return PageView( + controller: DesktopTabBar.controller.value, + children: tabs + .map((tab) => RemotePage( + key: ValueKey(tab.label), + id: tab.label, + tabBarHeight: _fullscreenID.value.isNotEmpty + ? 0 + : kDesktopRemoteTabBarHeight, + fullscreenID: _fullscreenID, + )) //RemotePage(key: ValueKey(e), id: e)) + .toList()); + })), + ], + ), ), ); } diff --git a/flutter/lib/desktop/pages/desktop_tab_page.dart b/flutter/lib/desktop/pages/desktop_tab_page.dart index 45722174e..5c108f39f 100644 --- a/flutter/lib/desktop/pages/desktop_tab_page.dart +++ b/flutter/lib/desktop/pages/desktop_tab_page.dart @@ -5,6 +5,7 @@ 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:get/get.dart'; +import 'package:window_manager/window_manager.dart'; class DesktopTabPage extends StatefulWidget { const DesktopTabPage({Key? key}) : super(key: key); @@ -30,34 +31,36 @@ class _DesktopTabPageState extends State { @override Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - border: Border.all(color: MyTheme.color(context).border!)), - child: Scaffold( - backgroundColor: MyTheme.color(context).bg, - body: Column( - children: [ - DesktopTabBar( - tabs: tabs, - dark: isDarkTheme(), - mainTab: true, - onAddSetting: onAddSetting, - ), - Obx((() => Expanded( - child: PageView( - controller: DesktopTabBar.controller.value, - children: tabs.map((tab) { - switch (tab.label) { - case kTabLabelHomePage: - return DesktopHomePage(key: ValueKey(tab.label)); - case kTabLabelSettingPage: - return DesktopSettingPage(key: ValueKey(tab.label)); - default: - return Container(); - } - }).toList()), - ))), - ], + return DragToResizeArea( + child: Container( + decoration: BoxDecoration( + border: Border.all(color: MyTheme.color(context).border!)), + child: Scaffold( + backgroundColor: MyTheme.color(context).bg, + body: Column( + children: [ + DesktopTabBar( + tabs: tabs, + dark: isDarkTheme(), + mainTab: true, + onAddSetting: onAddSetting, + ), + Obx((() => Expanded( + child: PageView( + controller: DesktopTabBar.controller.value, + children: tabs.map((tab) { + switch (tab.label) { + case kTabLabelHomePage: + return DesktopHomePage(key: ValueKey(tab.label)); + case kTabLabelSettingPage: + return DesktopSettingPage(key: ValueKey(tab.label)); + default: + return Container(); + } + }).toList()), + ))), + ], + ), ), ), ); diff --git a/flutter/lib/desktop/pages/file_manager_tab_page.dart b/flutter/lib/desktop/pages/file_manager_tab_page.dart index 5f12c873a..12b5b20ff 100644 --- a/flutter/lib/desktop/pages/file_manager_tab_page.dart +++ b/flutter/lib/desktop/pages/file_manager_tab_page.dart @@ -68,27 +68,31 @@ class _FileManagerTabPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: Column( - children: [ - DesktopTabBar( - tabs: tabs, - onTabClose: onRemoveId, - dark: isDarkTheme(), - mainTab: false, - ), - Expanded( - child: Obx( - () => PageView( - controller: DesktopTabBar.controller.value, - children: tabs - .map((tab) => FileManagerPage( - key: ValueKey(tab.label), - id: tab.label)) //RemotePage(key: ValueKey(e), id: e)) - .toList()), + return SubWindowDragToResizeArea( + windowId: windowId(), + child: Scaffold( + body: Column( + children: [ + DesktopTabBar( + tabs: tabs, + onTabClose: onRemoveId, + dark: isDarkTheme(), + mainTab: false, ), - ) - ], + Expanded( + child: Obx( + () => PageView( + controller: DesktopTabBar.controller.value, + children: tabs + .map((tab) => FileManagerPage( + key: ValueKey(tab.label), + id: tab + .label)) //RemotePage(key: ValueKey(e), id: e)) + .toList()), + ), + ) + ], + ), ), ); } diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 34b39cb56..078451a50 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -252,8 +252,8 @@ packages: dependency: "direct main" description: path: "." - ref: "6e6b6f557f655e9c985007d754b6282a0e524932" - resolved-ref: "6e6b6f557f655e9c985007d754b6282a0e524932" + ref: "56c4ca21d0319597f6c19f56b34f1cae6bfc78b9" + resolved-ref: "56c4ca21d0319597f6c19f56b34f1cae6bfc78b9" url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" source: git version: "0.1.0" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 13fd96d97..c00e4fce6 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -63,10 +63,9 @@ dependencies: url: https://github.com/Kingtous/rustdesk_window_manager ref: 75a6c813babca461f359a586785d797f7806e390 desktop_multi_window: - # path: ../../rustdesk_desktop_multi_window git: url: https://github.com/Kingtous/rustdesk_desktop_multi_window - ref: 6e6b6f557f655e9c985007d754b6282a0e524932 + ref: 56c4ca21d0319597f6c19f56b34f1cae6bfc78b9 freezed_annotation: ^2.0.3 tray_manager: git: