From f0b31a9b08d0131b5003962f32b731bb2acd46c5 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Fri, 23 Jun 2023 16:59:27 +0800 Subject: [PATCH] #65 new: custom `keyboard type` --- .dart_tool/flutter_gen/gen_l10n/l10n.dart | 12 +++ .dart_tool/flutter_gen/gen_l10n/l10n_de.dart | 6 ++ .dart_tool/flutter_gen/gen_l10n/l10n_en.dart | 6 ++ .dart_tool/flutter_gen/gen_l10n/l10n_zh.dart | 12 +++ ios/Runner.xcodeproj/project.pbxproj | 12 +-- lib/data/res/build_data.dart | 6 +- lib/data/store/setting.dart | 4 + lib/l10n/app_en.arb | 2 + lib/l10n/app_zh.arb | 2 + lib/l10n/app_zh_tw.arb | 2 + lib/view/page/home.dart | 4 +- lib/view/page/process.dart | 1 + lib/view/page/setting.dart | 91 ++++++++++++++++---- lib/view/page/ssh.dart | 6 +- macos/Runner.xcodeproj/project.pbxproj | 12 +-- 15 files changed, 139 insertions(+), 39 deletions(-) diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n.dart b/.dart_tool/flutter_gen/gen_l10n/l10n.dart index 75948054..5f6fe09d 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n.dart @@ -606,6 +606,18 @@ abstract class S { /// **'Key Auth'** String get keyAuth; + /// No description provided for @keyboardCompatibility. + /// + /// In en, this message translates to: + /// **'Possible to improve input method compatibility'** + String get keyboardCompatibility; + + /// No description provided for @keyboardType. + /// + /// In en, this message translates to: + /// **'Keyborad type'** + String get keyboardType; + /// No description provided for @language. /// /// In en, this message translates to: diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart index 6e9e5908..6249d5f3 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart @@ -279,6 +279,12 @@ class SDe extends S { @override String get keyAuth => 'Schlüsselauthentifzierung'; + @override + String get keyboardCompatibility => 'Possible to improve input method compatibility'; + + @override + String get keyboardType => 'Keyborad type'; + @override String get language => 'Sprache'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart index bb101517..8b3da348 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart @@ -279,6 +279,12 @@ class SEn extends S { @override String get keyAuth => 'Key Auth'; + @override + String get keyboardCompatibility => 'Possible to improve input method compatibility'; + + @override + String get keyboardType => 'Keyborad type'; + @override String get language => 'Language'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart index 6212233a..e1e9714d 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart @@ -279,6 +279,12 @@ class SZh extends S { @override String get keyAuth => '密钥认证'; + @override + String get keyboardCompatibility => '可能会改善输入法兼容性'; + + @override + String get keyboardType => '键盘类型'; + @override String get language => '语言'; @@ -901,6 +907,12 @@ class SZhTw extends SZh { @override String get keyAuth => '密鑰認證'; + @override + String get keyboardCompatibility => '可能會改善輸入法兼容性'; + + @override + String get keyboardType => '鍵盤類型'; + @override String get language => '語言'; diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2e84b352..5257e26a 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -368,7 +368,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -491,7 +491,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -499,7 +499,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -516,7 +516,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -524,7 +524,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 0740981a..717eefcd 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 361; + static const int build = 362; static const String engine = "3.10.0"; - static const String buildAt = "2023-06-21 18:31:01.595350"; - static const int modifications = 2; + static const String buildAt = "2023-06-23 16:49:18.940704"; + static const int modifications = 14; } diff --git a/lib/data/store/setting.dart b/lib/data/store/setting.dart index ab1b759b..4169a03f 100644 --- a/lib/data/store/setting.dart +++ b/lib/data/store/setting.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:toolbox/core/persistant_store.dart'; import 'package:toolbox/core/utils/platform.dart'; @@ -72,4 +73,7 @@ class SettingStore extends PersistentStore { StoreProperty get fullScreenJitter => property('fullScreenJitter', defaultValue: true); + + StoreProperty get keyboardType => + property('keyboardType', defaultValue: TextInputType.text.index); } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 164c4332..cc3385fd 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -85,6 +85,8 @@ "isBusy": "Is busy now", "keepForeground": "Keep app foreground!", "keyAuth": "Key Auth", + "keyboardCompatibility": "Possible to improve input method compatibility", + "keyboardType": "Keyborad type", "language": "Language", "languageName": "English", "lastTry": "Last try", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 06ea3ddd..13fc64f2 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -85,6 +85,8 @@ "isBusy": "当前正忙", "keepForeground": "请保持应用处于前台!", "keyAuth": "密钥认证", + "keyboardCompatibility": "可能会改善输入法兼容性", + "keyboardType": "键盘类型", "language": "语言", "languageName": "简体中文", "lastTry": "最后尝试", diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index 80c24353..8e56f3e7 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -82,6 +82,8 @@ "isBusy": "當前正忙", "keepForeground": "請保持應用處於前台!", "keyAuth": "密鑰認證", + "keyboardCompatibility": "可能會改善輸入法兼容性", + "keyboardType": "鍵盤類型", "language": "語言", "languageName": "繁體中文", "lastTry": "最後嘗試", diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 7c6c19aa..3ea01f88 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -292,12 +292,12 @@ class _HomePageState extends State @override Future afterFirstLayout(BuildContext context) async { + doUpdate(context); await GetIt.I.allReady(); await _serverProvider.loadLocalData(); await _serverProvider.refreshData(); - await doUpdate(context); if (!Analysis.enabled) { - await Analysis.init(); + Analysis.init(); } } } diff --git a/lib/view/page/process.dart b/lib/view/page/process.dart index 58282774..4bb51d8e 100644 --- a/lib/view/page/process.dart +++ b/lib/view/page/process.dart @@ -100,6 +100,7 @@ class _ProcessPageState extends State { } else { child = ListView.builder( itemCount: _result.procs.length, + padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 7), itemBuilder: (ctx, idx) { final proc = _result.procs[idx]; return _buildListItem(proc); diff --git a/lib/view/page/setting.dart b/lib/view/page/setting.dart index 3b9641e9..9ce8ec26 100644 --- a/lib/view/page/setting.dart +++ b/lib/view/page/setting.dart @@ -35,13 +35,13 @@ class SettingPage extends StatefulWidget { } class _SettingPageState extends State { - final themeKey = GlobalKey>(); - final startPageKey = GlobalKey>(); - final updateIntervalKey = GlobalKey>(); - final maxRetryKey = GlobalKey>(); - final fontSizeKey = GlobalKey>(); - final localeKey = GlobalKey>(); - final editorThemeKey = GlobalKey>(); + final _themeKey = GlobalKey>(); + final _startPageKey = GlobalKey>(); + final _updateIntervalKey = GlobalKey>(); + final _maxRetryKey = GlobalKey>(); + final _localeKey = GlobalKey>(); + final _editorThemeKey = GlobalKey>(); + final _keyboardTypeKey = GlobalKey>(); late final SettingStore _setting; late final ServerProvider _serverProvider; @@ -56,6 +56,7 @@ class _SettingPageState extends State { final _fontSize = ValueNotifier(0.0); final _localeCode = ValueNotifier(''); final _editorTheme = ValueNotifier(''); + final _keyboardType = ValueNotifier(0); final _pushToken = ValueNotifier(null); @@ -79,6 +80,7 @@ class _SettingPageState extends State { _selectedColorValue.value = _setting.primaryColor.fetch()!; _fontSize.value = _setting.termFontSize.fetch()!; _editorTheme.value = _setting.editorTheme.fetch()!; + _keyboardType.value = _setting.keyboardType.fetch()!; } @override @@ -157,6 +159,7 @@ class _SettingPageState extends State { _buildFont(), _buildTermFontSize(), _buildSSHVirtualKeyAutoOff(), + _buildKeyboardType(), ].map((e) => RoundRectCard(e)).toList(), ); } @@ -212,12 +215,12 @@ class _SettingPageState extends State { style: grey, ), onTap: () { - updateIntervalKey.currentState?.showButtonMenu(); + _updateIntervalKey.currentState?.showButtonMenu(); }, trailing: ValueBuilder( listenable: _updateInterval, build: () => PopupMenuButton( - key: updateIntervalKey, + key: _updateIntervalKey, itemBuilder: (_) => items, initialValue: _updateInterval.value, onSelected: (int val) { @@ -291,12 +294,12 @@ class _SettingPageState extends State { _s.launchPage, ), onTap: () { - startPageKey.currentState?.showButtonMenu(); + _startPageKey.currentState?.showButtonMenu(); }, trailing: ValueBuilder( listenable: _launchPageIdx, build: () => PopupMenuButton( - key: startPageKey, + key: _startPageKey, itemBuilder: (BuildContext context) => items, initialValue: _launchPageIdx.value, onSelected: (int idx) { @@ -335,11 +338,11 @@ class _SettingPageState extends State { ), subtitle: Text(help, style: grey), onTap: () { - maxRetryKey.currentState?.showButtonMenu(); + _maxRetryKey.currentState?.showButtonMenu(); }, trailing: ValueBuilder( build: () => PopupMenuButton( - key: maxRetryKey, + key: _maxRetryKey, itemBuilder: (BuildContext context) => items, initialValue: _maxRetryCount.value, onSelected: (int val) { @@ -374,12 +377,12 @@ class _SettingPageState extends State { _s.themeMode, ), onTap: () { - themeKey.currentState?.showButtonMenu(); + _themeKey.currentState?.showButtonMenu(); }, trailing: ValueBuilder( listenable: _nightMode, build: () => PopupMenuButton( - key: themeKey, + key: _themeKey, itemBuilder: (BuildContext context) => items, initialValue: _nightMode.value, onSelected: (int idx) { @@ -601,12 +604,12 @@ class _SettingPageState extends State { return ListTile( title: Text(_s.language), onTap: () { - localeKey.currentState?.showButtonMenu(); + _localeKey.currentState?.showButtonMenu(); }, trailing: ValueBuilder( listenable: _localeCode, build: () => PopupMenuButton( - key: localeKey, + key: _localeKey, itemBuilder: (BuildContext context) => items, initialValue: _localeCode.value, onSelected: (String idx) { @@ -644,7 +647,7 @@ class _SettingPageState extends State { trailing: ValueBuilder( listenable: _editorTheme, build: () => PopupMenuButton( - key: editorThemeKey, + key: _editorThemeKey, itemBuilder: (BuildContext context) => items, initialValue: _editorTheme.value, onSelected: (String idx) { @@ -658,7 +661,7 @@ class _SettingPageState extends State { ), ), onTap: () { - editorThemeKey.currentState?.showButtonMenu(); + _editorThemeKey.currentState?.showButtonMenu(); }, ); } @@ -681,4 +684,54 @@ class _SettingPageState extends State { trailing: buildSwitch(context, _setting.fullScreenJitter), ); } + + Widget _buildKeyboardType() { + const List names = [ + 'text', + 'multiline', + 'number', + 'phone', + 'datetime', + 'emailAddress', + 'url', + 'visiblePassword', + 'name', + 'address', + 'none', + ]; + if (names.length != TextInputType.values.length) { + throw 'names.length != TextInputType.values.length'; + } + final items = TextInputType.values.map( + (key) { + return PopupMenuItem( + value: key.index, + child: Text(names[key.index]), + ); + }, + ).toList(); + return ListTile( + title: Text(_s.keyboardType), + subtitle: Text(_s.keyboardCompatibility, style: grey), + trailing: ValueBuilder( + listenable: _keyboardType, + build: () => PopupMenuButton( + key: _keyboardTypeKey, + itemBuilder: (BuildContext context) => items, + initialValue: _keyboardType.value, + onSelected: (idx) { + _keyboardType.value = idx; + _setting.keyboardType.put(idx); + }, + child: Text( + names[_keyboardType.value], + style: textSize15, + ), + ), + ), + onTap: () { + _keyboardTypeKey.currentState?.showButtonMenu(); + }, + ); + } } diff --git a/lib/view/page/ssh.dart b/lib/view/page/ssh.dart index a959bb05..6fc35dda 100644 --- a/lib/view/page/ssh.dart +++ b/lib/view/page/ssh.dart @@ -48,6 +48,7 @@ class _SSHPageState extends State { late S _s; late TerminalStyle _terminalStyle; late TerminalTheme _terminalTheme; + late TextInputType _keyboardType; var _isDark = false; @@ -60,6 +61,7 @@ class _SSHPageState extends State { fontSize: _setting.termFontSize.fetch()!, ); _terminalStyle = TerminalStyle.fromTextStyle(textStyle); + _keyboardType = TextInputType.values[_setting.keyboardType.fetch()!]; initTerminal(); } @@ -96,8 +98,6 @@ class _SSHPageState extends State { } Widget _buildBody() { - final keyboardType = - isIOS ? TextInputType.emailAddress : TextInputType.visiblePassword; return SizedBox( height: _media.size.height - _virtualKeyboardHeight - @@ -106,7 +106,7 @@ class _SSHPageState extends State { child: TerminalView( _terminal, controller: _terminalController, - keyboardType: keyboardType, + keyboardType: _keyboardType, textStyle: _terminalStyle, theme: _terminalTheme, deleteDetection: isIOS, diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index f5aecbd3..af9f4eb7 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -475,9 +475,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -490,9 +490,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -505,9 +505,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 361; + CURRENT_PROJECT_VERSION = 362; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.361; + MARKETING_VERSION = 1.0.362; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;