diff --git a/lib/core/utils/window_size_listener.dart b/lib/core/utils/window_size_listener.dart index 1fc752710..67270f760 100644 --- a/lib/core/utils/window_size_listener.dart +++ b/lib/core/utils/window_size_listener.dart @@ -8,52 +8,40 @@ abstract final class WindowSizeListener { final class _WindowSizeListener implements WindowListener { @override - void onWindowBlur() { - } + void onWindowBlur() {} @override - void onWindowClose() { - } + void onWindowClose() {} @override - void onWindowDocked() { - } + void onWindowDocked() {} @override - void onWindowEnterFullScreen() { - } + void onWindowEnterFullScreen() {} @override - void onWindowEvent(String eventName) { - } + void onWindowEvent(String eventName) {} @override - void onWindowFocus() { - } + void onWindowFocus() {} @override - void onWindowLeaveFullScreen() { - } + void onWindowLeaveFullScreen() {} @override - void onWindowMaximize() { - } + void onWindowMaximize() {} @override - void onWindowMinimize() { - } + void onWindowMinimize() {} @override - void onWindowMove() { - } + void onWindowMove() {} @override - void onWindowMoved() { - } + void onWindowMoved() {} @override void onWindowResize() { - if (!isLinux) return; final current = Stores.setting.windowSize.fetch(); if (current.isEmpty) return; @@ -63,26 +51,14 @@ final class _WindowSizeListener implements WindowListener { } @override - void onWindowResized() { - if (!isMacOS || !isWindows) return; - final current = Stores.setting.windowSize.fetch(); - if (current.isEmpty) return; - - windowManager.getSize().then((size) { - Stores.setting.windowSize.put(size.toIntStr()); - }); - } + void onWindowResized() {} @override - void onWindowRestore() { - } + void onWindowRestore() {} @override - void onWindowUndocked() { - } + void onWindowUndocked() {} @override - void onWindowUnmaximize() { - } - -} \ No newline at end of file + void onWindowUnmaximize() {} +} diff --git a/lib/main.dart b/lib/main.dart index fe568791a..e4fd0b649 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,8 +70,10 @@ Future _initApp() async { _setupDebug(); final windowSize = Stores.setting.windowSize.fetch().toSize(); + final hideTitleBar = Stores.setting.hideTitleBar.fetch(); + print('windowSize: $windowSize, hideTitleBar: $hideTitleBar'); SystemUIs.initDesktopWindow( - hideTitleBar: Stores.setting.hideTitleBar.fetch(), + hideTitleBar: hideTitleBar, size: windowSize, listener: WindowSizeListener.instance, ); diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index ba095eb97..667db7a3e 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -66,18 +66,7 @@ class BackupPage extends StatelessWidget { trailing: const Icon(Icons.save), onTap: () async { final path = await Backup.backup(); - debugPrint("Backup path: $path"); - - /// Issue #188 - switch (Pfs.type) { - case Pfs.windows: - final backslashPath = path.replaceAll('/', '\\'); - await Process.run('explorer', ['/select,$backslashPath']); - case Pfs.linux: - await Process.run('xdg-open', [path]); - default: - await Pfs.sharePath(path); - } + await Pfs.share(path: path); }, ), ListTile( diff --git a/lib/view/page/storage/local.dart b/lib/view/page/storage/local.dart index 65a28a64c..e0dc8da54 100644 --- a/lib/view/page/storage/local.dart +++ b/lib/view/page/storage/local.dart @@ -314,7 +314,7 @@ class _LocalStoragePageState extends State { leading: const Icon(Icons.open_in_new), title: Text(l10n.open), onTap: () { - Pfs.sharePath(file.absolute.path); + Pfs.share(path: file.absolute.path); }, ), ], diff --git a/lib/view/page/storage/sftp_mission.dart b/lib/view/page/storage/sftp_mission.dart index c07770727..4bf157179 100644 --- a/lib/view/page/storage/sftp_mission.dart +++ b/lib/view/page/storage/sftp_mission.dart @@ -59,65 +59,84 @@ class _SftpMissionPageState extends State { ), ); } - switch (status.status) { - case SftpWorkerStatus.finished: - final time = status.spentTime.toString(); - final str = '${l10n.finished} ${l10n.spentTime( - time == 'null' ? l10n.unknown : (time.substring(0, time.length - 7)), - )}'; - return _wrapInCard( - status: status, - subtitle: str, - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - onPressed: () { - final idx = status.req.localPath.lastIndexOf('/'); - final dir = status.req.localPath.substring(0, idx); - AppRoutes.localStorage(initDir: dir).go(context); - }, - icon: const Icon(Icons.file_open)), - IconButton( - onPressed: () => Pfs.sharePath(status.req.localPath), - icon: const Icon(Icons.open_in_new), - ) - ], - ), - ); - case SftpWorkerStatus.loading: - final percentStr = (status.progress ?? 0.0).toStringAsFixed(2); - final size = (status.size ?? 0).bytes2Str; - return _wrapInCard( - status: status, - subtitle: l10n.percentOfSize(percentStr, size), - trailing: _buildDelete(status.fileName, status.id), - ); - case SftpWorkerStatus.preparing: - return _wrapInCard( - status: status, - subtitle: l10n.sftpDlPrepare, - trailing: _buildDelete(status.fileName, status.id), - ); - case SftpWorkerStatus.sshConnectted: - return _wrapInCard( - status: status, - subtitle: l10n.sftpSSHConnected, - trailing: _buildDelete(status.fileName, status.id), - ); - default: - return _wrapInCard( - status: status, - subtitle: l10n.unknown, - trailing: IconButton( - onPressed: () => context.showRoundDialog( - title: l10n.error, - child: Text((status.error ?? l10n.unknown).toString()), - ), - icon: const Icon(Icons.error), - ), - ); - } + return switch (status.status) { + const (SftpWorkerStatus.finished) => _buildFinished(status), + const (SftpWorkerStatus.loading) => _buildLoading(status), + const (SftpWorkerStatus.sshConnectted) => _buildConnected(status), + const (SftpWorkerStatus.preparing) => _buildPreparing(status), + _ => _buildDefault(status), + }; + } + + Widget _buildPreparing(SftpReqStatus status) { + return _wrapInCard( + status: status, + subtitle: l10n.sftpDlPrepare, + trailing: _buildDelete(status.fileName, status.id), + ); + } + + Widget _buildDefault(SftpReqStatus status) { + return _wrapInCard( + status: status, + subtitle: l10n.unknown, + trailing: IconButton( + onPressed: () => context.showRoundDialog( + title: l10n.error, + child: Text((status.error ?? l10n.unknown).toString()), + ), + icon: const Icon(Icons.error), + ), + ); + } + + Widget _buildConnected(SftpReqStatus status) { + return _wrapInCard( + status: status, + subtitle: l10n.sftpSSHConnected, + trailing: _buildDelete(status.fileName, status.id), + ); + } + + Widget _buildLoading(SftpReqStatus status) { + final percentStr = (status.progress ?? 0.0).toStringAsFixed(2); + final size = (status.size ?? 0).bytes2Str; + return _wrapInCard( + status: status, + subtitle: l10n.percentOfSize(percentStr, size), + trailing: _buildDelete(status.fileName, status.id), + ); + } + + Widget _buildFinished(SftpReqStatus status) { + final time = status.spentTime.toString(); + final str = '${l10n.finished} ${l10n.spentTime( + time == 'null' ? l10n.unknown : (time.substring(0, time.length - 7)), + )}'; + + final btns = Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + onPressed: () { + final idx = status.req.localPath.lastIndexOf('/'); + final dir = status.req.localPath.substring(0, idx); + AppRoutes.localStorage(initDir: dir).go(context); + }, + icon: const Icon(Icons.file_open), + ), + IconButton( + onPressed: () => Pfs.share(path: status.req.localPath), + icon: const Icon(Icons.open_in_new), + ) + ], + ); + + return _wrapInCard( + status: status, + subtitle: str, + trailing: btns, + ); } Widget _wrapInCard({ diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 16b145448..dcd684b39 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -1,9 +1,13 @@ PODS: + - device_info_plus (0.0.1): + - FlutterMacOS - dynamic_color (0.0.2): - FlutterMacOS - FlutterMacOS (1.0.0) - icloud_storage (0.0.1): - FlutterMacOS + - package_info_plus (0.0.1): + - FlutterMacOS - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS @@ -16,27 +20,36 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - wakelock_plus (0.0.1): + - FlutterMacOS - window_manager (0.2.0): - FlutterMacOS DEPENDENCIES: + - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - icloud_storage (from `Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos`) + - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) EXTERNAL SOURCES: + device_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos dynamic_color: :path: Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos FlutterMacOS: :path: Flutter/ephemeral icloud_storage: :path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos + package_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin screen_retriever: @@ -47,18 +60,23 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + wakelock_plus: + :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos window_manager: :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: + device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 dynamic_color: 2eaa27267de1ca20d879fbd6e01259773fb1670f FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd - path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf - shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 + url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 + wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 PODFILE CHECKSUM: 8cdf29216ea1ab6b9743188287968d22b4579c1d diff --git a/pubspec.lock b/pubspec.lock index 406101545..325ca0828 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -385,8 +385,8 @@ packages: dependency: "direct main" description: path: "." - ref: "v1.0.45" - resolved-ref: ec8b29583a872130a536745eb2ff34f3f71ec042 + ref: "v1.0.47" + resolved-ref: ea605db48e626fa08f06b2056510ed4887ade087 url: "https://github.com/lppcg/fl_lib" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 68dbc7019..1d55df6fb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,7 +58,7 @@ dependencies: fl_lib: git: url: https://github.com/lppcg/fl_lib - ref: v1.0.45 + ref: v1.0.47 dependency_overrides: # dartssh2: