mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 16:45:27 +01:00
fix: ssh term (#365)
This commit is contained in:
@@ -37,7 +37,7 @@ class EditorPage extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
_EditorPageState createState() => _EditorPageState();
|
||||
State<EditorPage> createState() => _EditorPageState();
|
||||
}
|
||||
|
||||
class _EditorPageState extends State<EditorPage> {
|
||||
|
||||
@@ -14,7 +14,7 @@ class PingPage extends StatefulWidget {
|
||||
const PingPage({super.key});
|
||||
|
||||
@override
|
||||
_PingPageState createState() => _PingPageState();
|
||||
State<PingPage> createState() => _PingPageState();
|
||||
}
|
||||
|
||||
class _PingPageState extends State<PingPage>
|
||||
|
||||
@@ -19,7 +19,7 @@ class PrivateKeyEditPage extends StatefulWidget {
|
||||
final PrivateKeyInfo? pki;
|
||||
|
||||
@override
|
||||
_PrivateKeyEditPageState createState() => _PrivateKeyEditPageState();
|
||||
State<PrivateKeyEditPage> createState() => _PrivateKeyEditPageState();
|
||||
}
|
||||
|
||||
class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
|
||||
@@ -15,7 +15,7 @@ class PrivateKeysListPage extends StatefulWidget {
|
||||
const PrivateKeysListPage({super.key});
|
||||
|
||||
@override
|
||||
_PrivateKeyListState createState() => _PrivateKeyListState();
|
||||
State<PrivateKeysListPage> createState() => _PrivateKeyListState();
|
||||
}
|
||||
|
||||
class _PrivateKeyListState extends State<PrivateKeysListPage>
|
||||
|
||||
@@ -16,7 +16,7 @@ class ProcessPage extends StatefulWidget {
|
||||
const ProcessPage({super.key, required this.spi});
|
||||
|
||||
@override
|
||||
_ProcessPageState createState() => _ProcessPageState();
|
||||
State<ProcessPage> createState() => _ProcessPageState();
|
||||
}
|
||||
|
||||
class _ProcessPageState extends State<ProcessPage> {
|
||||
|
||||
@@ -19,7 +19,7 @@ final class PvePage extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
_PvePageState createState() => _PvePageState();
|
||||
State<PvePage> createState() => _PvePageState();
|
||||
}
|
||||
|
||||
const _kHorziPadding = 11.0;
|
||||
|
||||
@@ -32,7 +32,7 @@ class ServerDetailPage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
|
||||
@override
|
||||
_ServerDetailPageState createState() => _ServerDetailPageState();
|
||||
State<ServerDetailPage> createState() => _ServerDetailPageState();
|
||||
}
|
||||
|
||||
class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
|
||||
@@ -20,7 +20,7 @@ class ServerEditPage extends StatefulWidget {
|
||||
final ServerPrivateInfo? spi;
|
||||
|
||||
@override
|
||||
_ServerEditPageState createState() => _ServerEditPageState();
|
||||
State<ServerEditPage> createState() => _ServerEditPageState();
|
||||
}
|
||||
|
||||
class _ServerEditPageState extends State<ServerEditPage> {
|
||||
|
||||
@@ -25,7 +25,7 @@ class ServerPage extends StatefulWidget {
|
||||
const ServerPage({super.key});
|
||||
|
||||
@override
|
||||
_ServerPageState createState() => _ServerPageState();
|
||||
State<ServerPage> createState() => _ServerPageState();
|
||||
}
|
||||
|
||||
class _ServerPageState extends State<ServerPage>
|
||||
|
||||
@@ -23,7 +23,7 @@ class SettingPage extends StatefulWidget {
|
||||
const SettingPage({super.key});
|
||||
|
||||
@override
|
||||
_SettingPageState createState() => _SettingPageState();
|
||||
State<SettingPage> createState() => _SettingPageState();
|
||||
}
|
||||
|
||||
class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
@@ -14,7 +14,7 @@ class IOSSettingsPage extends StatefulWidget {
|
||||
const IOSSettingsPage({super.key});
|
||||
|
||||
@override
|
||||
_IOSSettingsPageState createState() => _IOSSettingsPageState();
|
||||
State<IOSSettingsPage> createState() => _IOSSettingsPageState();
|
||||
}
|
||||
|
||||
class _IOSSettingsPageState extends State<IOSSettingsPage> {
|
||||
@@ -83,7 +83,7 @@ class _IOSSettingsPageState extends State<IOSSettingsPage> {
|
||||
}
|
||||
|
||||
Widget _buildWatchApp() {
|
||||
return FutureWidget<Map<String, dynamic>?>(
|
||||
return FutureWidget(
|
||||
future: () async {
|
||||
if (!await wc.isPaired) {
|
||||
return null;
|
||||
@@ -107,6 +107,7 @@ class _IOSSettingsPageState extends State<IOSSettingsPage> {
|
||||
}
|
||||
return ListTile(
|
||||
title: const Text('Watch app'),
|
||||
subtitle: Text(l10n.edit, style: UIs.textGrey),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () async => _onTapWatchApp(ctx),
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ class ServerOrderPage extends StatefulWidget {
|
||||
const ServerOrderPage({super.key});
|
||||
|
||||
@override
|
||||
_ServerOrderPageState createState() => _ServerOrderPageState();
|
||||
State<ServerOrderPage> createState() => _ServerOrderPageState();
|
||||
}
|
||||
|
||||
class _ServerOrderPageState extends State<ServerOrderPage> {
|
||||
|
||||
@@ -8,7 +8,7 @@ class SSHVirtKeySettingPage extends StatefulWidget {
|
||||
const SSHVirtKeySettingPage({super.key});
|
||||
|
||||
@override
|
||||
_SSHVirtKeySettingPageState createState() => _SSHVirtKeySettingPageState();
|
||||
State<SSHVirtKeySettingPage> createState() => _SSHVirtKeySettingPageState();
|
||||
}
|
||||
|
||||
class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
|
||||
@@ -13,7 +13,7 @@ class SnippetEditPage extends StatefulWidget {
|
||||
final Snippet? snippet;
|
||||
|
||||
@override
|
||||
_SnippetEditPageState createState() => _SnippetEditPageState();
|
||||
State<SnippetEditPage> createState() => _SnippetEditPageState();
|
||||
}
|
||||
|
||||
class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
|
||||
@@ -12,7 +12,7 @@ class SnippetListPage extends StatefulWidget {
|
||||
const SnippetListPage({super.key});
|
||||
|
||||
@override
|
||||
_SnippetListPageState createState() => _SnippetListPageState();
|
||||
State<SnippetListPage> createState() => _SnippetListPageState();
|
||||
}
|
||||
|
||||
class _SnippetListPageState extends State<SnippetListPage> {
|
||||
|
||||
@@ -30,7 +30,7 @@ class SSHPage extends StatefulWidget {
|
||||
final String? initCmd;
|
||||
final bool notFromTab;
|
||||
final Function()? onSessionEnd;
|
||||
final FocusNode? focus;
|
||||
final GlobalKey<TerminalViewState>? terminalKey;
|
||||
|
||||
const SSHPage({
|
||||
super.key,
|
||||
@@ -38,11 +38,11 @@ class SSHPage extends StatefulWidget {
|
||||
this.initCmd,
|
||||
this.notFromTab = true,
|
||||
this.onSessionEnd,
|
||||
this.focus,
|
||||
this.terminalKey,
|
||||
});
|
||||
|
||||
@override
|
||||
_SSHPageState createState() => _SSHPageState();
|
||||
State<SSHPage> createState() => _SSHPageState();
|
||||
}
|
||||
|
||||
const _horizonPadding = 7.0;
|
||||
@@ -52,7 +52,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
late final _terminal = Terminal(inputHandler: _keyboard);
|
||||
final TerminalController _terminalController = TerminalController();
|
||||
final List<List<VirtKey>> _virtKeysList = [];
|
||||
late final _focus = widget.focus ?? FocusNode();
|
||||
late final _termKey = widget.terminalKey ?? GlobalKey<TerminalViewState>();
|
||||
|
||||
late MediaQueryData _media;
|
||||
late TerminalStyle _terminalStyle;
|
||||
@@ -144,8 +144,8 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
),
|
||||
child: TerminalView(
|
||||
_terminal,
|
||||
key: _termKey,
|
||||
controller: _terminalController,
|
||||
focusNode: _focus,
|
||||
keyboardType: TextInputType.text,
|
||||
enableSuggestions: true,
|
||||
textStyle: _terminalStyle,
|
||||
@@ -282,11 +282,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
Future<void> _doVirtualKeyFunc(VirtualKeyFunc type) async {
|
||||
switch (type) {
|
||||
case VirtualKeyFunc.toggleIME:
|
||||
if (!_focus.hasFocus) {
|
||||
_focus.requestFocus();
|
||||
} else {
|
||||
_focus.unfocus();
|
||||
}
|
||||
_termKey.currentState?.toggleFocus();
|
||||
break;
|
||||
case VirtualKeyFunc.backspace:
|
||||
_terminal.keyInput(TerminalKey.backspace);
|
||||
|
||||
@@ -17,8 +17,8 @@ class SSHTabPage extends StatefulWidget {
|
||||
|
||||
class _SSHTabPageState extends State<SSHTabPage>
|
||||
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
late final _tabMap = <String, ({Widget page, FocusNode? focus})>{
|
||||
l10n.add: (page: _buildAddPage(), focus: null),
|
||||
late final _tabMap = <String, ({Widget page})>{
|
||||
l10n.add: (page: _buildAddPage()),
|
||||
};
|
||||
late var _tabController = TabController(
|
||||
length: _tabMap.length,
|
||||
@@ -38,8 +38,7 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
dividerColor: Colors.transparent,
|
||||
onTap: (value) {
|
||||
_fabRN.value = value;
|
||||
final mapKey = _tabMap.keys.elementAt(value);
|
||||
_tabMap[mapKey]?.focus?.requestFocus();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
),
|
||||
body: _buildBody(),
|
||||
@@ -70,20 +69,27 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
IconBtn(
|
||||
icon: Icons.close,
|
||||
onTap: () async {
|
||||
final confirm = await context.showRoundDialog<bool>(
|
||||
title: l10n.attention,
|
||||
child: Text('${l10n.close} SSH ${l10n.conn}($e) ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(l10n.ok, style: UIs.textRed),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(false),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
],
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(l10n.attention),
|
||||
content: Text('${l10n.close} SSH ${l10n.conn}($e) ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(l10n.ok, style: UIs.textRed),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(false),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
Future.delayed(const Duration(milliseconds: 50),
|
||||
FocusScope.of(context).unfocus);
|
||||
if (confirm != true) {
|
||||
return;
|
||||
}
|
||||
@@ -142,18 +148,15 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
}
|
||||
return spi.name;
|
||||
}();
|
||||
final focus = FocusNode();
|
||||
_tabMap[name] = (
|
||||
page: SSHPage(
|
||||
spi: spi,
|
||||
focus: focus,
|
||||
notFromTab: false,
|
||||
onSessionEnd: () {
|
||||
_tabMap.remove(name);
|
||||
_refreshTabs();
|
||||
},
|
||||
),
|
||||
focus: focus,
|
||||
);
|
||||
_refreshTabs();
|
||||
final idx = _tabMap.length - 1;
|
||||
|
||||
@@ -32,7 +32,7 @@ class SftpPage extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
_SftpPageState createState() => _SftpPageState();
|
||||
State<SftpPage> createState() => _SftpPageState();
|
||||
}
|
||||
|
||||
class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
|
||||
@@ -12,7 +12,7 @@ class SftpMissionPage extends StatefulWidget {
|
||||
const SftpMissionPage({super.key});
|
||||
|
||||
@override
|
||||
_SftpMissionPageState createState() => _SftpMissionPageState();
|
||||
State<SftpMissionPage> createState() => _SftpMissionPageState();
|
||||
}
|
||||
|
||||
class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
|
||||
Reference in New Issue
Block a user