mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
@@ -98,7 +98,8 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
floatingActionButton: AutoHide(
|
||||
key: _autoHideKey,
|
||||
direction: AxisDirection.right,
|
||||
direction: AxisDirection.down,
|
||||
offset: 75,
|
||||
controller: _scrollController,
|
||||
child: FloatingActionButton(
|
||||
heroTag: 'addServer',
|
||||
|
||||
@@ -29,6 +29,7 @@ const _echoPWD = 'echo \$PWD';
|
||||
class SSHPage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
final String? initCmd;
|
||||
final Snippet? initSnippet;
|
||||
final bool notFromTab;
|
||||
final Function()? onSessionEnd;
|
||||
final GlobalKey<TerminalViewState>? terminalKey;
|
||||
@@ -37,6 +38,7 @@ class SSHPage extends StatefulWidget {
|
||||
super.key,
|
||||
required this.spi,
|
||||
this.initCmd,
|
||||
this.initSnippet,
|
||||
this.notFromTab = true,
|
||||
this.onSessionEnd,
|
||||
this.terminalKey,
|
||||
@@ -309,8 +311,7 @@ class SSHPageState extends State<SSHPage>
|
||||
|
||||
final snippet = snippets.firstOrNull;
|
||||
if (snippet == null) return;
|
||||
_terminal.textInput(snippet.script);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
snippet.runInTerm(_terminal, widget.spi);
|
||||
break;
|
||||
case VirtualKeyFunc.file:
|
||||
// get $PWD from SSH session
|
||||
@@ -415,16 +416,19 @@ class SSHPageState extends State<SSHPage>
|
||||
|
||||
_initService();
|
||||
|
||||
for (final snippet in Pros.snippet.snippets) {
|
||||
if (snippet.autoRunOn?.contains(widget.spi.id) == true) {
|
||||
snippet.runInTerm(_terminal, widget.spi);
|
||||
}
|
||||
}
|
||||
|
||||
if (widget.initCmd != null) {
|
||||
_terminal.textInput(widget.initCmd!);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
} else {
|
||||
for (final snippet in Pros.snippet.snippets) {
|
||||
if (snippet.autoRunOn?.contains(widget.spi.id) == true) {
|
||||
_terminal.textInput(snippet.script);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (widget.initSnippet != null) {
|
||||
widget.initSnippet!.runInTerm(_terminal, widget.spi);
|
||||
}
|
||||
|
||||
SSHPage.focusNode.requestFocus();
|
||||
|
||||
@@ -96,6 +96,7 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
|
||||
Widget _buildAddPage() {
|
||||
return Center(
|
||||
key: const Key('sshTabAddServer'),
|
||||
child: Consumer<ServerProvider>(builder: (_, pro, __) {
|
||||
if (pro.serverOrder.isEmpty) {
|
||||
return Center(
|
||||
@@ -105,21 +106,27 @@ class _SSHTabPageState extends State<SSHTabPage>
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.all(7),
|
||||
itemBuilder: (_, idx) {
|
||||
final spi = Pros.server.pick(id: pro.serverOrder[idx])?.spi;
|
||||
if (spi == null) return UIs.placeholder;
|
||||
return CardX(
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 17, right: 7),
|
||||
title: Text(spi.name),
|
||||
subtitle: Text(spi.id, style: UIs.textGrey),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => _onTapInitCard(spi),
|
||||
),
|
||||
).center(),
|
||||
);
|
||||
},
|
||||
itemCount: pro.servers.length,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 3,
|
||||
crossAxisSpacing: 3,
|
||||
mainAxisSpacing: 3,
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -126,7 +126,7 @@ void _onTapMoreBtns(
|
||||
if (snippets == null || snippets.isEmpty) return;
|
||||
final snippet = snippets.firstOrNull;
|
||||
if (snippet == null) return;
|
||||
final fmted = snippet.fmtWith(spi);
|
||||
final fmted = snippet.fmtWithSpi(spi);
|
||||
final sure = await context.showRoundDialog<bool>(
|
||||
title: l10n.attention,
|
||||
child: SingleChildScrollView(
|
||||
@@ -141,7 +141,7 @@ void _onTapMoreBtns(
|
||||
],
|
||||
);
|
||||
if (sure != true) return;
|
||||
AppRoutes.ssh(spi: spi, initCmd: fmted).checkGo(
|
||||
AppRoutes.ssh(spi: spi, initSnippet: snippet).checkGo(
|
||||
context: context,
|
||||
check: () => _checkClient(context, spi.id),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user