new: ssh page zoom (#256)

This commit is contained in:
lollipopkit
2024-03-08 01:18:11 -06:00
parent 9ad710fade
commit 7b74d83c23
12 changed files with 64 additions and 32 deletions

View File

@@ -241,6 +241,7 @@
"system": "Systeme",
"tag": "Tags",
"temperature": "Temperatur",
"termFontSizeTip": "Diese Einstellung beeinflusst die Größe des Terminals (Breite und Höhe).",
"terminal": "Terminal",
"test": "Prüfung",
"textScaler": "Skalierung der Schriftart",

View File

@@ -241,6 +241,7 @@
"system": "System",
"tag": "Tags",
"temperature": "Temperature",
"termFontSizeTip": "This setting will affect the terminal size (width and height).",
"terminal": "Terminal",
"test": "Test",
"textScaler": "Text scaler",

View File

@@ -241,6 +241,7 @@
"system": "Sistema",
"tag": "Etiqueta",
"temperature": "Temperatura",
"termFontSizeTip": "Este ajuste afectará el tamaño del terminal (ancho y alto).",
"terminal": "Terminal",
"test": "Prueba",
"textScaler": "Escalar texto",
@@ -282,4 +283,4 @@
"whenOpenApp": "Al abrir la App",
"willTakEeffectImmediately": "Los cambios tendrán efecto inmediatamente",
"write": "Escribir"
}
}

View File

@@ -241,6 +241,7 @@
"system": "Système",
"tag": "Étiquettes",
"temperature": "Température",
"termFontSizeTip": "Ce paramètre affectera la taille du terminal (largeur et hauteur).",
"terminal": "Terminal",
"test": "Tester",
"textScaler": "Mise à l'échelle du texte",

View File

@@ -241,6 +241,7 @@
"system": "Sistem",
"tag": "Tag",
"temperature": "Suhu",
"termFontSizeTip": "Pengaturan ini akan memengaruhi ukuran terminal (lebar dan tinggi).",
"terminal": "Terminal",
"test": "pengujian",
"textScaler": "Penskalaan font",

View File

@@ -241,6 +241,7 @@
"system": "システム",
"tag": "タグ",
"temperature": "温度",
"termFontSizeTip": "この設定は端末のサイズ(幅と高さ)に影響します",
"terminal": "ターミナル",
"test": "テスト",
"textScaler": "テキストスケーラー",
@@ -282,4 +283,4 @@
"whenOpenApp": "アプリを開くとき",
"willTakEeffectImmediately": "変更は即座に有効になります",
"write": "書き込み"
}
}

View File

@@ -241,6 +241,7 @@
"system": "Sistema",
"tag": "Tag",
"temperature": "Temperatura",
"termFontSizeTip": "Esta configuração afetará o tamanho do terminal (largura e altura).",
"terminal": "Terminal",
"test": "Teste",
"textScaler": "Escala de texto",
@@ -282,4 +283,4 @@
"whenOpenApp": "Ao abrir o app",
"willTakEeffectImmediately": "As alterações serão aplicadas imediatamente",
"write": "Escrita"
}
}

View File

@@ -241,6 +241,7 @@
"system": "система",
"tag": "тег",
"temperature": "температура",
"termFontSizeTip": "Эта настройка повлияет на размер терминала (ширина и высота).",
"terminal": "терминал",
"test": "тест",
"textScaler": "масштабирование текста",
@@ -282,4 +283,4 @@
"whenOpenApp": "при открытии приложения",
"willTakEeffectImmediately": "Изменения вступят в силу немедленно",
"write": "запись"
}
}

View File

@@ -241,6 +241,7 @@
"system": "系统",
"tag": "标签",
"temperature": "温度",
"termFontSizeTip": "此设置会影响终端大小(宽高)",
"terminal": "终端",
"test": "测试",
"textScaler": "字体缩放",

View File

@@ -241,6 +241,7 @@
"system": "系統",
"tag": "标签",
"temperature": "溫度",
"termFontSizeTip": "此設置將影響終端大小(寬度和高度)",
"terminal": "终端機",
"test": "測試",
"textScaler": "字體縮放",

View File

@@ -563,16 +563,17 @@ class _SettingPageState extends State<SettingPage> {
}
Widget _buildTermFontSize() {
return ListenableBuilder(
listenable: _termFontSize,
builder: (_, __) => ListTile(
title: Text(l10n.fontSize),
trailing: Text(
_termFontSize.value.toString(),
return ListTile(
title: Text(l10n.fontSize),
subtitle: Text(l10n.termFontSizeTip, style: UIs.textGrey),
trailing: ValueListenableBuilder(
valueListenable: _setting.termFontSize.listenable(),
builder: (_, val, __) => Text(
val.toString(),
style: UIs.text15,
),
onTap: () => _showFontSizeDialog(_termFontSize, _setting.termFontSize),
),
onTap: () => _showFontSizeDialog(_termFontSize, _setting.termFontSize),
);
}

View File

@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/material.dart';
@@ -57,6 +58,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
late TerminalStyle _terminalStyle;
late TerminalTheme _terminalTheme;
late TextInputType _keyboardType;
late double _originTextSize;
double _virtKeyWidth = 0;
double _virtKeysHeight = 0;
@@ -69,13 +71,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
@override
void initState() {
super.initState();
final fontFamilly = getFileName(Stores.setting.fontPath.fetch());
final textStyle = TextStyle(
fontFamily: fontFamilly,
fontSize: Stores.setting.termFontSize.fetch(),
);
_terminalStyle = TerminalStyle.fromTextStyle(textStyle);
_keyboardType = TextInputType.values[Stores.setting.keyboardType.fetch()];
_initStoredCfg();
_initVirtKeys();
Future.delayed(const Duration(milliseconds: 77), () async {
@@ -138,17 +134,31 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
_media.padding.bottom -
_media.padding.top,
child: Padding(
padding: EdgeInsets.only(top: _media.padding.top),
child: TerminalView(
_terminal,
controller: _terminalController,
keyboardType: _keyboardType,
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isMobile,
autofocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
//hideScrollBar: false,
padding: EdgeInsets.only(top: _media.padding.top, left: 7, right: 7),
child: GestureDetector(
onScaleUpdate: (details) {
if (details.scale == 1) {
return;
}
final scale = math.pow(details.scale, 0.3);
final fontSize = _originTextSize * scale;
if (fontSize < 7 || fontSize > 17) {
return;
}
_terminalStyle = _terminalStyle.copyWith(fontSize: fontSize);
setState(() {});
},
child: TerminalView(
_terminal,
controller: _terminalController,
keyboardType: _keyboardType,
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isMobile,
autofocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
//hideScrollBar: false,
),
),
),
);
@@ -225,9 +235,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
child: SizedBox(
width: _virtKeyWidth,
height: _virtKeysHeight / _virtKeysList.length,
child: Center(
child: child,
),
child: Center(child: child),
),
);
}
@@ -474,6 +482,19 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
iosConfiguration: IosConfiguration(),
);
}
void _initStoredCfg() {
final fontFamilly = getFileName(Stores.setting.fontPath.fetch());
final textSize = Stores.setting.termFontSize.fetch();
_originTextSize = textSize;
final textStyle = TextStyle(
fontFamily: fontFamilly,
fontSize: textSize,
);
_terminalStyle = TerminalStyle.fromTextStyle(textStyle);
_keyboardType = TextInputType.values[Stores.setting.keyboardType.fetch()];
}
}
Future<void> _onStart(ServiceInstance service) async {}