diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index 5fbd46c3..d01b238b 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:toolbox/core/utils/platform/path.dart'; import 'package:toolbox/data/model/app/shell_func.dart'; import 'package:toolbox/data/model/server/system.dart'; @@ -135,10 +136,13 @@ class ServerProvider extends ChangeNotifier { return await _getData(s.spi); } + static final refreshKey = GlobalKey(); + Future startAutoRefresh() async { final duration = Stores.setting.serverStatusUpdateInterval.fetch(); stopAutoRefresh(); if (duration == 0) return; + refreshKey.currentState?.show(); _timer = Timer.periodic(Duration(seconds: duration), (_) async { 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; void setDisconnected() { diff --git a/lib/main.dart b/lib/main.dart index 7191622f..1c4aa158 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -136,8 +136,9 @@ Future _initDesktopWindow() async { skipTaskbar: false, titleBarStyle: TitleBarStyle.hidden, ); - if (isMacOS) await CustomAppBar.updateTitlebarHeight(); + windowManager.waitUntilReadyToShow(windowOptions, () async { + if (isMacOS) await CustomAppBar.updateTitlebarHeight(); await windowManager.show(); await windowManager.focus(); }); diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index 4715d352..acd33b8f 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -170,12 +170,12 @@ class BackupPage extends StatelessWidget { children: [ TextButton( onPressed: () async => _onTapWebdavDl(context), - child: Text(l10n.download), + child: Text(l10n.restore), ), UIs.width7, TextButton( onPressed: () async => _onTapWebdavUp(context), - child: Text(l10n.upload), + child: Text(l10n.backup), ), ], ); diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 3eac45a9..36e6e200 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -93,6 +93,7 @@ class _HomePageState extends State case AppLifecycleState.paused: // Keep running in background on Android device if (isAndroid && Stores.setting.bgRun.fetch()) { + // Keep this if statement single if (Pros.app.moveBg) { BgRunMC.moveToBg(); } diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 0c4de69e..2e6c738d 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -90,10 +90,10 @@ class _ServerPageState extends State ); // Desktop doesn't support pull to refresh - if (isDesktop) { - return child; - } + if (isDesktop) return child; + return RefreshIndicator( + key: ServerProvider.refreshKey, onRefresh: () async => await Pros.server.refreshData(onlyFailed: true), child: child, ); diff --git a/lib/view/widget/appbar.dart b/lib/view/widget/appbar.dart index 13c3dcdf..cd1d34c9 100644 --- a/lib/view/widget/appbar.dart +++ b/lib/view/widget/appbar.dart @@ -74,10 +74,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { static Future updateTitlebarHeight() async { switch (Platform.operatingSystem) { case 'macos': - final newTitlebarHeight = await windowManager.getTitleBarHeight(); - if (_titlebarHeight != newTitlebarHeight) { - _titlebarHeight = newTitlebarHeight; - } + _titlebarHeight = 27; break; // Draw a titlebar on Linux case 'linux' || 'windows':