desktop close connection tab (remote page)
This commit is contained in:
parent
c9c40508e7
commit
ce050e250d
@ -4,6 +4,7 @@ import 'dart:io';
|
|||||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||||
import 'package:get/instance_manager.dart';
|
import 'package:get/instance_manager.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
@ -66,11 +67,11 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
backToHomePage() {
|
closeConnection({String? id}) {
|
||||||
if (isAndroid || isIOS) {
|
if (isAndroid || isIOS) {
|
||||||
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
||||||
} else {
|
} else {
|
||||||
// TODO desktop
|
closeTab(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +307,7 @@ void msgBox(
|
|||||||
0,
|
0,
|
||||||
wrap(translate('OK'), () {
|
wrap(translate('OK'), () {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
backToHomePage();
|
closeConnection();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (hasCancel == null) {
|
if (hasCancel == null) {
|
||||||
|
@ -60,7 +60,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
_ffi.dialogManager
|
_ffi.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: backToHomePage);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
|
@ -10,6 +10,25 @@ const double _kTabBarHeight = kDesktopRemoteTabBarHeight;
|
|||||||
const double _kIconSize = 18;
|
const double _kIconSize = 18;
|
||||||
const double _kDividerIndent = 10;
|
const double _kDividerIndent = 10;
|
||||||
const double _kAddIconSize = _kTabBarHeight - 15;
|
const double _kAddIconSize = _kTabBarHeight - 15;
|
||||||
|
final tabBarKey = GlobalKey();
|
||||||
|
|
||||||
|
void closeTab(String? id) {
|
||||||
|
final tabBar = tabBarKey.currentWidget as TabBar?;
|
||||||
|
if (tabBar == null) return;
|
||||||
|
final tabs = tabBar.tabs as List<_Tab>;
|
||||||
|
if (id == null) {
|
||||||
|
final current = tabBar.controller?.index;
|
||||||
|
if (current == null) return;
|
||||||
|
tabs[current].onClose();
|
||||||
|
} else {
|
||||||
|
for (final tab in tabs) {
|
||||||
|
if (tab.label == id) {
|
||||||
|
tab.onClose();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TabInfo {
|
class TabInfo {
|
||||||
late final String label;
|
late final String label;
|
||||||
@ -59,6 +78,7 @@ class DesktopTabBar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Obx(() => TabBar(
|
child: Obx(() => TabBar(
|
||||||
|
key: tabBarKey,
|
||||||
indicatorColor: _theme.indicatorColor,
|
indicatorColor: _theme.indicatorColor,
|
||||||
labelPadding: const EdgeInsets.symmetric(
|
labelPadding: const EdgeInsets.symmetric(
|
||||||
vertical: 0, horizontal: 0),
|
vertical: 0, horizontal: 0),
|
||||||
|
@ -29,7 +29,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
gFFI.connect(widget.id, isFileTransfer: true);
|
gFFI.connect(widget.id, isFileTransfer: true);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
gFFI.dialogManager
|
gFFI.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: backToHomePage);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
gFFI.ffiModel.updateEventListener(widget.id);
|
gFFI.ffiModel.updateEventListener(widget.id);
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
|
@ -51,7 +51,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
gFFI.dialogManager
|
gFFI.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: backToHomePage);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
_interval =
|
_interval =
|
||||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||||
});
|
});
|
||||||
|
@ -132,7 +132,7 @@ class _ScanPageState extends State<ScanPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showServerSettingFromQr(String data) async {
|
void showServerSettingFromQr(String data) async {
|
||||||
backToHomePage();
|
closeConnection();
|
||||||
await controller?.pauseCamera();
|
await controller?.pauseCamera();
|
||||||
if (!data.startsWith('config=')) {
|
if (!data.startsWith('config=')) {
|
||||||
showToast('Invalid QR code');
|
showToast('Invalid QR code');
|
||||||
|
@ -184,7 +184,7 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
|||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
close();
|
close();
|
||||||
backToHomePage();
|
closeConnection();
|
||||||
},
|
},
|
||||||
child: Text(translate('Cancel')),
|
child: Text(translate('Cancel')),
|
||||||
),
|
),
|
||||||
@ -196,7 +196,7 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
|||||||
gFFI.login(id, text, remember);
|
gFFI.login(id, text, remember);
|
||||||
close();
|
close();
|
||||||
dialogManager.showLoading(translate('Logging in...'),
|
dialogManager.showLoading(translate('Logging in...'),
|
||||||
onCancel: backToHomePage);
|
onCancel: closeConnection);
|
||||||
},
|
},
|
||||||
child: Text(translate('OK')),
|
child: Text(translate('OK')),
|
||||||
),
|
),
|
||||||
@ -214,7 +214,7 @@ void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) {
|
|||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
close();
|
close();
|
||||||
backToHomePage();
|
closeConnection();
|
||||||
},
|
},
|
||||||
child: Text(translate('Cancel')),
|
child: Text(translate('Cancel')),
|
||||||
),
|
),
|
||||||
|
@ -287,7 +287,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
bind.sessionReconnect(id: id);
|
bind.sessionReconnect(id: id);
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
dialogManager.showLoading(translate('Connecting...'),
|
dialogManager.showLoading(translate('Connecting...'),
|
||||||
onCancel: backToHomePage);
|
onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
_reconnects *= 2;
|
_reconnects *= 2;
|
||||||
} else {
|
} else {
|
||||||
@ -335,7 +335,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
if (displays.length > 0) {
|
if (displays.length > 0) {
|
||||||
parent.target?.dialogManager.showLoading(
|
parent.target?.dialogManager.showLoading(
|
||||||
translate('Connected, waiting for image...'),
|
translate('Connected, waiting for image...'),
|
||||||
onCancel: backToHomePage);
|
onCancel: closeConnection);
|
||||||
_waitForImage = true;
|
_waitForImage = true;
|
||||||
_reconnects = 1;
|
_reconnects = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user