Skip to content

Commit

Permalink
opt.: ssh tab
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Jun 8, 2024
1 parent 46b98df commit e5ef284
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 60 deletions.
36 changes: 18 additions & 18 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -700,7 +700,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -826,7 +826,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -836,7 +836,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -854,7 +854,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -864,7 +864,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -885,7 +885,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -898,7 +898,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
Expand All @@ -924,7 +924,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -937,7 +937,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -960,7 +960,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -973,7 +973,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -996,7 +996,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1008,7 +1008,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
Expand Down Expand Up @@ -1037,7 +1037,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1049,7 +1049,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox;
Expand All @@ -1075,7 +1075,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1087,7 +1087,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox;
Expand Down
6 changes: 3 additions & 3 deletions lib/data/res/build_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

class BuildData {
static const String name = "ServerBox";
static const int build = 943;
static const int build = 948;
static const String engine = "3.22.1";
static const String buildAt = "2024-06-08 19:28:01";
static const int modifications = 7;
static const String buildAt = "2024-06-08 21:21:36";
static const int modifications = 3;
static const int script = 48;
}
55 changes: 30 additions & 25 deletions lib/view/page/ssh/page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:after_layout/after_layout.dart';
import 'package:dartssh2/dartssh2.dart';
import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -49,7 +50,8 @@ class SSHPage extends StatefulWidget {

const _horizonPadding = 7.0;

class SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
class SSHPageState extends State<SSHPage>
with AutomaticKeepAliveClientMixin, AfterLayoutMixin {
final _keyboard = VirtKeyProvider();
late final _terminal = Terminal(inputHandler: _keyboard);
final TerminalController _terminalController = TerminalController();
Expand All @@ -73,13 +75,6 @@ class SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
super.initState();
_initStoredCfg();
_initVirtKeys();

Future.delayed(const Duration(milliseconds: 77), () async {
_showHelp();
await _initTerminal();

if (Stores.setting.sshWakeLock.fetch()) WakelockPlus.enable();
});
}

@override
Expand Down Expand Up @@ -153,7 +148,7 @@ class SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isMobile,
autofocus: true,
autofocus: false,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
showToolbar: isMobile,
viewOffset: Offset(
Expand Down Expand Up @@ -432,6 +427,8 @@ class SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
}
}

SSHPage.focusNode.requestFocus();

await session.done;
if (mounted && widget.notFromTab) {
context.pop();
Expand Down Expand Up @@ -518,22 +515,30 @@ class SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
_terminalStyle = TerminalStyle.fromTextStyle(textStyle);
}

void _showHelp() {
if (!Stores.setting.sshTermHelpShown.fetch()) {
context.showRoundDialog(
title: l10n.doc,
child: Text(l10n.sshTermHelp),
actions: [
TextButton(
onPressed: () {
Stores.setting.sshTermHelpShown.put(true);
context.pop();
},
child: Text(l10n.noPromptAgain),
),
],
);
}
Future<void> _showHelp() async {
if (Stores.setting.sshTermHelpShown.fetch()) return;

return await context.showRoundDialog(
title: l10n.doc,
child: Text(l10n.sshTermHelp),
actions: [
TextButton(
onPressed: () {
Stores.setting.sshTermHelpShown.put(true);
context.pop();
},
child: Text(l10n.noPromptAgain),
),
],
);
}

@override
FutureOr<void> afterFirstLayout(BuildContext context) async {
await _showHelp();
await _initTerminal();

if (Stores.setting.sshWakeLock.fetch()) WakelockPlus.enable();
}
}

Expand Down
21 changes: 13 additions & 8 deletions lib/view/page/ssh/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class _SSHTabPageState extends State<SSHTabPage>
},
),
body: _buildBody(),
floatingActionButton: ListenableBuilder(
floatingActionButton: ValBuilder(
listenable: _fabVN,
builder: (_, __) {
if (_fabVN.value != 0) return const SizedBox();
builder: (idx) {
if (idx != 0) return const SizedBox();
return FloatingActionButton(
heroTag: 'sshAddServer',
onPressed: () => AppRoutes.serverEdit().go(context),
Expand All @@ -60,11 +60,12 @@ class _SSHTabPageState extends State<SSHTabPage>

void _onTapTab(int idx) async {
await _toPage(idx);
_fabVN.value = idx;
FocusScope.of(context).unfocus();
SSHPage.focusNode.unfocus();
}

void _onTapClose(String name) async {
SSHPage.focusNode.unfocus();

final confirm = await showDialog<bool>(
context: context,
builder: (context) {
Expand All @@ -89,6 +90,8 @@ class _SSHTabPageState extends State<SSHTabPage>

_tabMap.remove(name);
_tabRN.build();
_pageCtrl.previousPage(
duration: Durations.medium1, curve: Curves.fastEaseInToSlowEaseOut);
}

Widget _buildAddPage() {
Expand Down Expand Up @@ -134,19 +137,22 @@ class _SSHTabPageState extends State<SSHTabPage>
final name = _tabMap.keys.elementAt(idx);
return _tabMap[name]?.page ?? UIs.placeholder;
},
onPageChanged: (value) => _fabVN.value = value,
);
},
);
}

void _onTapInitCard(ServerPrivateInfo spi) async {
final name = () {
final reg = RegExp(r'\((\d+)\)');
final reg = RegExp('${spi.name}\\((\\d+)\\)');
final idxs = _tabMap.keys
.map((e) => reg.firstMatch(e))
.map((e) => e?.group(1))
.where((e) => e != null);
if (idxs.isEmpty) return spi.name;
if (idxs.isEmpty) {
return _tabMap.keys.contains(spi.name) ? '${spi.name}(1)' : spi.name;
}
final biggest = idxs.reduce((a, b) => a!.length > b!.length ? a : b);
final biggestInt = int.tryParse(biggest ?? '0');
if (biggestInt != null && biggestInt > 0) {
Expand All @@ -172,7 +178,6 @@ class _SSHTabPageState extends State<SSHTabPage>
await Future.delayed(Durations.short3);
final idx = _tabMap.keys.toList().indexOf(name);
await _toPage(idx);
_fabVN.value = idx;
}

Future<void> _toPage(int idx) => _pageCtrl.animateToPage(idx,
Expand Down
12 changes: 6 additions & 6 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
Expand All @@ -481,7 +481,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -608,7 +608,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
Expand All @@ -618,7 +618,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -638,7 +638,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 943;
CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -649,7 +649,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.943;
MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down

0 comments on commit e5ef284

Please sign in to comment.