Browse Source

neon,neon_news,neon_notes: Wakelock is supported on every platform

pull/475/head
jld3103 1 year ago
parent
commit
50fc205070
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 1
      packages/neon/neon/lib/src/platform/android.dart
  2. 1
      packages/neon/neon/lib/src/platform/linux.dart
  3. 3
      packages/neon/neon/lib/src/platform/platform.dart
  4. 5
      packages/neon/neon_news/lib/pages/article.dart
  5. 1
      packages/neon/neon_notes/lib/neon_notes.dart
  6. 6
      packages/neon/neon_notes/lib/pages/note.dart

1
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,

1
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,

3
packages/neon/neon/lib/src/platform/platform.dart

@ -23,7 +23,6 @@ Future<NeonPlatform> 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;

5
packages/neon/neon_news/lib/pages/article.dart

@ -34,9 +34,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
});
WidgetsBinding.instance.addPostFrameCallback((final _) {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.enable());
}
});
if (widget.useWebView) {
@ -102,9 +100,8 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
return true;
}
if (mounted && Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.disable());
}
return false;
},
child: Scaffold(

1
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';

6
packages/neon/neon_notes/lib/pages/note.dart

@ -42,9 +42,8 @@ class _NotesNotePageState extends State<NotesNotePage> {
_titleController.addListener(() => _titleStreamController.add(_titleController.text));
WidgetsBinding.instance.addPostFrameCallback((final _) {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.enable());
}
if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit ||
widget.bloc.initialContent.isEmpty) {
setState(() {
@ -65,9 +64,8 @@ class _NotesNotePageState extends State<NotesNotePage> {
@override
Widget build(final BuildContext context) => BackButtonListener(
onBackButtonPressed: () async {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.disable());
}
return false;
},
child: Scaffold(

Loading…
Cancel
Save