new: pull to refresh on server tab
This commit is contained in:
@@ -41,12 +41,18 @@ class ServerProvider extends BusyProvider {
|
||||
return Server(spi, initStatus, null, ServerState.disconnected);
|
||||
}
|
||||
|
||||
Future<void> refreshData({ServerPrivateInfo? spi}) async {
|
||||
Future<void> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
"about": MessageLookupByLibrary.simpleMessage("About"),
|
||||
"aboutThanks": MessageLookupByLibrary.simpleMessage(
|
||||
"\n\nThanks to the following people who participated in the test."),
|
||||
"addAServer": MessageLookupByLibrary.simpleMessage("add a server"),
|
||||
|
||||
@@ -66,6 +66,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
"about": MessageLookupByLibrary.simpleMessage("关于"),
|
||||
"aboutThanks":
|
||||
MessageLookupByLibrary.simpleMessage("\n\n感谢以下参与软件测试的各位。"),
|
||||
"addAServer": MessageLookupByLibrary.simpleMessage("添加服务器"),
|
||||
|
||||
@@ -50,6 +50,16 @@ class S {
|
||||
return Localizations.of<S>(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(
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"about": "关于",
|
||||
"aboutThanks": "\n\n感谢以下参与软件测试的各位。",
|
||||
"addAServer": "添加服务器",
|
||||
"addOne": "前去新增",
|
||||
|
||||
@@ -267,7 +267,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
),
|
||||
)
|
||||
],
|
||||
child: Text(_s.license),
|
||||
child: Text(_s.about),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -220,7 +220,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
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<ServerDetailPage>
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 11,
|
||||
),
|
||||
height13,
|
||||
_buildProgress(used)
|
||||
],
|
||||
),
|
||||
@@ -262,7 +260,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
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<ServerDetailPage>
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 11,
|
||||
),
|
||||
height13,
|
||||
_buildProgress(used)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -76,6 +76,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
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<ServerPage>
|
||||
},
|
||||
);
|
||||
return Scaffold(
|
||||
body: child,
|
||||
body: RefreshIndicator(child: child, onRefresh: () async => await _serverProvider.refreshData(onlyFailed: true)),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => AppRoute(
|
||||
const ServerEditPage(),
|
||||
|
||||
Reference in New Issue
Block a user