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 {
|
final class _WindowSizeListener implements WindowListener {
|
||||||
@override
|
@override
|
||||||
void onWindowBlur() {
|
void onWindowBlur() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowClose() {
|
void onWindowClose() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowDocked() {
|
void onWindowDocked() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowEnterFullScreen() {
|
void onWindowEnterFullScreen() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowEvent(String eventName) {
|
void onWindowEvent(String eventName) {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowFocus() {
|
void onWindowFocus() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowLeaveFullScreen() {
|
void onWindowLeaveFullScreen() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowMaximize() {
|
void onWindowMaximize() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowMinimize() {
|
void onWindowMinimize() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowMove() {
|
void onWindowMove() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowMoved() {
|
void onWindowMoved() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowResize() {
|
void onWindowResize() {
|
||||||
if (!isLinux) return;
|
|
||||||
final current = Stores.setting.windowSize.fetch();
|
final current = Stores.setting.windowSize.fetch();
|
||||||
if (current.isEmpty) return;
|
if (current.isEmpty) return;
|
||||||
|
|
||||||
@@ -63,26 +51,14 @@ final class _WindowSizeListener implements WindowListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowResized() {
|
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());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowRestore() {
|
void onWindowRestore() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowUndocked() {
|
void onWindowUndocked() {}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowUnmaximize() {
|
void onWindowUnmaximize() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ Future<void> _initApp() async {
|
|||||||
_setupDebug();
|
_setupDebug();
|
||||||
|
|
||||||
final windowSize = Stores.setting.windowSize.fetch().toSize();
|
final windowSize = Stores.setting.windowSize.fetch().toSize();
|
||||||
|
final hideTitleBar = Stores.setting.hideTitleBar.fetch();
|
||||||
|
print('windowSize: $windowSize, hideTitleBar: $hideTitleBar');
|
||||||
SystemUIs.initDesktopWindow(
|
SystemUIs.initDesktopWindow(
|
||||||
hideTitleBar: Stores.setting.hideTitleBar.fetch(),
|
hideTitleBar: hideTitleBar,
|
||||||
size: windowSize,
|
size: windowSize,
|
||||||
listener: WindowSizeListener.instance,
|
listener: WindowSizeListener.instance,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -66,18 +66,7 @@ class BackupPage extends StatelessWidget {
|
|||||||
trailing: const Icon(Icons.save),
|
trailing: const Icon(Icons.save),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final path = await Backup.backup();
|
final path = await Backup.backup();
|
||||||
debugPrint("Backup path: $path");
|
await Pfs.share(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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
|||||||
leading: const Icon(Icons.open_in_new),
|
leading: const Icon(Icons.open_in_new),
|
||||||
title: Text(l10n.open),
|
title: Text(l10n.open),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Pfs.sharePath(file.absolute.path);
|
Pfs.share(path: file.absolute.path);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -59,65 +59,84 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
switch (status.status) {
|
return switch (status.status) {
|
||||||
case SftpWorkerStatus.finished:
|
const (SftpWorkerStatus.finished) => _buildFinished(status),
|
||||||
final time = status.spentTime.toString();
|
const (SftpWorkerStatus.loading) => _buildLoading(status),
|
||||||
final str = '${l10n.finished} ${l10n.spentTime(
|
const (SftpWorkerStatus.sshConnectted) => _buildConnected(status),
|
||||||
time == 'null' ? l10n.unknown : (time.substring(0, time.length - 7)),
|
const (SftpWorkerStatus.preparing) => _buildPreparing(status),
|
||||||
)}';
|
_ => _buildDefault(status),
|
||||||
return _wrapInCard(
|
};
|
||||||
status: status,
|
}
|
||||||
subtitle: str,
|
|
||||||
trailing: Row(
|
Widget _buildPreparing(SftpReqStatus status) {
|
||||||
mainAxisSize: MainAxisSize.min,
|
return _wrapInCard(
|
||||||
children: [
|
status: status,
|
||||||
IconButton(
|
subtitle: l10n.sftpDlPrepare,
|
||||||
onPressed: () {
|
trailing: _buildDelete(status.fileName, status.id),
|
||||||
final idx = status.req.localPath.lastIndexOf('/');
|
);
|
||||||
final dir = status.req.localPath.substring(0, idx);
|
}
|
||||||
AppRoutes.localStorage(initDir: dir).go(context);
|
|
||||||
},
|
Widget _buildDefault(SftpReqStatus status) {
|
||||||
icon: const Icon(Icons.file_open)),
|
return _wrapInCard(
|
||||||
IconButton(
|
status: status,
|
||||||
onPressed: () => Pfs.sharePath(status.req.localPath),
|
subtitle: l10n.unknown,
|
||||||
icon: const Icon(Icons.open_in_new),
|
trailing: IconButton(
|
||||||
)
|
onPressed: () => context.showRoundDialog(
|
||||||
],
|
title: l10n.error,
|
||||||
),
|
child: Text((status.error ?? l10n.unknown).toString()),
|
||||||
);
|
),
|
||||||
case SftpWorkerStatus.loading:
|
icon: const Icon(Icons.error),
|
||||||
final percentStr = (status.progress ?? 0.0).toStringAsFixed(2);
|
),
|
||||||
final size = (status.size ?? 0).bytes2Str;
|
);
|
||||||
return _wrapInCard(
|
}
|
||||||
status: status,
|
|
||||||
subtitle: l10n.percentOfSize(percentStr, size),
|
Widget _buildConnected(SftpReqStatus status) {
|
||||||
trailing: _buildDelete(status.fileName, status.id),
|
return _wrapInCard(
|
||||||
);
|
status: status,
|
||||||
case SftpWorkerStatus.preparing:
|
subtitle: l10n.sftpSSHConnected,
|
||||||
return _wrapInCard(
|
trailing: _buildDelete(status.fileName, status.id),
|
||||||
status: status,
|
);
|
||||||
subtitle: l10n.sftpDlPrepare,
|
}
|
||||||
trailing: _buildDelete(status.fileName, status.id),
|
|
||||||
);
|
Widget _buildLoading(SftpReqStatus status) {
|
||||||
case SftpWorkerStatus.sshConnectted:
|
final percentStr = (status.progress ?? 0.0).toStringAsFixed(2);
|
||||||
return _wrapInCard(
|
final size = (status.size ?? 0).bytes2Str;
|
||||||
status: status,
|
return _wrapInCard(
|
||||||
subtitle: l10n.sftpSSHConnected,
|
status: status,
|
||||||
trailing: _buildDelete(status.fileName, status.id),
|
subtitle: l10n.percentOfSize(percentStr, size),
|
||||||
);
|
trailing: _buildDelete(status.fileName, status.id),
|
||||||
default:
|
);
|
||||||
return _wrapInCard(
|
}
|
||||||
status: status,
|
|
||||||
subtitle: l10n.unknown,
|
Widget _buildFinished(SftpReqStatus status) {
|
||||||
trailing: IconButton(
|
final time = status.spentTime.toString();
|
||||||
onPressed: () => context.showRoundDialog(
|
final str = '${l10n.finished} ${l10n.spentTime(
|
||||||
title: l10n.error,
|
time == 'null' ? l10n.unknown : (time.substring(0, time.length - 7)),
|
||||||
child: Text((status.error ?? l10n.unknown).toString()),
|
)}';
|
||||||
),
|
|
||||||
icon: const Icon(Icons.error),
|
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({
|
Widget _wrapInCard({
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
PODS:
|
PODS:
|
||||||
|
- device_info_plus (0.0.1):
|
||||||
|
- FlutterMacOS
|
||||||
- dynamic_color (0.0.2):
|
- dynamic_color (0.0.2):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- FlutterMacOS (1.0.0)
|
- FlutterMacOS (1.0.0)
|
||||||
- icloud_storage (0.0.1):
|
- icloud_storage (0.0.1):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
- package_info_plus (0.0.1):
|
||||||
|
- FlutterMacOS
|
||||||
- path_provider_foundation (0.0.1):
|
- path_provider_foundation (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
@@ -16,27 +20,36 @@ PODS:
|
|||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- url_launcher_macos (0.0.1):
|
- url_launcher_macos (0.0.1):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
- wakelock_plus (0.0.1):
|
||||||
|
- FlutterMacOS
|
||||||
- window_manager (0.2.0):
|
- window_manager (0.2.0):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
|
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
|
||||||
- dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`)
|
- dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`)
|
||||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||||
- icloud_storage (from `Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos`)
|
- 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`)
|
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
|
||||||
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
|
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
|
||||||
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
|
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
|
||||||
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
|
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||||
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
|
- 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`)
|
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
|
device_info_plus:
|
||||||
|
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
|
||||||
dynamic_color:
|
dynamic_color:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos
|
||||||
FlutterMacOS:
|
FlutterMacOS:
|
||||||
:path: Flutter/ephemeral
|
:path: Flutter/ephemeral
|
||||||
icloud_storage:
|
icloud_storage:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos
|
||||||
|
package_info_plus:
|
||||||
|
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
|
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
|
||||||
screen_retriever:
|
screen_retriever:
|
||||||
@@ -47,18 +60,23 @@ EXTERNAL SOURCES:
|
|||||||
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
|
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
|
||||||
url_launcher_macos:
|
url_launcher_macos:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
|
||||||
|
wakelock_plus:
|
||||||
|
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos
|
||||||
window_manager:
|
window_manager:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
|
device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
|
||||||
dynamic_color: 2eaa27267de1ca20d879fbd6e01259773fb1670f
|
dynamic_color: 2eaa27267de1ca20d879fbd6e01259773fb1670f
|
||||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||||
icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd
|
icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd
|
||||||
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
|
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
|
||||||
|
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
|
||||||
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
|
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
|
||||||
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
|
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
|
||||||
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
|
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
|
||||||
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
|
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
|
||||||
|
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
|
||||||
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
|
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
|
||||||
|
|
||||||
PODFILE CHECKSUM: 8cdf29216ea1ab6b9743188287968d22b4579c1d
|
PODFILE CHECKSUM: 8cdf29216ea1ab6b9743188287968d22b4579c1d
|
||||||
|
|||||||
@@ -385,8 +385,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "v1.0.45"
|
ref: "v1.0.47"
|
||||||
resolved-ref: ec8b29583a872130a536745eb2ff34f3f71ec042
|
resolved-ref: ea605db48e626fa08f06b2056510ed4887ade087
|
||||||
url: "https://github.com/lppcg/fl_lib"
|
url: "https://github.com/lppcg/fl_lib"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ dependencies:
|
|||||||
fl_lib:
|
fl_lib:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/lppcg/fl_lib
|
url: https://github.com/lppcg/fl_lib
|
||||||
ref: v1.0.45
|
ref: v1.0.47
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
# dartssh2:
|
# dartssh2:
|
||||||
|
|||||||
Reference in New Issue
Block a user