This commit is contained in:
lollipopkit
2023-12-11 11:13:49 +08:00
parent 73752bffc3
commit ce9929e93f
6 changed files with 23 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:toolbox/core/utils/platform/path.dart'; import 'package:toolbox/core/utils/platform/path.dart';
import 'package:toolbox/data/model/app/shell_func.dart'; import 'package:toolbox/data/model/app/shell_func.dart';
import 'package:toolbox/data/model/server/system.dart'; import 'package:toolbox/data/model/server/system.dart';
@@ -135,10 +136,13 @@ class ServerProvider extends ChangeNotifier {
return await _getData(s.spi); return await _getData(s.spi);
} }
static final refreshKey = GlobalKey<RefreshIndicatorState>();
Future<void> startAutoRefresh() async { Future<void> startAutoRefresh() async {
final duration = Stores.setting.serverStatusUpdateInterval.fetch(); final duration = Stores.setting.serverStatusUpdateInterval.fetch();
stopAutoRefresh(); stopAutoRefresh();
if (duration == 0) return; if (duration == 0) return;
refreshKey.currentState?.show();
_timer = Timer.periodic(Duration(seconds: duration), (_) async { _timer = Timer.periodic(Duration(seconds: duration), (_) async {
await refreshData(); await refreshData();
}); });
@@ -151,6 +155,16 @@ class ServerProvider extends ChangeNotifier {
} }
} }
void setNotBusy([String? id]) {
if (id == null) {
for (final s in _servers.values) {
s.isBusy = false;
}
return;
}
_servers[id]?.isBusy = false;
}
bool get isAutoRefreshOn => _timer != null; bool get isAutoRefreshOn => _timer != null;
void setDisconnected() { void setDisconnected() {

View File

@@ -136,8 +136,9 @@ Future<void> _initDesktopWindow() async {
skipTaskbar: false, skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden, titleBarStyle: TitleBarStyle.hidden,
); );
if (isMacOS) await CustomAppBar.updateTitlebarHeight();
windowManager.waitUntilReadyToShow(windowOptions, () async { windowManager.waitUntilReadyToShow(windowOptions, () async {
if (isMacOS) await CustomAppBar.updateTitlebarHeight();
await windowManager.show(); await windowManager.show();
await windowManager.focus(); await windowManager.focus();
}); });

View File

@@ -170,12 +170,12 @@ class BackupPage extends StatelessWidget {
children: [ children: [
TextButton( TextButton(
onPressed: () async => _onTapWebdavDl(context), onPressed: () async => _onTapWebdavDl(context),
child: Text(l10n.download), child: Text(l10n.restore),
), ),
UIs.width7, UIs.width7,
TextButton( TextButton(
onPressed: () async => _onTapWebdavUp(context), onPressed: () async => _onTapWebdavUp(context),
child: Text(l10n.upload), child: Text(l10n.backup),
), ),
], ],
); );

View File

@@ -93,6 +93,7 @@ class _HomePageState extends State<HomePage>
case AppLifecycleState.paused: case AppLifecycleState.paused:
// Keep running in background on Android device // Keep running in background on Android device
if (isAndroid && Stores.setting.bgRun.fetch()) { if (isAndroid && Stores.setting.bgRun.fetch()) {
// Keep this if statement single
if (Pros.app.moveBg) { if (Pros.app.moveBg) {
BgRunMC.moveToBg(); BgRunMC.moveToBg();
} }

View File

@@ -90,10 +90,10 @@ class _ServerPageState extends State<ServerPage>
); );
// Desktop doesn't support pull to refresh // Desktop doesn't support pull to refresh
if (isDesktop) { if (isDesktop) return child;
return child;
}
return RefreshIndicator( return RefreshIndicator(
key: ServerProvider.refreshKey,
onRefresh: () async => await Pros.server.refreshData(onlyFailed: true), onRefresh: () async => await Pros.server.refreshData(onlyFailed: true),
child: child, child: child,
); );

View File

@@ -74,10 +74,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
static Future<void> updateTitlebarHeight() async { static Future<void> updateTitlebarHeight() async {
switch (Platform.operatingSystem) { switch (Platform.operatingSystem) {
case 'macos': case 'macos':
final newTitlebarHeight = await windowManager.getTitleBarHeight(); _titlebarHeight = 27;
if (_titlebarHeight != newTitlebarHeight) {
_titlebarHeight = newTitlebarHeight;
}
break; break;
// Draw a titlebar on Linux // Draw a titlebar on Linux
case 'linux' || 'windows': case 'linux' || 'windows':