From 99aa0fc1f504cc1635e732db25b156c760d832dd Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Fri, 17 Feb 2023 15:55:34 +0800 Subject: [PATCH] new: `pull to refresh` on server tab --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/data/provider/server.dart | 13 ++++++++++++- lib/data/res/build_data.dart | 9 ++++----- lib/generated/intl/messages_en.dart | 1 + lib/generated/intl/messages_zh.dart | 1 + lib/generated/l10n.dart | 10 ++++++++++ lib/l10n/intl_en.arb | 1 + lib/l10n/intl_zh.arb | 1 + lib/view/page/home.dart | 2 +- lib/view/page/server/detail.dart | 12 ++++-------- lib/view/page/server/tab.dart | 3 ++- make.dart | 6 +++--- 12 files changed, 46 insertions(+), 25 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f3eec0f4..019cb754 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -356,7 +356,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 218; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -364,7 +364,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.218; + MARKETING_VERSION = 1.0.220; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -486,7 +486,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 218; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -494,7 +494,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.218; + MARKETING_VERSION = 1.0.220; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -510,7 +510,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 218; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -518,7 +518,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.218; + MARKETING_VERSION = 1.0.220; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index 4729f3d7..39653019 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -41,12 +41,18 @@ class ServerProvider extends BusyProvider { return Server(spi, initStatus, null, ServerState.disconnected); } - Future refreshData({ServerPrivateInfo? spi}) async { + Future refreshData( + {ServerPrivateInfo? spi, bool onlyFailed = false}) async { if (spi != null) { await _getData(spi); return; } await Future.wait(_servers.map((s) async { + if (onlyFailed) { + if (s.cs != ServerState.failed) return; + _limiter.resetTryTimes(s.spi.id); + } + if (onlyFailed && s.cs != ServerState.failed) return; await _getData(s.spi); })); } @@ -72,6 +78,7 @@ class ServerProvider extends BusyProvider { for (var i = 0; i < _servers.length; i++) { _servers[i].cs = ServerState.disconnected; } + _limiter.clear(); notifyListeners(); } @@ -274,4 +281,8 @@ class _TryLimiter { void resetTryTimes(String id) { _triedTimes[id] = 0; } + + void clear() { + _triedTimes.clear(); + } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 6fd8576e..5fa3d28f 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 218; - static const String engine = - "Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 9944297138 (5 days ago) • 2023-02-08 15:46:04 -0800\nEngine • revision 248290d6d5\nTools • Dart 2.19.2 • DevTools 2.20.1\n"; - static const String buildAt = "2023-02-14 18:46:55.180156"; - static const int modifications = 5; + static const int build = 220; + static const String engine = "Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 9944297138 (7 days ago) • 2023-02-08 15:46:04 -0800\nEngine • revision 248290d6d5\nTools • Dart 2.19.2 • DevTools 2.20.1\n"; + static const String buildAt = "2023-02-16 12:58:28.193531"; + static const int modifications = 3; } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 5b4fafef..51c88e4c 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -68,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "about": MessageLookupByLibrary.simpleMessage("About"), "aboutThanks": MessageLookupByLibrary.simpleMessage( "\n\nThanks to the following people who participated in the test."), "addAServer": MessageLookupByLibrary.simpleMessage("add a server"), diff --git a/lib/generated/intl/messages_zh.dart b/lib/generated/intl/messages_zh.dart index 847b2e1b..15ab3c1a 100644 --- a/lib/generated/intl/messages_zh.dart +++ b/lib/generated/intl/messages_zh.dart @@ -66,6 +66,7 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "about": MessageLookupByLibrary.simpleMessage("关于"), "aboutThanks": MessageLookupByLibrary.simpleMessage("\n\n感谢以下参与软件测试的各位。"), "addAServer": MessageLookupByLibrary.simpleMessage("添加服务器"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 53b964cc..704b5205 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -50,6 +50,16 @@ class S { return Localizations.of(context, S); } + /// `About` + String get about { + return Intl.message( + 'About', + name: 'about', + desc: '', + args: [], + ); + } + /// `\n\nThanks to the following people who participated in the test.` String get aboutThanks { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 22f18ade..c7b4f5ac 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,4 +1,5 @@ { + "about": "About", "aboutThanks": "\n\nThanks to the following people who participated in the test.", "addAServer": "add a server", "addOne": "Add one", diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index 9350b363..33302562 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -1,4 +1,5 @@ { + "about": "关于", "aboutThanks": "\n\n感谢以下参与软件测试的各位。", "addAServer": "添加服务器", "addOne": "前去新增", diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 67fad83a..e78a5c57 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -267,7 +267,7 @@ class _MyHomePageState extends State ), ) ], - child: Text(_s.license), + child: Text(_s.about), ) ], ), diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index 7777aa6d..522f3c89 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -220,7 +220,7 @@ class _ServerDetailPageState extends State children: [ Text('${used.toStringAsFixed(0)}%', style: textSize27), width7, - Text('of ${(ss.mem.total * 1024).convertBytes} Mem', + Text('of ${(ss.mem.total * 1024).convertBytes}', style: textSize13Grey) ], ), @@ -233,9 +233,7 @@ class _ServerDetailPageState extends State ), ], ), - const SizedBox( - height: 11, - ), + height13, _buildProgress(used) ], ), @@ -262,7 +260,7 @@ class _ServerDetailPageState extends State children: [ Text('${used.toStringAsFixed(0)}%', style: textSize27), width7, - Text('of ${(ss.swap.total * 1024).convertBytes} Swap', + Text('of ${(ss.swap.total * 1024).convertBytes} ', style: textSize13Grey) ], ), @@ -275,9 +273,7 @@ class _ServerDetailPageState extends State ), ], ), - const SizedBox( - height: 11, - ), + height13, _buildProgress(used) ], ), diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 1a875761..fddadc30 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -76,6 +76,7 @@ class _ServerPageState extends State return ListView.separated( padding: const EdgeInsets.all(7), controller: ScrollController(), + physics: const AlwaysScrollableScrollPhysics(), itemBuilder: (ctx, idx) { if (idx == pro.servers.length) { return SizedBox(height: _media.padding.bottom); @@ -90,7 +91,7 @@ class _ServerPageState extends State }, ); return Scaffold( - body: child, + body: RefreshIndicator(child: child, onRefresh: () async => await _serverProvider.refreshData(onlyFailed: true)), floatingActionButton: FloatingActionButton( onPressed: () => AppRoute( const ServerEditPage(), diff --git a/make.dart b/make.dart index 728fe9f0..fb49d14c 100755 --- a/make.dart +++ b/make.dart @@ -90,7 +90,7 @@ Future updateBuildData() async { Future dartFormat() async { final result = await fvmRun(['dart', 'format', '.']); - print('\n${result.stdout}'); + print(result.stdout); if (result.exitCode != 0) { print(result.stderr); exit(1); @@ -183,8 +183,8 @@ void main(List args) async { switch (command) { case 'build': final stopwatch = Stopwatch()..start(); - build = await getGitCommitCount(); await dartFormat(); + build = await getGitCommitCount(); await updateBuildData(); await changeAppleVersion(); if (args.length > 1) { @@ -192,7 +192,7 @@ void main(List args) async { for (final platform in platforms.split(',')) { if (buildFuncs.keys.contains(platform)) { await buildFuncs[platform]!(); - print('Build finished in ${stopwatch.elapsed}'); + print('Build finished in [${stopwatch.elapsed}]'); stopwatch.reset(); stopwatch.start(); } else {