mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-01 21:21:27 +03:00
flutter_desktop: fix canvas height - tabBarHeight
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -906,8 +906,10 @@ class _PeerTabbedPageState extends State<_PeerTabbedPage>
|
||||
if (_tabController.indexIsChanging) {
|
||||
switch (_tabController.index) {
|
||||
case 0:
|
||||
gFFI.bind.mainLoadRecentPeers();
|
||||
break;
|
||||
case 1:
|
||||
gFFI.bind.mainLoadFavPeers();
|
||||
break;
|
||||
case 2:
|
||||
gFFI.bind.mainDiscover();
|
||||
|
||||
@@ -3,9 +3,11 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/titlebar_widget.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../models/model.dart';
|
||||
@@ -70,6 +72,42 @@ class _ConnectionTabPageState extends State<ConnectionTabPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabBar = TabBar(
|
||||
isScrollable: true,
|
||||
labelColor: Colors.white,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
indicatorColor: Colors.white,
|
||||
tabs: connectionIds
|
||||
.map((e) => Tab(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(e),
|
||||
SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
onRemoveId(e);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.highlight_remove,
|
||||
size: 20,
|
||||
))
|
||||
],
|
||||
),
|
||||
))
|
||||
.toList());
|
||||
final tabBarView = TabBarView(
|
||||
children: connectionIds
|
||||
.map((e) => Container(
|
||||
child: RemotePage(
|
||||
key: ValueKey(e),
|
||||
id: e,
|
||||
tabBarHeight: kDesktopRemoteTabBarHeight,
|
||||
))) //RemotePage(key: ValueKey(e), id: e))
|
||||
.toList());
|
||||
return Scaffold(
|
||||
body: DefaultTabController(
|
||||
initialIndex: initialIndex,
|
||||
@@ -78,43 +116,9 @@ class _ConnectionTabPageState extends State<ConnectionTabPage>
|
||||
child: Column(
|
||||
children: [
|
||||
DesktopTitleBar(
|
||||
child: TabBar(
|
||||
isScrollable: true,
|
||||
labelColor: Colors.white,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
indicatorColor: Colors.white,
|
||||
tabs: connectionIds
|
||||
.map((e) => Tab(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(e),
|
||||
SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
onRemoveId(e);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.highlight_remove,
|
||||
size: 20,
|
||||
))
|
||||
],
|
||||
),
|
||||
))
|
||||
.toList()),
|
||||
child: Container(height: kDesktopRemoteTabBarHeight, child: tabBar),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
children: connectionIds
|
||||
.map((e) => Container(
|
||||
child: RemotePage(
|
||||
key: ValueKey(e),
|
||||
id: e))) //RemotePage(key: ValueKey(e), id: e))
|
||||
.toList()),
|
||||
)
|
||||
Expanded(child: tabBarView),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:wakelock/wakelock.dart';
|
||||
// import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../consts.dart';
|
||||
import '../../mobile/widgets/dialog.dart';
|
||||
import '../../mobile/widgets/overlay.dart';
|
||||
import '../../models/model.dart';
|
||||
@@ -23,9 +24,11 @@ import '../../models/model.dart';
|
||||
final initText = '\1' * 1024;
|
||||
|
||||
class RemotePage extends StatefulWidget {
|
||||
RemotePage({Key? key, required this.id}) : super(key: key);
|
||||
RemotePage({Key? key, required this.id, required this.tabBarHeight})
|
||||
: super(key: key);
|
||||
|
||||
final String id;
|
||||
final double tabBarHeight;
|
||||
|
||||
@override
|
||||
_RemotePageState createState() => _RemotePageState();
|
||||
@@ -53,10 +56,12 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final ffi = Get.put(FFI(), tag: widget.id);
|
||||
var ffitmp = FFI();
|
||||
ffitmp.canvasModel.tabBarHeight = super.widget.tabBarHeight;
|
||||
final ffi = Get.put(ffitmp, tag: widget.id);
|
||||
// note: a little trick
|
||||
ffi.ffiModel.platformFFI = gFFI.ffiModel.platformFFI;
|
||||
ffi.connect(widget.id);
|
||||
ffi.connect(widget.id, tabBarHeight: super.widget.tabBarHeight);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
showLoading(translate('Connecting...'));
|
||||
@@ -236,11 +241,12 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
Provider.of<CanvasModel>(context, listen: false).tabBarHeight =
|
||||
super.widget.tabBarHeight;
|
||||
final pi = Provider.of<FfiModel>(context).pi;
|
||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||
final showActionButton = !_showBar || hideKeyboard;
|
||||
final keyboard = _ffi.ffiModel.permissions['keyboard'] != false;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
clientClose();
|
||||
@@ -296,7 +302,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
Widget getRawPointerAndKeyBody(bool keyboard, Widget child) {
|
||||
return Listener(
|
||||
onPointerHover: (e) {
|
||||
debugPrint("onPointerHover ${e}");
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||
if (!_isPhysicalMouse) {
|
||||
setState(() {
|
||||
@@ -304,11 +309,11 @@ class _RemotePageState extends State<RemotePage>
|
||||
});
|
||||
}
|
||||
if (_isPhysicalMouse) {
|
||||
_ffi.handleMouse(getEvent(e, 'mousemove'));
|
||||
_ffi.handleMouse(getEvent(e, 'mousemove'),
|
||||
tabBarHeight: super.widget.tabBarHeight);
|
||||
}
|
||||
},
|
||||
onPointerDown: (e) {
|
||||
debugPrint("onPointerDown ${e}");
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) {
|
||||
if (_isPhysicalMouse) {
|
||||
setState(() {
|
||||
@@ -317,25 +322,25 @@ class _RemotePageState extends State<RemotePage>
|
||||
}
|
||||
}
|
||||
if (_isPhysicalMouse) {
|
||||
_ffi.handleMouse(getEvent(e, 'mousedown'));
|
||||
_ffi.handleMouse(getEvent(e, 'mousedown'),
|
||||
tabBarHeight: super.widget.tabBarHeight);
|
||||
}
|
||||
},
|
||||
onPointerUp: (e) {
|
||||
debugPrint("onPointerUp ${e}");
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||
if (_isPhysicalMouse) {
|
||||
_ffi.handleMouse(getEvent(e, 'mouseup'));
|
||||
_ffi.handleMouse(getEvent(e, 'mouseup'),
|
||||
tabBarHeight: super.widget.tabBarHeight);
|
||||
}
|
||||
},
|
||||
onPointerMove: (e) {
|
||||
debugPrint("onPointerMove ${e}");
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||
if (_isPhysicalMouse) {
|
||||
_ffi.handleMouse(getEvent(e, 'mousemove'));
|
||||
_ffi.handleMouse(getEvent(e, 'mousemove'),
|
||||
tabBarHeight: super.widget.tabBarHeight);
|
||||
}
|
||||
},
|
||||
onPointerSignal: (e) {
|
||||
debugPrint("onPointerSignal ${e}");
|
||||
if (e is PointerScrollEvent) {
|
||||
var dx = e.scrollDelta.dx;
|
||||
var dy = e.scrollDelta.dy;
|
||||
@@ -557,7 +562,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
void showActions(String id) async {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final x = 120.0;
|
||||
final y = size.height;
|
||||
final y = size.height - super.widget.tabBarHeight;
|
||||
final more = <PopupMenuItem<String>>[];
|
||||
final pi = _ffi.ffiModel.pi;
|
||||
final perms = _ffi.ffiModel.permissions;
|
||||
@@ -672,7 +677,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
if (!keyboard) {
|
||||
return SizedBox();
|
||||
}
|
||||
final size = MediaQuery.of(context).size;
|
||||
var wrap = (String text, void Function() onPressed,
|
||||
[bool? active, IconData? icon]) {
|
||||
return TextButton(
|
||||
@@ -788,7 +792,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
sendPrompt(widget.id, isMac, 'VK_S');
|
||||
}),
|
||||
];
|
||||
final space = size.width > 320 ? 4.0 : 2.0;
|
||||
final space = MediaQuery.of(context).size.width > 320 ? 4.0 : 2.0;
|
||||
return Container(
|
||||
color: Color(0xAA000000),
|
||||
padding: EdgeInsets.only(
|
||||
|
||||
@@ -64,6 +64,11 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener {
|
||||
_queryCoun = 0;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowMinimize() {
|
||||
_queryCoun = _maxQueryCount;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final space = 8.0;
|
||||
@@ -110,19 +115,23 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener {
|
||||
final now = DateTime.now();
|
||||
if (!setEquals(_curPeers, _lastQueryPeers)) {
|
||||
if (now.difference(_lastChangeTime) > Duration(seconds: 1)) {
|
||||
gFFI.ffiModel.platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryPeers = {..._curPeers};
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun = 0;
|
||||
if (_curPeers.length > 0) {
|
||||
gFFI.ffiModel.platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryPeers = {..._curPeers};
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_queryCoun < _maxQueryCount) {
|
||||
if (now.difference(_lastQueryTime) > Duration(seconds: 20)) {
|
||||
gFFI.ffiModel.platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun += 1;
|
||||
if (_curPeers.length > 0) {
|
||||
gFFI.ffiModel.platformFFI.ffiBind
|
||||
.queryOnlines(ids: _curPeers.toList(growable: false));
|
||||
_lastQueryTime = DateTime.now();
|
||||
_queryCoun += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +202,6 @@ class DiscoveredPeerWidget extends BasePeerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("DiscoveredPeerWidget build");
|
||||
final widget = super.build(context);
|
||||
gFFI.bind.mainLoadLanPeers();
|
||||
return widget;
|
||||
|
||||
@@ -405,7 +405,6 @@ class RecentPeerCard extends BasePeerCard {
|
||||
: super(peer: peer, key: key, type: PeerType.recent);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
debugPrint("call RecentPeerCard _getPopupMenuItems");
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
@@ -427,7 +426,6 @@ class FavoritePeerCard extends BasePeerCard {
|
||||
: super(peer: peer, key: key, type: PeerType.fav);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
debugPrint("call FavoritePeerCard _getPopupMenuItems");
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
@@ -451,7 +449,6 @@ class DiscoveredPeerCard extends BasePeerCard {
|
||||
: super(peer: peer, key: key, type: PeerType.discovered);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
debugPrint("call DiscoveredPeerCard _getPopupMenuItems");
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
@@ -473,7 +470,6 @@ class AddressBookPeerCard extends BasePeerCard {
|
||||
: super(peer: peer, key: key, type: PeerType.ab);
|
||||
|
||||
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||
debugPrint("call AddressBookPeerCard _getPopupMenuItems");
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
child: Text(translate('Connect')), value: 'connect'),
|
||||
|
||||
@@ -22,7 +22,8 @@ class DesktopTitleBar extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: child ?? Offstage(),)
|
||||
child: child ?? Offstage(),
|
||||
)
|
||||
// const WindowButtons()
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user