fix: ssh terminal ui

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-06-07 17:18:42 +08:00
parent 4d52023982
commit ba686db847

View File

@@ -75,7 +75,6 @@ class SSHPageState extends State<SSHPage>
late MediaQueryData _media; late MediaQueryData _media;
late TerminalStyle _terminalStyle; late TerminalStyle _terminalStyle;
late TerminalTheme _terminalTheme; late TerminalTheme _terminalTheme;
double _virtKeyWidth = 0;
double _virtKeysHeight = 0; double _virtKeysHeight = 0;
late final _horizonVirtKeys = Stores.setting.horizonVirtKey.fetch(); late final _horizonVirtKeys = Stores.setting.horizonVirtKey.fetch();
@@ -135,7 +134,6 @@ class SSHPageState extends State<SSHPage>
// Because the virtual keyboard only displayed on mobile devices // Because the virtual keyboard only displayed on mobile devices
if (isMobile) { if (isMobile) {
_virtKeyWidth = _media.size.width / 7;
if (_horizonVirtKeys) { if (_horizonVirtKeys) {
_virtKeysHeight = 37; _virtKeysHeight = 37;
} else { } else {
@@ -156,12 +154,14 @@ class SSHPageState extends State<SSHPage>
_handleEscKeyOrBackButton(); _handleEscKeyOrBackButton();
}, },
child: Scaffold( child: Scaffold(
appBar: CustomAppBar( appBar: widget.args.notFromTab
leading: BackButton(onPressed: context.pop), ? CustomAppBar(
title: Text(widget.args.spi.name), leading: BackButton(onPressed: context.pop),
actions: [_buildCopyBtn], title: Text(widget.args.spi.name),
centerTitle: false, actions: [_buildCopyBtn],
), centerTitle: false,
)
: null,
backgroundColor: hasBg ? Colors.transparent : _terminalTheme.background, backgroundColor: hasBg ? Colors.transparent : _terminalTheme.background,
body: _buildBody(), body: _buildBody(),
bottomNavigationBar: isDesktop ? null : _buildBottom(), bottomNavigationBar: isDesktop ? null : _buildBottom(),
@@ -258,17 +258,31 @@ class SSHPageState extends State<SSHPage>
} }
Widget _buildVirtualKey() { Widget _buildVirtualKey() {
if (_horizonVirtKeys) { final count = _horizonVirtKeys ? _virtKeysList.length : _virtKeysList.firstOrNull?.length ?? 0;
return SingleChildScrollView( if (count == 0) return UIs.placeholder;
scrollDirection: Axis.horizontal, return LayoutBuilder(
child: Row(children: _virtKeysList.expand((e) => e).map(_buildVirtKeyItem).toList()), builder: (_, cons) {
); final virtKeyWidth = cons.maxWidth / count;
} if (_horizonVirtKeys) {
final rows = _virtKeysList.map((e) => Row(children: e.map(_buildVirtKeyItem).toList())).toList(); return SingleChildScrollView(
return Column(mainAxisSize: MainAxisSize.min, children: rows); 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; var selected = false;
switch (item.key) { switch (item.key) {
case TerminalKey.control: case TerminalKey.control:
@@ -304,7 +318,7 @@ class SSHPageState extends State<SSHPage>
onTapCancel: () => _virtKeyLongPressTimer?.cancel(), onTapCancel: () => _virtKeyLongPressTimer?.cancel(),
onTapUp: (_) => _virtKeyLongPressTimer?.cancel(), onTapUp: (_) => _virtKeyLongPressTimer?.cancel(),
child: SizedBox( child: SizedBox(
width: _virtKeyWidth, width: virtKeyWidth,
height: _virtKeysHeight / _virtKeysList.length, height: _virtKeysHeight / _virtKeysList.length,
child: Center(child: child), child: Center(child: child),
), ),