From f47aacaf6fc9f1757332305d90c4e3ef85ee6492 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sun, 17 Sep 2023 15:21:12 +0800 Subject: [PATCH] opt.: `OS` type --- ios/Runner.xcodeproj/project.pbxproj | 36 ++++----- lib/core/update.dart | 2 +- lib/core/utils/platform/base.dart | 105 +++++++++++++------------ lib/data/model/app/update.dart | 8 +- lib/data/res/build_data.dart | 6 +- lib/view/page/server/detail.dart | 2 +- lib/view/page/setting/entry.dart | 15 ++-- macos/Runner.xcodeproj/project.pbxproj | 12 +-- 8 files changed, 95 insertions(+), 91 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 57638642..af41470e 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -586,7 +586,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -594,7 +594,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -718,7 +718,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -726,7 +726,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -744,7 +744,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -752,7 +752,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -773,7 +773,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -786,7 +786,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -812,7 +812,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -825,7 +825,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -848,7 +848,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -861,7 +861,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -884,7 +884,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -896,7 +896,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -925,7 +925,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -937,7 +937,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -963,7 +963,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -975,7 +975,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/core/update.dart b/lib/core/update.dart index f9f189ca..393f41b6 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -35,7 +35,7 @@ Future doUpdate(BuildContext context, {bool force = false}) async { final newest = update.build.last.current; if (newest == null) { - Loggers.app.warning('Update not available on $platform'); + Loggers.app.warning('Update not available on ${OS.type}'); return; } diff --git a/lib/core/utils/platform/base.dart b/lib/core/utils/platform/base.dart index c9b69fc4..5513fc2b 100644 --- a/lib/core/utils/platform/base.dart +++ b/lib/core/utils/platform/base.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; -enum PlatformType { +enum OS { android, ios, linux, @@ -12,32 +12,60 @@ enum PlatformType { fuchsia, unknown; - String get prettyName { + static final _os = () { + if (kIsWeb) { + return OS.web; + } + if (Platform.isAndroid) { + return OS.android; + } + if (Platform.isIOS) { + return OS.ios; + } + if (Platform.isLinux) { + return OS.linux; + } + if (Platform.isMacOS) { + return OS.macos; + } + if (Platform.isWindows) { + return OS.windows; + } + if (Platform.isFuchsia) { + return OS.fuchsia; + } + return OS.unknown; + }(); + + static OS get type => _os; + + @override + String toString() { switch (this) { - case PlatformType.android: + case OS.android: return 'Android'; - case PlatformType.ios: + case OS.ios: return 'iOS'; - case PlatformType.linux: + case OS.linux: return 'Linux'; - case PlatformType.macos: + case OS.macos: return 'macOS'; - case PlatformType.windows: + case OS.windows: return 'Windows'; - case PlatformType.web: + case OS.web: return 'Web'; - case PlatformType.fuchsia: + case OS.fuchsia: return 'Fuchsia'; - case PlatformType.unknown: + case OS.unknown: return 'Unknown'; } } /// Whether has platform specific settings. - bool get hasSettings { - switch (this) { - case PlatformType.android: - case PlatformType.ios: + static bool get hasSettings { + switch (type) { + case OS.android: + case OS.ios: return true; default: return false; @@ -45,41 +73,16 @@ enum PlatformType { } } -final _p = () { - if (kIsWeb) { - return PlatformType.web; - } - if (Platform.isAndroid) { - return PlatformType.android; - } - if (Platform.isIOS) { - return PlatformType.ios; - } - if (Platform.isLinux) { - return PlatformType.linux; - } - if (Platform.isMacOS) { - return PlatformType.macos; - } - if (Platform.isWindows) { - return PlatformType.windows; - } - if (Platform.isFuchsia) { - return PlatformType.fuchsia; - } - return PlatformType.unknown; -}(); - -PlatformType get platform => _p; - -bool get isAndroid => _p == PlatformType.android; -bool get isIOS => _p == PlatformType.ios; -bool get isLinux => _p == PlatformType.linux; -bool get isMacOS => _p == PlatformType.macos; -bool get isWindows => _p == PlatformType.windows; -bool get isWeb => _p == PlatformType.web; -bool get isMobile => _p == PlatformType.ios || _p == PlatformType.android; +bool get isAndroid => OS.type == OS.android; +bool get isIOS => OS.type == OS.ios; +bool get isLinux => OS.type == OS.linux; +bool get isMacOS => OS.type == OS.macos; +bool get isWindows => OS.type == OS.windows; +bool get isWeb => OS.type == OS.web; +bool get isMobile => + OS.type == OS.ios || + OS.type == OS.android; bool get isDesktop => - _p == PlatformType.linux || - _p == PlatformType.macos || - _p == PlatformType.windows; + OS.type == OS.linux || + OS.type == OS.macos || + OS.type == OS.windows; diff --git a/lib/data/model/app/update.dart b/lib/data/model/app/update.dart index d2e12213..ffd1c256 100644 --- a/lib/data/model/app/update.dart +++ b/lib/data/model/app/update.dart @@ -112,12 +112,12 @@ class AppUpdatePlatformSpecific { }; T? get current { - switch (platform) { - case PlatformType.macos: + switch (OS.type) { + case OS.macos: return mac; - case PlatformType.ios: + case OS.ios: return ios; - case PlatformType.android: + case OS.android: return android; default: return null; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index a010f02c..652db57e 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 = 562; + static const int build = 563; static const String engine = "3.13.2"; - static const String buildAt = "2023-09-17 00:26:50"; - static const int modifications = 2; + static const String buildAt = "2023-09-17 14:30:45"; + static const int modifications = 3; static const int script = 15; } diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index c6c0a15e..3665587a 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -388,7 +388,7 @@ class _ServerDetailPageState extends State } Widget _buildNetSpeedTop() { - const icon = Icon(Icons.arrow_downward, size: 17); + const icon = Icon(Icons.arrow_downward, size: 13); return Padding( padding: const EdgeInsets.only(bottom: 3), child: Row( diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 0b151d9c..60e11923 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -181,9 +181,10 @@ class _SettingPageState extends State { if (BioAuth.isPlatformSupported) { children.add(_buildBioAuth()); } + /// Platform specific settings - if (platform.hasSettings) { - children.add(_buildPlatformSetting(platform)); + if (OS.hasSettings) { + children.add(_buildPlatformSetting()); } return Column( children: children.map((e) => RoundRectCard(e)).toList(), @@ -1038,16 +1039,16 @@ class _SettingPageState extends State { ); } - Widget _buildPlatformSetting(PlatformType type) { + Widget _buildPlatformSetting() { return ListTile( - title: Text('${type.prettyName} ${_s.setting}'), + title: Text('${OS.type} ${_s.setting}'), trailing: const Icon(Icons.keyboard_arrow_right), onTap: () { - switch (type) { - case PlatformType.android: + switch (OS.type) { + case OS.android: AppRoute.androidSettings().go(context); break; - case PlatformType.ios: + case OS.ios: AppRoute.iosSettings().go(context); break; default: diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 25107c2d..e3944a4c 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -476,9 +476,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -491,9 +491,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -506,9 +506,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 562; + CURRENT_PROJECT_VERSION = 563; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.562; + MARKETING_VERSION = 1.0.563; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;