From 50fc20507080a9f104e8d084393e0eea89742786 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 15 Jul 2023 08:39:44 +0200 Subject: [PATCH] neon,neon_news,neon_notes: Wakelock is supported on every platform --- packages/neon/neon/lib/src/platform/android.dart | 1 - packages/neon/neon/lib/src/platform/linux.dart | 1 - packages/neon/neon/lib/src/platform/platform.dart | 3 --- packages/neon/neon_news/lib/pages/article.dart | 9 +++------ packages/neon/neon_notes/lib/neon_notes.dart | 1 - packages/neon/neon_notes/lib/pages/note.dart | 10 ++++------ 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/neon/neon/lib/src/platform/android.dart b/packages/neon/neon/lib/src/platform/android.dart index 53f96543..90dbf997 100644 --- a/packages/neon/neon/lib/src/platform/android.dart +++ b/packages/neon/neon/lib/src/platform/android.dart @@ -10,7 +10,6 @@ class AndroidNeonPlatform extends NeonPlatform { AndroidNeonPlatform() : super( canUseWebView: true, - canUseWakelock: true, canUseQuickActions: true, canUseSystemTray: false, canUseWindowManager: false, diff --git a/packages/neon/neon/lib/src/platform/linux.dart b/packages/neon/neon/lib/src/platform/linux.dart index 471c8db1..49fb669c 100644 --- a/packages/neon/neon/lib/src/platform/linux.dart +++ b/packages/neon/neon/lib/src/platform/linux.dart @@ -11,7 +11,6 @@ class LinuxNeonPlatform extends NeonPlatform { LinuxNeonPlatform() : super( canUseWebView: false, - canUseWakelock: false, canUseQuickActions: false, canUseSystemTray: true, canUseWindowManager: true, diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 1466c866..e41f67ba 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -23,7 +23,6 @@ Future getNeonPlatform() async { abstract class NeonPlatform { NeonPlatform({ required this.canUseWebView, - required this.canUseWakelock, required this.canUseQuickActions, required this.canUseSystemTray, required this.canUseWindowManager, @@ -36,8 +35,6 @@ abstract class NeonPlatform { final bool canUseWebView; - final bool canUseWakelock; - final bool canUseQuickActions; final bool canUseSystemTray; diff --git a/packages/neon/neon_news/lib/pages/article.dart b/packages/neon/neon_news/lib/pages/article.dart index d6413630..e2ccda80 100644 --- a/packages/neon/neon_news/lib/pages/article.dart +++ b/packages/neon/neon_news/lib/pages/article.dart @@ -34,9 +34,7 @@ class _NewsArticlePageState extends State { }); WidgetsBinding.instance.addPostFrameCallback((final _) { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.enable()); - } + unawaited(WakelockPlus.enable()); }); if (widget.useWebView) { @@ -102,9 +100,8 @@ class _NewsArticlePageState extends State { return true; } - if (mounted && Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.disable()); - } + unawaited(WakelockPlus.disable()); + return false; }, child: Scaffold( diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index 7547558d..7478f852 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -11,7 +11,6 @@ import 'package:go_router/go_router.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/blocs.dart'; import 'package:neon/models.dart'; -import 'package:neon/platform.dart'; import 'package:neon/settings.dart'; import 'package:neon/sort_box.dart'; import 'package:neon/utils.dart'; diff --git a/packages/neon/neon_notes/lib/pages/note.dart b/packages/neon/neon_notes/lib/pages/note.dart index 9a247d50..f5336f83 100644 --- a/packages/neon/neon_notes/lib/pages/note.dart +++ b/packages/neon/neon_notes/lib/pages/note.dart @@ -42,9 +42,8 @@ class _NotesNotePageState extends State { _titleController.addListener(() => _titleStreamController.add(_titleController.text)); WidgetsBinding.instance.addPostFrameCallback((final _) { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.enable()); - } + unawaited(WakelockPlus.enable()); + if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.bloc.initialContent.isEmpty) { setState(() { @@ -65,9 +64,8 @@ class _NotesNotePageState extends State { @override Widget build(final BuildContext context) => BackButtonListener( onBackButtonPressed: () async { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.disable()); - } + unawaited(WakelockPlus.disable()); + return false; }, child: Scaffold(