mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: ssh tab multi page FocusNode
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_background_service/flutter_background_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
@@ -30,6 +31,7 @@ class SSHPage extends StatefulWidget {
|
||||
final String? initCmd;
|
||||
final bool notFromTab;
|
||||
final Function()? onSessionEnd;
|
||||
final FocusNode? focus;
|
||||
|
||||
const SSHPage({
|
||||
super.key,
|
||||
@@ -37,6 +39,7 @@ class SSHPage extends StatefulWidget {
|
||||
this.initCmd,
|
||||
this.notFromTab = true,
|
||||
this.onSessionEnd,
|
||||
this.focus,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -50,7 +53,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
late final _terminal = Terminal(inputHandler: _keyboard);
|
||||
final TerminalController _terminalController = TerminalController();
|
||||
final List<List<VirtKey>> _virtKeysList = [];
|
||||
final _focus = FocusNode();
|
||||
late final _focus = widget.focus ?? FocusNode();
|
||||
|
||||
late MediaQueryData _media;
|
||||
late TerminalStyle _terminalStyle;
|
||||
|
||||
@@ -25,6 +25,7 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
vsync: this,
|
||||
);
|
||||
final _fabRN = ValueNotifier(0);
|
||||
final _focusMap = <String, FocusNode>{};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -36,7 +37,10 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
dividerColor: Colors.transparent,
|
||||
onTap: (value) => _fabRN.value = value,
|
||||
onTap: (value) {
|
||||
_fabRN.value = value;
|
||||
_focusMap[_tabIds.keys.elementAt(value)]?.requestFocus();
|
||||
},
|
||||
),
|
||||
body: _buildBody(),
|
||||
floatingActionButton: ListenableBuilder(
|
||||
@@ -138,10 +142,10 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
}
|
||||
return spi.name;
|
||||
}();
|
||||
final key = GlobalKey<State<SSHPage>>(debugLabel: 'sshTabPage_$name');
|
||||
final focus = _focusMap.putIfAbsent(name, () => FocusNode());
|
||||
_tabIds[name] = SSHPage(
|
||||
key: key,
|
||||
spi: spi,
|
||||
focus: focus,
|
||||
notFromTab: false,
|
||||
onSessionEnd: () {
|
||||
// debugPrint("Session done received on page whose tabId = $name");
|
||||
|
||||
Reference in New Issue
Block a user