From ba686db8473dd8c75c6f71d6a0f643132126059d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:18:42 +0800 Subject: [PATCH] fix: ssh terminal ui --- lib/view/page/ssh/page/page.dart | 50 ++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/view/page/ssh/page/page.dart b/lib/view/page/ssh/page/page.dart index 0afab982..e296768d 100644 --- a/lib/view/page/ssh/page/page.dart +++ b/lib/view/page/ssh/page/page.dart @@ -75,7 +75,6 @@ class SSHPageState extends State late MediaQueryData _media; late TerminalStyle _terminalStyle; late TerminalTheme _terminalTheme; - double _virtKeyWidth = 0; double _virtKeysHeight = 0; late final _horizonVirtKeys = Stores.setting.horizonVirtKey.fetch(); @@ -135,7 +134,6 @@ class SSHPageState extends State // Because the virtual keyboard only displayed on mobile devices if (isMobile) { - _virtKeyWidth = _media.size.width / 7; if (_horizonVirtKeys) { _virtKeysHeight = 37; } else { @@ -156,12 +154,14 @@ class SSHPageState extends State _handleEscKeyOrBackButton(); }, child: Scaffold( - appBar: CustomAppBar( - leading: BackButton(onPressed: context.pop), - title: Text(widget.args.spi.name), - actions: [_buildCopyBtn], - centerTitle: false, - ), + appBar: widget.args.notFromTab + ? CustomAppBar( + leading: BackButton(onPressed: context.pop), + title: Text(widget.args.spi.name), + actions: [_buildCopyBtn], + centerTitle: false, + ) + : null, backgroundColor: hasBg ? Colors.transparent : _terminalTheme.background, body: _buildBody(), bottomNavigationBar: isDesktop ? null : _buildBottom(), @@ -258,17 +258,31 @@ class SSHPageState extends State } Widget _buildVirtualKey() { - if (_horizonVirtKeys) { - return SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row(children: _virtKeysList.expand((e) => e).map(_buildVirtKeyItem).toList()), - ); - } - final rows = _virtKeysList.map((e) => Row(children: e.map(_buildVirtKeyItem).toList())).toList(); - return Column(mainAxisSize: MainAxisSize.min, children: rows); + final count = _horizonVirtKeys ? _virtKeysList.length : _virtKeysList.firstOrNull?.length ?? 0; + if (count == 0) return UIs.placeholder; + return LayoutBuilder( + builder: (_, cons) { + final virtKeyWidth = cons.maxWidth / count; + if (_horizonVirtKeys) { + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: _virtKeysList + .expand((e) => e) + .map((e) => _buildVirtKeyItem(e, virtKeyWidth)) + .toList(), + ), + ); + } + final rows = _virtKeysList + .map((e) => Row(children: e.map((e) => _buildVirtKeyItem(e, virtKeyWidth)).toList())) + .toList(); + return Column(mainAxisSize: MainAxisSize.min, children: rows); + }, + ); } - Widget _buildVirtKeyItem(VirtKey item) { + Widget _buildVirtKeyItem(VirtKey item, double virtKeyWidth) { var selected = false; switch (item.key) { case TerminalKey.control: @@ -304,7 +318,7 @@ class SSHPageState extends State onTapCancel: () => _virtKeyLongPressTimer?.cancel(), onTapUp: (_) => _virtKeyLongPressTimer?.cancel(), child: SizedBox( - width: _virtKeyWidth, + width: virtKeyWidth, height: _virtKeysHeight / _virtKeysList.length, child: Center(child: child), ),