From d94a7ea5faa5354004f9ac4ec709b1b7845ae07a Mon Sep 17 00:00:00 2001 From: jld3103 Date: Thu, 14 Jul 2022 07:45:21 +0200 Subject: [PATCH] harbour, notes: Use wakelock on note page --- packages/harbour/lib/src/apps/notes/app.dart | 2 ++ packages/harbour/lib/src/apps/notes/pages/note.dart | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/packages/harbour/lib/src/apps/notes/app.dart b/packages/harbour/lib/src/apps/notes/app.dart index e089dfa4..00388980 100644 --- a/packages/harbour/lib/src/apps/notes/app.dart +++ b/packages/harbour/lib/src/apps/notes/app.dart @@ -9,11 +9,13 @@ import 'package:harbour/src/harbour.dart'; import 'package:intersperse/intersperse.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:nextcloud/nextcloud.dart'; +import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; import 'package:settings/settings.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sort_box/sort_box.dart'; import 'package:url_launcher/url_launcher_string.dart'; +import 'package:wakelock/wakelock.dart'; part 'dialogs/create_note.dart'; part 'dialogs/select_category.dart'; diff --git a/packages/harbour/lib/src/apps/notes/pages/note.dart b/packages/harbour/lib/src/apps/notes/pages/note.dart index d3c0a9f2..352e77c2 100644 --- a/packages/harbour/lib/src/apps/notes/pages/note.dart +++ b/packages/harbour/lib/src/apps/notes/pages/note.dart @@ -73,6 +73,9 @@ class _NotesNotePageState extends State { }); WidgetsBinding.instance.addPostFrameCallback((final _) { + if (Provider.of(context, listen: false).canUseWakelock) { + Wakelock.enable(); + } if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.note.content!.isEmpty) { setState(() { @@ -94,6 +97,10 @@ class _NotesNotePageState extends State { return WillPopScope( onWillPop: () async { _update(); + + if (Provider.of(context, listen: false).canUseWakelock) { + await Wakelock.disable(); + } return true; }, child: Scaffold(