diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index df522679..c9fe32ac 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 = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -596,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -720,7 +720,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -730,7 +730,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -758,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -779,7 +779,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -792,7 +792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -818,7 +818,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -831,7 +831,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -854,7 +854,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -867,7 +867,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -890,7 +890,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -902,7 +902,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -931,7 +931,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -943,7 +943,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -969,7 +969,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 688; + CURRENT_PROJECT_VERSION = 693; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -981,7 +981,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.688; + MARKETING_VERSION = 1.0.693; 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 ae7426b0..0c952278 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -18,60 +18,68 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { setTransparentNavigationBar(context); - final child = _wrapTheme(context); - if (Stores.setting.useSystemPrimaryColor.fetch()) { - return _wrapSystemColor(context, child); - } - return child; - } - - Widget _wrapTheme(BuildContext context) { return ListenableBuilder( listenable: RebuildNodes.app, builder: (_, __) { - final tMode = Stores.setting.themeMode.fetch(); - // Issue #57 - final themeMode = switch (tMode) { - 1 || 2 => ThemeMode.values[tMode], - 3 => ThemeMode.dark, - _ => ThemeMode.system, - }; - final locale = Stores.setting.locale.fetch().toLocale; - final darkTheme = ThemeData( - useMaterial3: true, - brightness: Brightness.dark, - colorSchemeSeed: primaryColor, - ); - - return MaterialApp( - debugShowCheckedModeBanner: false, - locale: locale, - localizationsDelegates: S.localizationsDelegates, - supportedLocales: S.supportedLocales, - title: BuildData.name, - themeMode: themeMode, - theme: ThemeData( - useMaterial3: true, - colorSchemeSeed: primaryColor, - ), - darkTheme: tMode < 3 ? darkTheme : _getAmoledTheme(darkTheme), - home: Stores.setting.fullScreen.fetch() - ? const FullScreenPage() - : const HomePage(), + if (!Stores.setting.useSystemPrimaryColor.fetch()) { + primaryColor = Color(Stores.setting.primaryColor.fetch()); + return _buildApp(); + } + return DynamicColorBuilder( + builder: (light, dark) { + final lightTheme = ThemeData( + useMaterial3: true, + colorScheme: light, + ); + final darkTheme = ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + colorScheme: dark, + ); + if (context.isDark && light != null) { + primaryColor = light.primary; + } else if (!context.isDark && dark != null) { + primaryColor = dark.primary; + } + return _buildApp(light: lightTheme, dark: darkTheme); + }, ); }, ); } - Widget _wrapSystemColor(BuildContext context, Widget child) { - return DynamicColorBuilder(builder: (light, dark) { - if (context.isDark && light != null) { - primaryColor = light.primary; - } else if (!context.isDark && dark != null) { - primaryColor = dark.primary; - } - return child; - }); + Widget _buildApp({ThemeData? light, ThemeData? dark}) { + final tMode = Stores.setting.themeMode.fetch(); + // Issue #57 + final themeMode = switch (tMode) { + 1 || 2 => ThemeMode.values[tMode], + 3 => ThemeMode.dark, + _ => ThemeMode.system, + }; + final locale = Stores.setting.locale.fetch().toLocale; + + light ??= ThemeData( + useMaterial3: true, + colorSchemeSeed: primaryColor, + ); + dark ??= ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + colorSchemeSeed: primaryColor, + ); + + return MaterialApp( + locale: locale, + localizationsDelegates: S.localizationsDelegates, + supportedLocales: S.supportedLocales, + title: BuildData.name, + themeMode: themeMode, + theme: light, + darkTheme: tMode < 3 ? dark : _getAmoledTheme(dark), + home: Stores.setting.fullScreen.fetch() + ? const FullScreenPage() + : const HomePage(), + ); } } @@ -83,7 +91,7 @@ ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith( dialogTheme: const DialogTheme(backgroundColor: Colors.black), bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black), - listTileTheme: const ListTileThemeData(tileColor: Colors.black12), + listTileTheme: const ListTileThemeData(tileColor: Colors.transparent), cardTheme: const CardTheme(color: Colors.black12), navigationBarTheme: const NavigationBarThemeData(backgroundColor: Colors.black), diff --git a/lib/data/model/server/cpu.dart b/lib/data/model/server/cpu.dart index 2b09d2bb..0fbec3d1 100644 --- a/lib/data/model/server/cpu.dart +++ b/lib/data/model/server/cpu.dart @@ -75,29 +75,28 @@ class OneTimeCpuStatus extends TimeSeqIface { bool same(OneTimeCpuStatus other) => id == other.id; static List parse(String raw) { - final List cpus = []; + final List cpus = []; - for (var item in raw.split('\n')) { - if (item == '') break; - final id = item.split(' ').first; - final matches = item.replaceFirst(id, '').trim().split(' '); - cpus.add( - OneTimeCpuStatus( - id, - int.parse(matches[0]), - int.parse(matches[1]), - int.parse(matches[2]), - int.parse(matches[3]), - int.parse(matches[4]), - int.parse(matches[5]), - int.parse(matches[6]), - ), - ); + for (var item in raw.split('\n')) { + if (item == '') break; + final id = item.split(' ').first; + final matches = item.replaceFirst(id, '').trim().split(' '); + cpus.add( + OneTimeCpuStatus( + id, + int.parse(matches[0]), + int.parse(matches[1]), + int.parse(matches[2]), + int.parse(matches[3]), + int.parse(matches[4]), + int.parse(matches[5]), + int.parse(matches[6]), + ), + ); + } + return cpus; } - return cpus; } -} - final _bsdCpuPercentReg = RegExp(r'(\d+\.\d+)%'); diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 9dc61108..aef00719 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 = 688; - static const String engine = "3.16.4"; - static const String buildAt = "2023-12-21 16:19:00"; - static const int modifications = 6; - static const int script = 33; + static const int build = 693; + static const String engine = "3.16.5"; + static const String buildAt = "2023-12-29 17:24:27"; + static const int modifications = 5; + static const int script = 34; } diff --git a/lib/main.dart b/lib/main.dart index 3b7b071f..7d3c6cb9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,6 +12,7 @@ import 'package:toolbox/core/channel/bg_run.dart'; import 'package:toolbox/core/utils/sync/icloud.dart'; import 'package:toolbox/core/utils/platform/base.dart'; import 'package:toolbox/core/utils/sync/webdav.dart'; +import 'package:toolbox/core/utils/ui.dart'; import 'package:toolbox/data/res/logger.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; @@ -19,7 +20,6 @@ import 'package:window_manager/window_manager.dart'; import 'app.dart'; import 'core/analysis.dart'; -import 'core/utils/ui.dart'; import 'data/model/app/net_view.dart'; import 'data/model/server/private_key_info.dart'; import 'data/model/server/server_private_info.dart'; @@ -32,7 +32,6 @@ import 'data/provider/private_key.dart'; import 'data/provider/server.dart'; import 'data/provider/sftp.dart'; import 'data/provider/snippet.dart'; -import 'data/res/color.dart'; import 'locator.dart'; import 'view/widget/appbar.dart'; @@ -84,7 +83,6 @@ Future _initApp() async { _setupProviders(); // Load font - primaryColor = Color(Stores.setting.primaryColor.fetch()); loadFontFile(Stores.setting.fontPath.fetch()); if (isAndroid) { diff --git a/test/battery_test.dart b/test/battery_test.dart index a3808975..bf40a717 100644 --- a/test/battery_test.dart +++ b/test/battery_test.dart @@ -212,4 +212,4 @@ void main() { final result = Batteries.parse(_raw); expect(result.length, 7); }); -} \ No newline at end of file +}