From 46d5840276433a928da0eb26590f03e55f74cde3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:04:01 +0800 Subject: [PATCH] feat: share server via qrcode (#530) --- ios/Runner.xcodeproj/project.pbxproj | 36 ++-- ios/Runner/Info-Debug.plist | 151 ++++++------- ios/Runner/Info-Profile.plist | 7 +- ios/Runner/Info-Release.plist | 21 +- .../model/server/server_private_info.dart | 4 + lib/data/res/build_data.dart | 2 +- lib/view/page/backup.dart | 10 +- lib/view/page/server/detail/view.dart | 5 + lib/view/page/server/edit.dart | 199 ++++++++++-------- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + macos/Runner.xcodeproj/project.pbxproj | 12 +- pubspec.lock | 36 +++- pubspec.yaml | 4 +- 13 files changed, 286 insertions(+), 203 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 7b9a80d91..ede55cd45 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -700,7 +700,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -836,7 +836,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -864,7 +864,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1008,7 +1008,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1049,7 +1049,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -1087,7 +1087,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1051; + MARKETING_VERSION = 1.0.1057; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/ios/Runner/Info-Debug.plist b/ios/Runner/Info-Debug.plist index 48c9d0d62..39a0fa5ee 100644 --- a/ios/Runner/Info-Debug.plist +++ b/ios/Runner/Info-Debug.plist @@ -1,76 +1,81 @@ - - CADisableMinimumFrameDurationOnPhone - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLocalizations - - en - zh - - CFBundleName - ServerBox - CFBundlePackageType - APPL - CFBundleShortVersionString - $(MARKETING_VERSION) - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - ITSAppUsesNonExemptEncryption - - LSRequiresIPhoneOS - - LSSupportsOpeningDocumentsInPlace - - NSBonjourServices - - _dartobservatory._tcp - - NSFaceIDUsageDescription - Required for auth - NSLocalNetworkUsageDescription - ServerBox needs to access your local network to discover and connect to your server. - NSUserActivityTypes - - ConfigurationIntent - - UIApplicationSupportsIndirectInputEvents - - UIBackgroundModes - - fetch - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIStatusBarHidden - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - - + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLocalizations + + en + zh + + CFBundleName + ServerBox + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + ITSAppUsesNonExemptEncryption + + LSRequiresIPhoneOS + + LSSupportsOpeningDocumentsInPlace + + NSBonjourServices + + _dartobservatory._tcp + + NSUserActivityTypes + + ConfigurationIntent + + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + fetch + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + NSLocalNetworkUsageDescription + Access your local network to discover and connect to your server. + NSFaceIDUsageDescription + Required for auth + NSCameraUsageDescription + Scan QR codes and etc. + NSPhotoLibraryUsageDescription + Get QR code and etc. + + \ No newline at end of file diff --git a/ios/Runner/Info-Profile.plist b/ios/Runner/Info-Profile.plist index 9d6a71c7e..ab4251da6 100644 --- a/ios/Runner/Info-Profile.plist +++ b/ios/Runner/Info-Profile.plist @@ -64,9 +64,14 @@ _dartobservatory._tcp + NSLocalNetworkUsageDescription - ServerBox needs to access your local network to discover and connect to your server. + Access your local network to discover and connect to your server. NSFaceIDUsageDescription Required for auth + NSCameraUsageDescription + Scan QR codes and etc. + NSPhotoLibraryUsageDescription + Get QR code and etc. diff --git a/ios/Runner/Info-Release.plist b/ios/Runner/Info-Release.plist index 1edaf8107..1b326c8ee 100644 --- a/ios/Runner/Info-Release.plist +++ b/ios/Runner/Info-Release.plist @@ -3,7 +3,7 @@ CADisableMinimumFrameDurationOnPhone - + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -28,13 +28,13 @@ CFBundleVersion $(CURRENT_PROJECT_VERSION) ITSAppUsesNonExemptEncryption - + LSRequiresIPhoneOS - + LSSupportsOpeningDocumentsInPlace - + UIApplicationSupportsIndirectInputEvents - + UIBackgroundModes fetch @@ -44,7 +44,7 @@ UIMainStoryboardFile Main UIStatusBarHidden - + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait @@ -59,8 +59,13 @@ UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - + + NSFaceIDUsageDescription Required for auth + NSCameraUsageDescription + Scan QR codes and etc. + NSPhotoLibraryUsageDescription + Get QR code and etc. - + \ No newline at end of file diff --git a/lib/data/model/server/server_private_info.dart b/lib/data/model/server/server_private_info.dart index 2e988cd01..ea8bc8597 100644 --- a/lib/data/model/server/server_private_info.dart +++ b/lib/data/model/server/server_private_info.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:hive_flutter/hive_flutter.dart'; import 'package:server_box/data/model/server/custom.dart'; import 'package:server_box/data/model/server/server.dart'; @@ -144,6 +146,8 @@ class ServerPrivateInfo { return data; } + String toJsonString() => json.encode(toJson()); + Server? get server => Pros.server.pick(spi: this); Server? get jumpServer => Pros.server.pick(id: jumpId); diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 999fdbbe9..2a68f170f 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,6 +2,6 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 1051; + static const int build = 1057; static const int script = 56; } diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index a6c46ec4a..7c776839f 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -306,7 +306,7 @@ class BackupPage extends StatelessWidget { ); } catch (e, s) { Loggers.app.warning('Import backup failed', e, s); - context.showErrDialog(e: e, s: s, operation: libL10n.restore); + context.showErrDialog(e, s, libL10n.restore); } } @@ -330,7 +330,7 @@ class BackupPage extends StatelessWidget { final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile); await dlBak.restore(force: true); } catch (e, s) { - context.showErrDialog(e: e, s: s, operation: libL10n.restore); + context.showErrDialog(e, s, libL10n.restore); Loggers.app.warning('Download webdav backup failed', e, s); } finally { webdavLoading.value = false; @@ -349,7 +349,7 @@ class BackupPage extends StatelessWidget { } Loggers.app.info('Upload webdav backup success'); } catch (e, s) { - context.showErrDialog(e: e, s: s, operation: l10n.upload); + context.showErrDialog(e, s, l10n.upload); Loggers.app.warning('Upload webdav backup failed', e, s); } finally { webdavLoading.value = false; @@ -435,7 +435,7 @@ class BackupPage extends StatelessWidget { ); } catch (e, s) { Loggers.app.warning('Import backup failed', e, s); - context.showErrDialog(e: e, s: s, operation: libL10n.restore); + context.showErrDialog(e, s, libL10n.restore); } } @@ -473,7 +473,7 @@ class BackupPage extends StatelessWidget { context.showSnackBar(libL10n.success); } } catch (e, s) { - context.showErrDialog(e: e, s: s, operation: libL10n.import); + context.showErrDialog(e, s, libL10n.import); Loggers.app.warning('Import servers failed', e, s); } } diff --git a/lib/view/page/server/detail/view.dart b/lib/view/page/server/detail/view.dart index 186ee2166..116067227 100644 --- a/lib/view/page/server/detail/view.dart +++ b/lib/view/page/server/detail/view.dart @@ -123,6 +123,11 @@ class _ServerDetailPageState extends State return CustomAppBar( title: Text(si.spi.name), actions: [ + ShareBtn( + data: widget.spi.toJsonString(), + tip: widget.spi.name, + tip2: '${libL10n.share} ${l10n.server} ~ ServerBox', + ), IconButton( icon: const Icon(Icons.edit), onPressed: () async { diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 7f5faba27..0cad3cd99 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:fl_lib/fl_lib.dart'; import 'package:flutter/material.dart'; import 'package:icons_plus/icons_plus.dart'; @@ -80,50 +82,29 @@ class _ServerEditPageState extends State with AfterLayoutMixin { @override Widget build(BuildContext context) { + final actions = []; + if (widget.spi != null) actions.add(_buildDelBtn()); + return GestureDetector( onTap: () => _focusScope.unfocus(), child: Scaffold( - appBar: _buildAppBar(), + appBar: CustomAppBar(title: Text(libL10n.edit), actions: actions), body: _buildForm(), floatingActionButton: _buildFAB(), ), ); } - PreferredSizeWidget _buildAppBar() { - return CustomAppBar( - title: Text(libL10n.edit), - actions: widget.spi != null ? [_buildDelBtn()] : null, - ); - } - - Widget _buildDelBtn() { - return IconButton( - onPressed: () { - context.showRoundDialog( - title: libL10n.attention, - child: StatefulBuilder(builder: (ctx, setState) { - return Text(libL10n.askContinue( - '${libL10n.delete} ${l10n.server}(${widget.spi!.name})', - )); - }), - actions: Btn.ok( - onTap: () async { - context.pop(); - Pros.server.delServer(widget.spi!.id); - context.pop(true); - }, - red: true, - ).toList, - ); - }, - icon: const Icon(Icons.delete), - ); - } - Widget _buildForm() { - final children = [ + final topItems = [ _buildWriteScriptTip(), + if (isMobile) _buildQrScan(), + ]; + final children = [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: topItems.joinWith(UIs.width13).toList(), + ), Input( autoFocus: true, controller: _nameController, @@ -600,69 +581,113 @@ class _ServerEditPageState extends State with AfterLayoutMixin { context.pop(); } - Widget _buildWriteScriptTip() { - return Center( - child: InkWell( - borderRadius: BorderRadius.circular(10), - onTap: () { - context.showRoundDialog( - title: libL10n.attention, - child: SimpleMarkdown(data: l10n.writeScriptTip), - actions: [Btn.ok()], - ); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Icons.tips_and_updates, size: 15, color: Colors.grey), - UIs.width13, - Text(libL10n.attention, style: UIs.textGrey) - ], - ).paddingSymmetric(horizontal: 13, vertical: 3), - ), - ).paddingOnly(bottom: 13); - } - @override void afterFirstLayout(BuildContext context) { final spi = widget.spi; if (spi != null) { - _nameController.text = spi.name; - _ipController.text = spi.ip; - _portController.text = spi.port.toString(); - _usernameController.text = spi.user; - if (spi.keyId == null) { - _passwordController.text = spi.pwd ?? ''; - } else { - _keyIdx.value = Pros.key.pkis.indexWhere( - (e) => e.id == widget.spi!.keyId, - ); - } + _initWithSpi(spi); + } + } - /// List in dart is passed by pointer, so you need to copy it here - _tags.value = spi.tags?.toSet() ?? {}; + void _initWithSpi(ServerPrivateInfo spi) { + _nameController.text = spi.name; + _ipController.text = spi.ip; + _portController.text = spi.port.toString(); + _usernameController.text = spi.user; + if (spi.keyId == null) { + _passwordController.text = spi.pwd ?? ''; + } else { + _keyIdx.value = Pros.key.pkis.indexWhere( + (e) => e.id == widget.spi!.keyId, + ); + } - _altUrlController.text = spi.alterUrl ?? ''; - _autoConnect.value = spi.autoConnect ?? true; - _jumpServer.value = spi.jumpId; + /// List in dart is passed by pointer, so you need to copy it here + _tags.value = spi.tags?.toSet() ?? {}; - final custom = spi.custom; - if (custom != null) { - _pveAddrCtrl.text = custom.pveAddr ?? ''; - _pveIgnoreCert.value = custom.pveIgnoreCert; - _customCmds.value = custom.cmds ?? {}; - _preferTempDevCtrl.text = custom.preferTempDev ?? ''; - _logoUrlCtrl.text = custom.logoUrl ?? ''; - } + _altUrlController.text = spi.alterUrl ?? ''; + _autoConnect.value = spi.autoConnect ?? true; + _jumpServer.value = spi.jumpId; - final wol = spi.wolCfg; - if (wol != null) { - _wolMacCtrl.text = wol.mac; - _wolIpCtrl.text = wol.ip; - _wolPwdCtrl.text = wol.pwd ?? ''; - } + final custom = spi.custom; + if (custom != null) { + _pveAddrCtrl.text = custom.pveAddr ?? ''; + _pveIgnoreCert.value = custom.pveIgnoreCert; + _customCmds.value = custom.cmds ?? {}; + _preferTempDevCtrl.text = custom.preferTempDev ?? ''; + _logoUrlCtrl.text = custom.logoUrl ?? ''; + } - _env.value = spi.envs ?? {}; + final wol = spi.wolCfg; + if (wol != null) { + _wolMacCtrl.text = wol.mac; + _wolIpCtrl.text = wol.ip; + _wolPwdCtrl.text = wol.pwd ?? ''; } + + _env.value = spi.envs ?? {}; + } + + Widget _buildWriteScriptTip() { + return Btn.tile( + text: libL10n.attention, + icon: const Icon(Icons.tips_and_updates, color: Colors.grey), + onTap: () { + context.showRoundDialog( + title: libL10n.attention, + child: SimpleMarkdown(data: l10n.writeScriptTip), + actions: Btnx.oks, + ); + }, + textStyle: UIs.textGrey, + mainAxisSize: MainAxisSize.min, + ); + } + + Widget _buildQrScan() { + return Btn.tile( + text: libL10n.import, + icon: const Icon(Icons.qr_code, color: Colors.grey), + onTap: () async { + final codes = await BarcodeScannerPage.route.go( + context, + args: const BarcodeScannerPageArgs(), + ); + final code = codes?.firstOrNull?.rawValue; + if (code == null) return; + try { + final spi = ServerPrivateInfo.fromJson(json.decode(code)); + _initWithSpi(spi); + } catch (e, s) { + context.showErrDialog(e, s); + } + }, + textStyle: UIs.textGrey, + mainAxisSize: MainAxisSize.min, + ); + } + + Widget _buildDelBtn() { + return IconButton( + onPressed: () { + context.showRoundDialog( + title: libL10n.attention, + child: StatefulBuilder(builder: (ctx, setState) { + return Text(libL10n.askContinue( + '${libL10n.delete} ${l10n.server}(${widget.spi!.name})', + )); + }), + actions: Btn.ok( + onTap: () async { + context.pop(); + Pros.server.delServer(widget.spi!.id); + context.pop(true); + }, + red: true, + ).toList, + ); + }, + icon: const Icon(Icons.delete), + ); } } diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 48dd2b3e0..524858aca 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -9,6 +9,7 @@ import device_info_plus import dynamic_color import icloud_storage import local_auth_darwin +import mobile_scanner import package_info_plus import path_provider_foundation import screen_retriever @@ -23,6 +24,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) IcloudStoragePlugin.register(with: registry.registrar(forPlugin: "IcloudStoragePlugin")) FLALocalAuthPlugin.register(with: registry.registrar(forPlugin: "FLALocalAuthPlugin")) + MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index a6dd616d8..8c2cde222 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; 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 = 1051; + CURRENT_PROJECT_VERSION = 1057; 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.1051; + MARKETING_VERSION = 1.0.1057; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/pubspec.lock b/pubspec.lock index f5e4f5f5b..f96a17d27 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -406,8 +406,8 @@ packages: dependency: "direct main" description: path: "." - ref: "v1.0.129" - resolved-ref: e971000e0cffa49637564e35f477ed782ca3dd10 + ref: "v1.0.132" + resolved-ref: f68453c64cfa3b363bcd6b5e7d76cad7fa7724c6 url: "https://github.com/lppcg/fl_lib" source: git version: "0.0.1" @@ -839,6 +839,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + mobile_scanner: + dependency: transitive + description: + name: mobile_scanner + sha256: b8c0e9afcfd52534f85ec666f3d52156f560b5e6c25b1e3d4fe2087763607926 + url: "https://pub.dev" + source: hosted + version: "5.1.1" nested: dependency: transitive description: @@ -1040,6 +1048,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + pretty_qr_code: + dependency: transitive + description: + name: pretty_qr_code + sha256: cbdb4af29da1c1fa21dd76f809646c591320ab9e435d3b0eab867492d43607d5 + url: "https://pub.dev" + source: hosted + version: "3.3.0" provider: dependency: "direct main" description: @@ -1064,6 +1080,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + qr: + dependency: transitive + description: + name: qr + sha256: "5a1d2586170e172b8a8c8470bbbffd5eb0cd38a66c0d77155ea138d3af3a4445" + url: "https://pub.dev" + source: hosted + version: "3.0.2" quiver: dependency: transitive description: @@ -1080,6 +1104,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.9" + screenshot: + dependency: transitive + description: + name: screenshot + sha256: "63817697a7835e6ce82add4228e15d233b74d42975c143ad8cfe07009fab866b" + url: "https://pub.dev" + source: hosted + version: "3.0.0" share_plus: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 692ac49fc..5be45b5e0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: server_box description: server status & toolbox app. publish_to: 'none' -version: 1.0.1051+1051 +version: 1.0.1057+1057 environment: sdk: ">=3.0.0" @@ -61,7 +61,7 @@ dependencies: fl_lib: git: url: https://github.com/lppcg/fl_lib - ref: v1.0.129 + ref: v1.0.132 dependency_overrides: # dartssh2: