feat: keep screen on during file transfer

This commit is contained in:
Tien Do Nam
2023-01-07 00:50:29 +01:00
parent c2c09704ec
commit d237d947f4
5 changed files with 55 additions and 0 deletions
+4
View File
@@ -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
+13
View File
@@ -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) {
@@ -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"))
}
+35
View File
@@ -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:
+1
View File
@@ -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