feat: can resize window when without title bar

Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
Kingtous 2022-08-22 13:51:05 +08:00
parent 3028d7c0ff
commit 05771e65e2
5 changed files with 89 additions and 80 deletions

View File

@ -72,34 +72,37 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SubWindowDragToResizeArea(
body: Column( windowId: windowId(),
children: [ child: Scaffold(
Obx(() => Visibility( body: Column(
visible: _fullscreenID.value.isEmpty, children: [
child: DesktopTabBar( Obx(() => Visibility(
tabs: tabs, visible: _fullscreenID.value.isEmpty,
onTabClose: onRemoveId, child: DesktopTabBar(
dark: isDarkTheme(), tabs: tabs,
mainTab: false, onTabClose: onRemoveId,
))), dark: isDarkTheme(),
Expanded(child: Obx(() { mainTab: false,
WindowController.fromWindowId(windowId()) ))),
.setFullscreen(_fullscreenID.value.isNotEmpty); Expanded(child: Obx(() {
return PageView( WindowController.fromWindowId(windowId())
controller: DesktopTabBar.controller.value, .setFullscreen(_fullscreenID.value.isNotEmpty);
children: tabs return PageView(
.map((tab) => RemotePage( controller: DesktopTabBar.controller.value,
key: ValueKey(tab.label), children: tabs
id: tab.label, .map((tab) => RemotePage(
tabBarHeight: _fullscreenID.value.isNotEmpty key: ValueKey(tab.label),
? 0 id: tab.label,
: kDesktopRemoteTabBarHeight, tabBarHeight: _fullscreenID.value.isNotEmpty
fullscreenID: _fullscreenID, ? 0
)) //RemotePage(key: ValueKey(e), id: e)) : kDesktopRemoteTabBarHeight,
.toList()); fullscreenID: _fullscreenID,
})), )) //RemotePage(key: ValueKey(e), id: e))
], .toList());
})),
],
),
), ),
); );
} }

View File

@ -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/pages/desktop_setting_page.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart'; import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart';
class DesktopTabPage extends StatefulWidget { class DesktopTabPage extends StatefulWidget {
const DesktopTabPage({Key? key}) : super(key: key); const DesktopTabPage({Key? key}) : super(key: key);
@ -30,34 +31,36 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return DragToResizeArea(
decoration: BoxDecoration( child: Container(
border: Border.all(color: MyTheme.color(context).border!)), decoration: BoxDecoration(
child: Scaffold( border: Border.all(color: MyTheme.color(context).border!)),
backgroundColor: MyTheme.color(context).bg, child: Scaffold(
body: Column( backgroundColor: MyTheme.color(context).bg,
children: [ body: Column(
DesktopTabBar( children: [
tabs: tabs, DesktopTabBar(
dark: isDarkTheme(), tabs: tabs,
mainTab: true, dark: isDarkTheme(),
onAddSetting: onAddSetting, mainTab: true,
), onAddSetting: onAddSetting,
Obx((() => Expanded( ),
child: PageView( Obx((() => Expanded(
controller: DesktopTabBar.controller.value, child: PageView(
children: tabs.map((tab) { controller: DesktopTabBar.controller.value,
switch (tab.label) { children: tabs.map((tab) {
case kTabLabelHomePage: switch (tab.label) {
return DesktopHomePage(key: ValueKey(tab.label)); case kTabLabelHomePage:
case kTabLabelSettingPage: return DesktopHomePage(key: ValueKey(tab.label));
return DesktopSettingPage(key: ValueKey(tab.label)); case kTabLabelSettingPage:
default: return DesktopSettingPage(key: ValueKey(tab.label));
return Container(); default:
} return Container();
}).toList()), }
))), }).toList()),
], ))),
],
),
), ),
), ),
); );

View File

@ -68,27 +68,31 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SubWindowDragToResizeArea(
body: Column( windowId: windowId(),
children: [ child: Scaffold(
DesktopTabBar( body: Column(
tabs: tabs, children: [
onTabClose: onRemoveId, DesktopTabBar(
dark: isDarkTheme(), tabs: tabs,
mainTab: false, onTabClose: onRemoveId,
), dark: isDarkTheme(),
Expanded( mainTab: false,
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()),
), ),
) 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()),
),
)
],
),
), ),
); );
} }

View File

@ -252,8 +252,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "6e6b6f557f655e9c985007d754b6282a0e524932" ref: "56c4ca21d0319597f6c19f56b34f1cae6bfc78b9"
resolved-ref: "6e6b6f557f655e9c985007d754b6282a0e524932" resolved-ref: "56c4ca21d0319597f6c19f56b34f1cae6bfc78b9"
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
source: git source: git
version: "0.1.0" version: "0.1.0"

View File

@ -63,10 +63,9 @@ dependencies:
url: https://github.com/Kingtous/rustdesk_window_manager url: https://github.com/Kingtous/rustdesk_window_manager
ref: 75a6c813babca461f359a586785d797f7806e390 ref: 75a6c813babca461f359a586785d797f7806e390
desktop_multi_window: desktop_multi_window:
# path: ../../rustdesk_desktop_multi_window
git: git:
url: https://github.com/Kingtous/rustdesk_desktop_multi_window url: https://github.com/Kingtous/rustdesk_desktop_multi_window
ref: 6e6b6f557f655e9c985007d754b6282a0e524932 ref: 56c4ca21d0319597f6c19f56b34f1cae6bfc78b9
freezed_annotation: ^2.0.3 freezed_annotation: ^2.0.3
tray_manager: tray_manager:
git: git: