From 19baff5dde229f513e629eb8191cff16379f5f35 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Tue, 4 Apr 2023 17:38:00 +0800 Subject: [PATCH] opt. & fix. fix: setting page update item display issue. fix: `bgRun` condition issue. opt: `r_upgrade` use 0.3.8+2 --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/core/update.dart | 4 ++-- lib/core/utils/server.dart | 2 +- lib/view/page/home.dart | 10 ++++++---- pubspec.yaml | 4 +++- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 01a352cf..d0cf91b4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 250; + CURRENT_PROJECT_VERSION = 252; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -367,7 +367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.250; + MARKETING_VERSION = 1.0.252; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -490,7 +490,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 250; + CURRENT_PROJECT_VERSION = 252; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -498,7 +498,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.250; + MARKETING_VERSION = 1.0.252; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -515,7 +515,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 250; + CURRENT_PROJECT_VERSION = 252; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -523,7 +523,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.250; + MARKETING_VERSION = 1.0.252; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/core/update.dart b/lib/core/update.dart index 89c0fa80..bc791f3d 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -27,8 +27,6 @@ Future isFileAvailable(String url) async { Future doUpdate(BuildContext context, {bool force = false}) async { final update = await locator().getUpdate(); - locator().setNewestBuild(update.newest); - final newest = () { if (isAndroid) { return update.androidbuild; @@ -40,6 +38,8 @@ Future doUpdate(BuildContext context, {bool force = false}) async { return update.newest; }(); + locator().setNewestBuild(newest); + if (!force && newest <= BuildData.build) { _logger.info('Update ignored due to current: ${BuildData.build}, ' 'update: $newest'); diff --git a/lib/core/utils/server.dart b/lib/core/utils/server.dart index 9ebd5ffd..bdae473a 100644 --- a/lib/core/utils/server.dart +++ b/lib/core/utils/server.dart @@ -9,7 +9,7 @@ import '../../locator.dart'; /// Must put this func out of any Class. /// -/// Because of this function is called by [compute] in [ServerProvider.genClient]. +/// Because of this function is called by [compute]. /// /// https://stackoverflow.com/questions/51998995/invalid-arguments-illegal-argument-in-isolate-message-object-is-a-closure List loadIndentity(String key) { diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 82eb7a91..1304fb71 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -44,8 +44,11 @@ class _MyHomePageState extends State AutomaticKeepAliveClientMixin, AfterLayoutMixin, WidgetsBindingObserver { - late final ServerProvider _serverProvider; + final _serverProvider = locator(); + final _setting = locator(); + late final PageController _pageController; + late int _selectIndex; late double _width; late S _s; @@ -53,9 +56,8 @@ class _MyHomePageState extends State @override void initState() { super.initState(); - _serverProvider = locator(); WidgetsBinding.instance.addObserver(this); - _selectIndex = locator().launchPage.fetch()!; + _selectIndex = _setting.launchPage.fetch()!; _pageController = PageController(initialPage: _selectIndex); } @@ -85,7 +87,7 @@ class _MyHomePageState extends State } break; case AppLifecycleState.paused: - if (isAndroid) { + if (isAndroid && _setting.bgRun.fetch()!) { // Keep running in background on Android device bgRunChannel.invokeMethod('sendToBackground'); } else { diff --git a/pubspec.yaml b/pubspec.yaml index b7cf0ab8..c5217d4f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,9 @@ dependencies: url: https://github.com/lollipopkit/circle_chart ref: main # path: ../circle_chart - r_upgrade: ^0.3.6 + + # TODO: Update this :) + r_upgrade: 0.3.8+2 path_provider: ^2.0.9 easy_isolate: ^1.3.0 share_plus: ^6.3.1