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() AndroidNeonPlatform()
: super( : super(
canUseWebView: true, canUseWebView: true,
canUseWakelock: true,
canUseQuickActions: true, canUseQuickActions: true,
canUseSystemTray: false, canUseSystemTray: false,
canUseWindowManager: false, canUseWindowManager: false,

1
packages/neon/neon/lib/src/platform/linux.dart

@ -11,7 +11,6 @@ class LinuxNeonPlatform extends NeonPlatform {
LinuxNeonPlatform() LinuxNeonPlatform()
: super( : super(
canUseWebView: false, canUseWebView: false,
canUseWakelock: false,
canUseQuickActions: false, canUseQuickActions: false,
canUseSystemTray: true, canUseSystemTray: true,
canUseWindowManager: true, canUseWindowManager: true,

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

@ -23,7 +23,6 @@ Future<NeonPlatform> getNeonPlatform() async {
abstract class NeonPlatform { abstract class NeonPlatform {
NeonPlatform({ NeonPlatform({
required this.canUseWebView, required this.canUseWebView,
required this.canUseWakelock,
required this.canUseQuickActions, required this.canUseQuickActions,
required this.canUseSystemTray, required this.canUseSystemTray,
required this.canUseWindowManager, required this.canUseWindowManager,
@ -36,8 +35,6 @@ abstract class NeonPlatform {
final bool canUseWebView; final bool canUseWebView;
final bool canUseWakelock;
final bool canUseQuickActions; final bool canUseQuickActions;
final bool canUseSystemTray; 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 _) { WidgetsBinding.instance.addPostFrameCallback((final _) {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.enable()); unawaited(WakelockPlus.enable());
}
}); });
if (widget.useWebView) { if (widget.useWebView) {
@ -102,9 +100,8 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
return true; return true;
} }
if (mounted && Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.disable()); unawaited(WakelockPlus.disable());
}
return false; return false;
}, },
child: Scaffold( 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:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:neon/blocs.dart'; import 'package:neon/blocs.dart';
import 'package:neon/models.dart'; import 'package:neon/models.dart';
import 'package:neon/platform.dart';
import 'package:neon/settings.dart'; import 'package:neon/settings.dart';
import 'package:neon/sort_box.dart'; import 'package:neon/sort_box.dart';
import 'package:neon/utils.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)); _titleController.addListener(() => _titleStreamController.add(_titleController.text));
WidgetsBinding.instance.addPostFrameCallback((final _) { WidgetsBinding.instance.addPostFrameCallback((final _) {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.enable()); unawaited(WakelockPlus.enable());
}
if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit ||
widget.bloc.initialContent.isEmpty) { widget.bloc.initialContent.isEmpty) {
setState(() { setState(() {
@ -65,9 +64,8 @@ class _NotesNotePageState extends State<NotesNotePage> {
@override @override
Widget build(final BuildContext context) => BackButtonListener( Widget build(final BuildContext context) => BackButtonListener(
onBackButtonPressed: () async { onBackButtonPressed: () async {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
unawaited(WakelockPlus.disable()); unawaited(WakelockPlus.disable());
}
return false; return false;
}, },
child: Scaffold( child: Scaffold(

Loading…
Cancel
Save