mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
new: auto refresh container page
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
@@ -49,6 +51,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initAutoRefresh();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -300,7 +303,8 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
child: Text(l10n.dockerEditHost),
|
||||
),
|
||||
);
|
||||
return CardX(child: Column(
|
||||
return CardX(
|
||||
child: Column(
|
||||
children: children,
|
||||
));
|
||||
}
|
||||
@@ -582,4 +586,19 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
void _initAutoRefresh() {
|
||||
if (Stores.setting.contaienrAutoRefresh.fetch()) {
|
||||
Timer.periodic(
|
||||
Duration(seconds: Stores.setting.serverStatusUpdateInterval.fetch()),
|
||||
(timer) {
|
||||
if (mounted) {
|
||||
_container.refresh();
|
||||
} else {
|
||||
timer.cancel();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user