mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: share on desktop (#405)
This commit is contained in:
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
void onWindowUnmaximize() {}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,10 @@ Future<void> _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,
|
||||
);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -314,7 +314,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
leading: const Icon(Icons.open_in_new),
|
||||
title: Text(l10n.open),
|
||||
onTap: () {
|
||||
Pfs.sharePath(file.absolute.path);
|
||||
Pfs.share(path: file.absolute.path);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -59,65 +59,84 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
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({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user