Skip to content

An open-source cross-platform alternative to AirDrop

feat: keep screen on during file transfer

Tien Do Namd237d947f441
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3bdfbf1d..f931758c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.5.0 (2023-01-)
+
+- feat: keep screen on during file transfer
+
## 1.4.0 (2023-01-06)
- feat: support multiple local IP addresses
diff --git a/lib/pages/progress_page.dart b/lib/pages/progress_page.dart
index 4ca886c6..3740ce26 100644
--- a/lib/pages/progress_page.dart
+++ b/lib/pages/progress_page.dart
@@ -15,6 +15,7 @@ import 'package:localsend_app/widget/custom_progress_bar.dart';
import 'package:localsend_app/widget/dialogs/cancel_session_dialog.dart';
import 'package:open_filex/open_filex.dart';
import 'package:routerino/routerino.dart';
+import 'package:wakelock/wakelock.dart';
class ProgressPage extends ConsumerStatefulWidget {
const ProgressPage({Key? key}) : super(key: key);
@@ -36,6 +37,10 @@ class _ProgressPageState extends ConsumerState<ProgressPage> {
// init
WidgetsBinding.instance.addPostFrameCallback((_) {
+ try {
+ Wakelock.enable();
+ } catch (_) {}
+
final receiveState = ref.read(serverProvider.select((state) => state?.receiveState));
if (receiveState != null) {
_files = receiveState.files.values.map((f) => f.file).toList();
@@ -52,6 +57,14 @@ class _ProgressPageState extends ConsumerState<ProgressPage> {
});
}
+ @override
+ void dispose() {
+ super.dispose();
+ try {
+ Wakelock.disable();
+ } catch (_) {}
+ }
+
Future<bool> _askCancelConfirmation(SessionStatus status) async {
final bool result = status == SessionStatus.sending ? await context.pushBottomSheet(() => const CancelSessionDialog()) : true;
if (result) {
diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift
index 41377eac..c6dd758a 100644
--- a/macos/Flutter/GeneratedPluginRegistrant.swift
+++ b/macos/Flutter/GeneratedPluginRegistrant.swift
@@ -15,6 +15,7 @@ import photo_manager
import screen_retriever
import shared_preferences_macos
import url_launcher_macos
+import wakelock_macos
import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
@@ -28,5 +29,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
+ WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
diff --git a/pubspec.lock b/pubspec.lock
index 524063db..c271d199 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1225,6 +1225,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "9.4.0"
+ wakelock:
+ dependency: "direct main"
+ description:
+ name: wakelock
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.6.2"
+ wakelock_macos:
+ dependency: transitive
+ description:
+ name: wakelock_macos
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.4.0"
+ wakelock_platform_interface:
+ dependency: transitive
+ description:
+ name: wakelock_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.0"
+ wakelock_web:
+ dependency: transitive
+ description:
+ name: wakelock_web
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.4.0"
+ wakelock_windows:
+ dependency: transitive
+ description:
+ name: wakelock_windows
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.1"
watcher:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 6dcaab79..b4b3c69e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -41,6 +41,7 @@ dependencies:
slang_flutter: 3.7.0
url_launcher: 6.1.7
uuid: 3.0.7
+ wakelock: 0.6.2
wechat_assets_picker: 8.3.0
window_manager: 0.2.8