From ba4abcecfbb6c8076a26a20ae591996961e587bf Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Tue, 14 May 2024 23:39:17 +0800 Subject: [PATCH] opt. --- ios/Runner.xcodeproj/project.pbxproj | 36 ++++++------ lib/app.dart | 7 +-- lib/core/route.dart | 12 +++- lib/core/utils/misc.dart | 8 --- lib/core/utils/ui.dart | 48 ---------------- lib/data/model/server/battery.dart | 1 - lib/data/model/server/pve.dart | 30 +++++----- lib/data/provider/debug.dart | 56 ------------------- lib/data/res/build_data.dart | 6 +- lib/data/res/provider.dart | 4 +- lib/data/res/url.dart | 1 + lib/data/store/container.dart | 1 - lib/main.dart | 45 +++++---------- lib/view/page/debug.dart | 55 ------------------ lib/view/page/editor.dart | 3 +- lib/view/page/home/home.dart | 7 +-- lib/view/page/server/edit.dart | 3 +- lib/view/page/setting/entry.dart | 5 +- lib/view/page/setting/seq/srv_detail_seq.dart | 1 - lib/view/page/ssh/page.dart | 3 +- lib/view/page/storage/local.dart | 3 +- lib/view/widget/popup_menu.dart | 5 +- macos/Runner.xcodeproj/project.pbxproj | 12 ++-- pubspec.lock | 8 +-- pubspec.yaml | 5 +- 25 files changed, 86 insertions(+), 279 deletions(-) delete mode 100644 lib/core/utils/ui.dart delete mode 100644 lib/data/provider/debug.dart delete mode 100644 lib/view/page/debug.dart diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2b0e38f7..47a4366e 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -690,7 +690,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -700,7 +700,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -826,7 +826,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -836,7 +836,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -854,7 +854,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -864,7 +864,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -898,7 +898,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -937,7 +937,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -973,7 +973,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1008,7 +1008,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1049,7 +1049,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1087,7 +1087,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/app.dart b/lib/app.dart index 20cfd108..cca3c08c 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -2,7 +2,6 @@ import 'package:dynamic_color/dynamic_color.dart'; import 'package:fl_lib/fl_lib.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:toolbox/core/utils/ui.dart'; import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/rebuild.dart'; import 'package:toolbox/data/res/store.dart'; @@ -84,11 +83,7 @@ class MyApp extends StatelessWidget { } void _setup(BuildContext context) async { - setTransparentNavigationBar(context); - Analysis.init( - 'https://countly.lolli.tech', - '0772e65c696709f879d87db77ae1a811259e3eb9', - ); + SystemUIs.setTransparentNavigationBar(context); } ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith( diff --git a/lib/core/route.dart b/lib/core/route.dart index 358d46ab..57c8257b 100644 --- a/lib/core/route.dart +++ b/lib/core/route.dart @@ -1,7 +1,9 @@ +import 'package:fl_lib/fl_lib.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:toolbox/data/model/server/private_key_info.dart'; import 'package:toolbox/data/model/server/server_private_info.dart'; +import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; import 'package:toolbox/view/page/backup.dart'; import 'package:toolbox/view/page/container.dart'; @@ -21,7 +23,6 @@ import 'package:toolbox/view/page/setting/seq/virt_key.dart'; import 'package:toolbox/view/page/storage/local.dart'; import '../data/model/server/snippet.dart'; -import '../view/page/debug.dart'; import '../view/page/editor.dart'; import '../view/page/process.dart'; import '../view/page/server/edit.dart'; @@ -150,7 +151,14 @@ class AppRoutes { } static AppRoutes debug({Key? key}) { - return AppRoutes(DebugPage(key: key), 'debug'); + return AppRoutes( + DebugPage( + key: key, + notifier: Pros.debug.widgets, + onClear: Pros.debug.clear, + ), + 'debug', + ); } static AppRoutes docker({Key? key, required ServerPrivateInfo spi}) { diff --git a/lib/core/utils/misc.dart b/lib/core/utils/misc.dart index 1ed6b98e..ebd3104c 100644 --- a/lib/core/utils/misc.dart +++ b/lib/core/utils/misc.dart @@ -1,7 +1,6 @@ import 'package:fl_lib/fl_lib.dart'; import 'package:plain_notification_token/plain_notification_token.dart'; - Future getToken() async { if (isIOS) { final plainNotificationToken = PlainNotificationToken(); @@ -14,10 +13,3 @@ Future getToken() async { } return null; } - -String? getFileName(String? path) { - if (path == null || path.isEmpty) { - return null; - } - return path.split('/').last; -} diff --git a/lib/core/utils/ui.dart b/lib/core/utils/ui.dart deleted file mode 100644 index 356ba50d..00000000 --- a/lib/core/utils/ui.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:fl_lib/fl_lib.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:toolbox/core/utils/misc.dart'; -import 'package:url_launcher/url_launcher.dart'; - -Future openUrl(String url) async { - return await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication); -} - -void setTransparentNavigationBar(BuildContext context) { - if (isAndroid) { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); - SystemChrome.setSystemUIOverlayStyle( - const SystemUiOverlayStyle( - systemNavigationBarColor: Colors.transparent, - systemNavigationBarContrastEnforced: true), - ); - } -} - -Future loadFontFile(String localPath) async { - if (localPath.isEmpty) return; - final name = getFileName(localPath); - if (name == null) return; - final file = File(localPath); - if (!await file.exists()) return; - final fontLoader = FontLoader(name); - fontLoader.addFont(file.readAsBytes().byteData); - await fontLoader.load(); -} - -void switchStatusBar({required bool hide}) { - if (hide) { - SystemChrome.setEnabledSystemUIMode( - SystemUiMode.immersiveSticky, - overlays: [], - ); - } else { - SystemChrome.setEnabledSystemUIMode( - SystemUiMode.edgeToEdge, - overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom], - ); - } -} diff --git a/lib/data/model/server/battery.dart b/lib/data/model/server/battery.dart index b2928399..6dbcf01d 100644 --- a/lib/data/model/server/battery.dart +++ b/lib/data/model/server/battery.dart @@ -1,4 +1,3 @@ - import 'package:fl_lib/fl_lib.dart'; /// raw dat from server: diff --git a/lib/data/model/server/pve.dart b/lib/data/model/server/pve.dart index a37a89c4..cb5bb617 100644 --- a/lib/data/model/server/pve.dart +++ b/lib/data/model/server/pve.dart @@ -131,11 +131,11 @@ final class PveLxc extends PveResIface implements PveCtrlIface { String get summary { if (available) { return uptime.secondsToDuration().toAgoStr( - day: l10n.day, - hour: l10n.hour, - minute: l10n.minute, - second: l10n.second, - ); + day: l10n.day, + hour: l10n.hour, + minute: l10n.minute, + second: l10n.second, + ); } return l10n.stopped; } @@ -214,11 +214,11 @@ final class PveQemu extends PveResIface implements PveCtrlIface { String get summary { if (available) { return uptime.secondsToDuration().toAgoStr( - day: l10n.day, - hour: l10n.hour, - minute: l10n.minute, - second: l10n.second, - ); + day: l10n.day, + hour: l10n.hour, + minute: l10n.minute, + second: l10n.second, + ); } return l10n.stopped; } @@ -269,11 +269,11 @@ final class PveNode extends PveResIface { String get topRight { if (isRunning) { return uptime.secondsToDuration().toAgoStr( - day: l10n.day, - hour: l10n.hour, - minute: l10n.minute, - second: l10n.second, - ); + day: l10n.day, + hour: l10n.hour, + minute: l10n.minute, + second: l10n.second, + ); } return l10n.stopped; } diff --git a/lib/data/provider/debug.dart b/lib/data/provider/debug.dart deleted file mode 100644 index a073fa91..00000000 --- a/lib/data/provider/debug.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:fl_lib/fl_lib.dart'; -import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; - -import '../../data/res/misc.dart'; - -const _level2Color = { - 'INFO': Colors.blue, - 'WARNING': Colors.yellow, -}; - -class DebugProvider extends ChangeNotifier { - final widgets = []; - - void addLog(LogRecord record) { - final color = _level2Color[record.level.name] ?? Colors.blue; - widgets.add(Text.rich(TextSpan( - children: [ - TextSpan( - text: '[${DateTime.now().hourMinute}][${record.loggerName}]', - style: const TextStyle(color: Colors.cyan), - ), - TextSpan( - text: '[${record.level}]', - style: TextStyle(color: color), - ), - TextSpan( - text: record.error == null - ? '\n${record.message}' - : '\n${record.message}: ${record.error}', - style: const TextStyle(color: Colors.white), - ), - ], - ))); - if (record.stackTrace != null) { - widgets.add(SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Text( - '${record.stackTrace}', - style: const TextStyle(color: Colors.white), - ), - )); - } - widgets.add(UIs.height13); - - if (widgets.length > Miscs.maxDebugLogLines) { - widgets.removeRange(0, widgets.length - Miscs.maxDebugLogLines); - } - notifyListeners(); - } - - void clear() { - widgets.clear(); - notifyListeners(); - } -} diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 4a118d94..01855b91 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 896; + static const int build = 897; static const String engine = "3.19.6"; - static const String buildAt = "2024-05-12 15:46:37"; - static const int modifications = 3; + static const String buildAt = "2024-05-14 22:32:07"; + static const int modifications = 12; static const int script = 47; } diff --git a/lib/data/res/provider.dart b/lib/data/res/provider.dart index 2fd135f9..665d2e8a 100644 --- a/lib/data/res/provider.dart +++ b/lib/data/res/provider.dart @@ -1,5 +1,5 @@ +import 'package:fl_lib/fl_lib.dart'; import 'package:toolbox/data/provider/app.dart'; -import 'package:toolbox/data/provider/debug.dart'; import 'package:toolbox/data/provider/private_key.dart'; import 'package:toolbox/data/provider/server.dart'; import 'package:toolbox/data/provider/sftp.dart'; @@ -7,7 +7,7 @@ import 'package:toolbox/data/provider/snippet.dart'; abstract final class Pros { static final app = AppProvider(); - static final debug = DebugProvider(); + static final debug = DebugProvider(maxLines: 177); static final key = PrivateKeyProvider(); static final server = ServerProvider(); static final sftp = SftpProvider(); diff --git a/lib/data/res/url.dart b/lib/data/res/url.dart index 5dc7b898..1fedd48e 100644 --- a/lib/data/res/url.dart +++ b/lib/data/res/url.dart @@ -4,4 +4,5 @@ abstract final class Urls { static const myGithub = 'https://github.com/lollipopkit'; static const appHelp = '$myGithub/flutter_server_box#-help'; static const appWiki = '$myGithub/flutter_server_box/wiki'; + static const analysis = 'https://countly.lolli.tech'; } diff --git a/lib/data/store/container.dart b/lib/data/store/container.dart index 5c29998f..8090751a 100644 --- a/lib/data/store/container.dart +++ b/lib/data/store/container.dart @@ -2,7 +2,6 @@ import 'package:fl_lib/fl_lib.dart'; import 'package:toolbox/data/model/container/type.dart'; import 'package:toolbox/data/res/store.dart'; - const _keyConfig = 'providerConfig'; class ContainerStore extends PersistentStore { diff --git a/lib/main.dart b/lib/main.dart index 2b4f62c3..2f2470c9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,23 +10,21 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:logging/logging.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:toolbox/app.dart'; import 'package:toolbox/core/utils/sync/icloud.dart'; import 'package:toolbox/core/utils/sync/webdav.dart'; -import 'package:toolbox/core/utils/ui.dart'; import 'package:toolbox/data/model/app/menu/server_func.dart'; +import 'package:toolbox/data/model/app/net_view.dart'; import 'package:toolbox/data/model/app/version_related.dart'; import 'package:toolbox/data/model/server/custom.dart'; +import 'package:toolbox/data/model/server/private_key_info.dart'; +import 'package:toolbox/data/model/server/server_private_info.dart'; +import 'package:toolbox/data/model/server/snippet.dart'; +import 'package:toolbox/data/model/ssh/virtual_key.dart'; import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; -import 'package:window_manager/window_manager.dart'; - -import 'app.dart'; -import 'data/model/app/net_view.dart'; -import 'data/model/server/private_key_info.dart'; -import 'data/model/server/server_private_info.dart'; -import 'data/model/server/snippet.dart'; -import 'data/model/ssh/virtual_key.dart'; +import 'package:toolbox/data/res/url.dart'; Future main() async { _runInZone(() async { @@ -71,11 +69,11 @@ Future _initApp() async { // Base of all data. await _initDb(); - _initDesktopWindow(); - _setupLogger(); + _setupDebug(); + SystemUIs.initDesktopWindow(Stores.setting.hideTitleBar.fetch()); // Load font - loadFontFile(Stores.setting.fontPath.fetch()); + FontUtils.loadFrom(Stores.setting.fontPath.fetch()); if (isAndroid) { // SharedPreferences is only used on Android for saving home widgets settings. @@ -119,7 +117,7 @@ Future _initDb() async { Pros.key.load(); } -void _setupLogger() { +void _setupDebug() { Logger.root.level = Level.ALL; Logger.root.onRecord.listen((record) { Pros.debug.addLog(record); @@ -127,25 +125,10 @@ void _setupLogger() { if (record.error != null) print(record.error); if (record.stackTrace != null) print(record.stackTrace); }); -} -void _initDesktopWindow() async { - if (!isDesktop) return; - - await windowManager.ensureInitialized(); - await CustomAppBar.updateTitlebarHeight(Stores.setting.hideTitleBar.fetch()); - - final windowOptions = WindowOptions( - center: true, - backgroundColor: Colors.transparent, - skipTaskbar: false, - titleBarStyle: CustomAppBar.drawTitlebar ? TitleBarStyle.hidden : null, - minimumSize: const Size(300, 300), - ); - windowManager.waitUntilReadyToShow(windowOptions, () async { - await windowManager.show(); - await windowManager.focus(); - }); + if (Stores.setting.collectUsage.fetch()) { + Analysis.init(Urls.analysis, '0772e65c696709f879d87db77ae1a811259e3eb9'); + } } Future _doVersionRelated() async { diff --git a/lib/view/page/debug.dart b/lib/view/page/debug.dart deleted file mode 100644 index c6fb86fa..00000000 --- a/lib/view/page/debug.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:fl_lib/fl_lib.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:toolbox/data/provider/debug.dart'; -import 'package:toolbox/data/res/provider.dart'; - - -class DebugPage extends StatelessWidget { - const DebugPage({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: CustomAppBar( - leading: IconButton( - onPressed: () => context.pop(), - icon: const Icon(Icons.arrow_back, color: Colors.white), - ), - title: const Text('Logs', style: TextStyle(color: Colors.white)), - backgroundColor: Colors.black, - actions: [ - IconButton( - onPressed: () => Pros.debug.clear(), - icon: const Icon(Icons.delete, color: Colors.white), - ), - ], - ), - body: _buildTerminal(context), - backgroundColor: Colors.black, - ); - } - - Widget _buildTerminal(BuildContext context) { - return Container( - padding: const EdgeInsets.all(10), - color: Colors.black, - child: DefaultTextStyle( - style: const TextStyle( - color: Colors.white, - ), - child: ChangeNotifierProvider.value( - value: Pros.debug, - child: Consumer( - builder: (_, provider, __) { - return ListView( - key: ValueKey(provider.widgets.length), - children: provider.widgets, - ); - }, - ), - ), - ), - ); - } -} diff --git a/lib/view/page/editor.dart b/lib/view/page/editor.dart index 1aba15df..5226006e 100644 --- a/lib/view/page/editor.dart +++ b/lib/view/page/editor.dart @@ -9,7 +9,6 @@ import 'package:flutter_highlight/theme_map.dart'; import 'package:flutter_highlight/themes/a11y-light.dart'; import 'package:flutter_highlight/themes/monokai.dart'; import 'package:toolbox/core/extension/context/locale.dart'; -import 'package:toolbox/core/utils/misc.dart'; import 'package:toolbox/data/res/highlight.dart'; import 'package:toolbox/data/res/store.dart'; @@ -118,7 +117,7 @@ class _EditorPageState extends State { return CustomAppBar( centerTitle: true, title: TwoLineText( - up: widget.title ?? getFileName(widget.path) ?? l10n.unknown, + up: widget.title ?? widget.path?.getFileName() ?? l10n.unknown, down: l10n.editor, ), actions: [ diff --git a/lib/view/page/home/home.dart b/lib/view/page/home/home.dart index 0353b7c6..c995da36 100644 --- a/lib/view/page/home/home.dart +++ b/lib/view/page/home/home.dart @@ -10,7 +10,6 @@ import 'package:toolbox/core/channel/home_widget.dart'; import 'package:toolbox/core/extension/build.dart'; import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/route.dart'; -import 'package:toolbox/core/utils/ui.dart'; import 'package:toolbox/data/model/app/github_id.dart'; import 'package:toolbox/data/model/app/tab.dart'; import 'package:toolbox/data/res/build_data.dart'; @@ -48,7 +47,7 @@ class _HomePageState extends State @override void initState() { super.initState(); - switchStatusBar(hide: false); + SystemUIs.switchStatusBar(hide: false); WidgetsBinding.instance.addObserver(this); _selectIndex.value = Stores.setting.launchPage.fetch(); // avoid index out of range @@ -286,11 +285,11 @@ class _HomePageState extends State child: _buildAboutContent(), actions: [ TextButton( - onPressed: () => openUrl(Urls.appWiki), + onPressed: () => Urls.appWiki.launch(), child: const Text('Wiki'), ), TextButton( - onPressed: () => openUrl(Urls.appHelp), + onPressed: () => Urls.appHelp.launch(), child: Text(l10n.feedback), ), TextButton( diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 1a6f3341..aebc8a88 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:icons_plus/icons_plus.dart'; import 'package:provider/provider.dart'; import 'package:toolbox/core/extension/context/locale.dart'; -import 'package:toolbox/core/utils/ui.dart'; import 'package:toolbox/data/model/app/shell_func.dart'; import 'package:toolbox/data/model/server/custom.dart'; import 'package:toolbox/data/model/server/wol_cfg.dart'; @@ -456,7 +455,7 @@ class _ServerEditPageState extends State { ), title: Text(l10n.doc), trailing: const Icon(Icons.open_in_new, size: 17), - onTap: () => openUrl(l10n.customCmdDocUrl), + onTap: () => l10n.customCmdDocUrl.launch(), ).cardx, ]; } diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 5ad3c7c5..802b19cd 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -13,7 +13,6 @@ import 'package:toolbox/data/res/store.dart'; import 'package:toolbox/data/res/url.dart'; import '../../../core/route.dart'; -import '../../../core/utils/misc.dart'; import '../../../data/model/app/net_view.dart'; import '../../../data/provider/app.dart'; import '../../../data/res/build_data.dart'; @@ -424,7 +423,7 @@ class _SettingPageState extends State { } Widget _buildFont() { - final fontName = getFileName(_setting.fontPath.fetch()); + final fontName = _setting.fontPath.fetch().getFileName(); return ListTile( leading: const Icon(MingCute.font_fill), title: Text(l10n.font), @@ -457,7 +456,7 @@ class _SettingPageState extends State { Future _pickFontFile() async { final path = await Pfs.pickFilePath(); if (path == null) return; - + // iOS can't copy file to app dir, so we need to use the original path if (isIOS) { _setting.fontPath.put(path); diff --git a/lib/view/page/setting/seq/srv_detail_seq.dart b/lib/view/page/setting/seq/srv_detail_seq.dart index 5ffee580..be786738 100644 --- a/lib/view/page/setting/seq/srv_detail_seq.dart +++ b/lib/view/page/setting/seq/srv_detail_seq.dart @@ -4,7 +4,6 @@ import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/data/model/app/server_detail_card.dart'; import 'package:toolbox/data/res/store.dart'; - class ServerDetailOrderPage extends StatefulWidget { const ServerDetailOrderPage({super.key}); diff --git a/lib/view/page/ssh/page.dart b/lib/view/page/ssh/page.dart index fb9bcb01..21d9afbd 100644 --- a/lib/view/page/ssh/page.dart +++ b/lib/view/page/ssh/page.dart @@ -19,7 +19,6 @@ import 'package:xterm/core.dart'; import 'package:xterm/ui.dart' hide TerminalThemes; import '../../../core/route.dart'; -import '../../../core/utils/misc.dart'; import '../../../data/model/server/server_private_info.dart'; import '../../../data/model/ssh/virtual_key.dart'; import '../../../data/res/terminal.dart'; @@ -509,7 +508,7 @@ class _SSHPageState extends State with AutomaticKeepAliveClientMixin { } void _initStoredCfg() { - final fontFamilly = getFileName(Stores.setting.fontPath.fetch()); + final fontFamilly = Stores.setting.fontPath.fetch().getFileName(); final textSize = Stores.setting.termFontSize.fetch(); final textStyle = TextStyle( fontFamily: fontFamilly, diff --git a/lib/view/page/storage/local.dart b/lib/view/page/storage/local.dart index baa5ea35..a22ead7c 100644 --- a/lib/view/page/storage/local.dart +++ b/lib/view/page/storage/local.dart @@ -10,7 +10,6 @@ import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/view/widget/omit_start_text.dart'; import '../../../core/route.dart'; -import '../../../core/utils/misc.dart'; import '../../../data/model/app/path_with_prefix.dart'; class LocalStoragePage extends StatefulWidget { @@ -134,7 +133,7 @@ class _LocalStoragePageState extends State { onPressed: () async { final path = await Pfs.pickFilePath(); if (path == null) return; - final name = getFileName(path) ?? 'imported'; + final name = path.getFileName() ?? 'imported'; await File(path).copy(_path!.path.joinPath(name)); setState(() {}); }, diff --git a/lib/view/widget/popup_menu.dart b/lib/view/widget/popup_menu.dart index e64df50e..c6b903ea 100644 --- a/lib/view/widget/popup_menu.dart +++ b/lib/view/widget/popup_menu.dart @@ -22,9 +22,8 @@ class PopupMenu extends StatelessWidget { @override Widget build(BuildContext context) { return PopupMenuButton( - itemBuilder: (_) => items - .map((e) => PopupMenuItem(value: e, child: builder(e))) - .toList(), + itemBuilder: (_) => + items.map((e) => PopupMenuItem(value: e, child: builder(e))).toList(), onSelected: onSelected, initialValue: initialValue, padding: padding, diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 989df5d1..4eb16977 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -471,7 +471,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; @@ -481,7 +481,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -608,7 +608,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; @@ -618,7 +618,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -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 = 896; + CURRENT_PROJECT_VERSION = 897; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; @@ -649,7 +649,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.896; + MARKETING_VERSION = 1.0.897; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/pubspec.lock b/pubspec.lock index ed08780b..c5c5f365 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -34,7 +34,7 @@ packages: source: hosted version: "2.0.2" archive: - dependency: "direct main" + dependency: transitive description: name: archive sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265 @@ -154,7 +154,7 @@ packages: source: hosted version: "2.0.3" choice: - dependency: "direct main" + dependency: transitive description: name: choice sha256: "52d07065e8056beba5b26cff7786134cbfa24927b1f5bf60a05d50058597b2d9" @@ -349,7 +349,7 @@ packages: source: hosted version: "7.0.0" file_picker: - dependency: "direct main" + dependency: transitive description: name: file_picker sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a" @@ -377,7 +377,7 @@ packages: description: path: "." ref: main - resolved-ref: ff02a5d2b808a77f2f54528aece6b958cdc209a5 + resolved-ref: d6f282b4883615cc5a31b5f3a720b6a74d5285f4 url: "https://github.com/lollipopkit/fl_lib" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 7179a8bc..f9bf7430 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,6 @@ environment: sdk: ">=3.0.0" dependencies: - archive: ^3.3.8 flutter: sdk: flutter flutter_localizations: @@ -35,7 +34,6 @@ dependencies: git: ref: a343bc2fdc11fbc7dbfc1f170692426a6fe01cb9 url: https://github.com/lollipopkit/xterm.dart - file_picker: ^8.0.1 plain_notification_token: ^0.0.4 highlight: ^0.7.0 flutter_highlight: ^0.7.0 @@ -47,7 +45,6 @@ dependencies: git: ref: master url: https://github.com/lollipopkit/watch_connectivity - choice: ^2.0.0 #flutter_secure_storage: ^9.0.0 xml: ^6.4.2 # for parsing nvidia-smi flutter_displaymode: ^0.6.0 @@ -66,7 +63,7 @@ dependencies: git: url: https://github.com/lollipopkit/fl_lib ref: main - #path: ../fl_lib + # path: ../fl_lib dev_dependencies: flutter_native_splash: ^2.1.6