🐛 Fix wakelock doesn't work
This commit is contained in:
		@@ -13,6 +13,7 @@ class ErrorNotifier extends GetxController {
 | 
			
		||||
 | 
			
		||||
  void showError(String msg) {
 | 
			
		||||
    showing.value = MaterialBanner(
 | 
			
		||||
      dividerColor: Colors.transparent,
 | 
			
		||||
      leading: const Icon(Icons.error),
 | 
			
		||||
      content: Column(
 | 
			
		||||
        crossAxisAlignment: CrossAxisAlignment.start,
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import 'package:spotify/spotify.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:path/path.dart';
 | 
			
		||||
import 'package:path_provider/path_provider.dart';
 | 
			
		||||
import 'package:wakelock_plus/wakelock_plus.dart';
 | 
			
		||||
 | 
			
		||||
typedef UserPreferences = PreferencesTableData;
 | 
			
		||||
 | 
			
		||||
@@ -48,6 +49,8 @@ class UserPreferencesProvider extends GetxController {
 | 
			
		||||
        .listen((event) async {
 | 
			
		||||
      state.value = event;
 | 
			
		||||
 | 
			
		||||
      await WakelockPlus.toggle(enable: state.value.playerWakelock);
 | 
			
		||||
 | 
			
		||||
      await audioPlayer.setAudioNormalization(state.value.normalizeAudio);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
@@ -173,5 +176,6 @@ class UserPreferencesProvider extends GetxController {
 | 
			
		||||
 | 
			
		||||
  void setPlayerWakelock(bool wakelock) {
 | 
			
		||||
    setData(PreferencesTableCompanion(playerWakelock: Value(wakelock)));
 | 
			
		||||
    WakelockPlus.toggle(enable: wakelock);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,8 @@ import 'dart:math';
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:get/get.dart';
 | 
			
		||||
import 'package:rhythm_box/providers/user_preferences.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/lyrics/synced_lyrics.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/player/bottom_player.dart';
 | 
			
		||||
import 'package:wakelock_plus/wakelock_plus.dart';
 | 
			
		||||
 | 
			
		||||
class LyricsScreen extends StatefulWidget {
 | 
			
		||||
  const LyricsScreen({super.key});
 | 
			
		||||
@@ -15,22 +13,6 @@ class LyricsScreen extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _LyricsScreenState extends State<LyricsScreen> {
 | 
			
		||||
  late final UserPreferencesProvider _preferences = Get.find();
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void activate() {
 | 
			
		||||
    super.activate();
 | 
			
		||||
    if (_preferences.state.value.playerWakelock) {
 | 
			
		||||
      WakelockPlus.enable();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void deactivate() {
 | 
			
		||||
    super.deactivate();
 | 
			
		||||
    WakelockPlus.disable();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Material(
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,11 @@ import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:get/get.dart';
 | 
			
		||||
import 'package:go_router/go_router.dart';
 | 
			
		||||
import 'package:rhythm_box/platform.dart';
 | 
			
		||||
import 'package:rhythm_box/providers/user_preferences.dart';
 | 
			
		||||
import 'package:rhythm_box/screens/player/queue.dart';
 | 
			
		||||
import 'package:rhythm_box/screens/player/siblings.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/lyrics/synced_lyrics.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/player/bottom_player.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/player/devices.dart';
 | 
			
		||||
import 'package:wakelock_plus/wakelock_plus.dart';
 | 
			
		||||
import 'package:window_manager/window_manager.dart';
 | 
			
		||||
 | 
			
		||||
class MiniPlayerScreen extends StatefulWidget {
 | 
			
		||||
@@ -21,8 +19,6 @@ class MiniPlayerScreen extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _MiniPlayerScreenState extends State<MiniPlayerScreen> {
 | 
			
		||||
  late final UserPreferencesProvider _preferences = Get.find();
 | 
			
		||||
 | 
			
		||||
  bool _wasMaximized = false;
 | 
			
		||||
 | 
			
		||||
  bool _areaActive = false;
 | 
			
		||||
@@ -55,20 +51,6 @@ class _MiniPlayerScreenState extends State<MiniPlayerScreen> {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void activate() {
 | 
			
		||||
    super.activate();
 | 
			
		||||
    if (_preferences.state.value.playerWakelock) {
 | 
			
		||||
      WakelockPlus.enable();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void deactivate() {
 | 
			
		||||
    super.deactivate();
 | 
			
		||||
    WakelockPlus.disable();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
    super.initState();
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@ import 'package:google_fonts/google_fonts.dart';
 | 
			
		||||
import 'package:media_kit/media_kit.dart';
 | 
			
		||||
import 'package:rhythm_box/providers/audio_player.dart';
 | 
			
		||||
import 'package:rhythm_box/providers/auth.dart';
 | 
			
		||||
import 'package:rhythm_box/providers/user_preferences.dart';
 | 
			
		||||
import 'package:rhythm_box/screens/player/queue.dart';
 | 
			
		||||
import 'package:rhythm_box/screens/player/siblings.dart';
 | 
			
		||||
import 'package:rhythm_box/services/artist.dart';
 | 
			
		||||
@@ -21,7 +20,6 @@ import 'package:rhythm_box/services/audio_services/image.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/lyrics/synced_lyrics.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/tracks/heart_button.dart';
 | 
			
		||||
import 'package:rhythm_box/widgets/tracks/querying_track_info.dart';
 | 
			
		||||
import 'package:wakelock_plus/wakelock_plus.dart';
 | 
			
		||||
 | 
			
		||||
class PlayerScreen extends StatefulWidget {
 | 
			
		||||
  const PlayerScreen({super.key});
 | 
			
		||||
@@ -34,7 +32,6 @@ class _PlayerScreenState extends State<PlayerScreen> {
 | 
			
		||||
  late final AudioPlayerProvider _playback = Get.find();
 | 
			
		||||
  late final QueryingTrackInfoProvider _query = Get.find();
 | 
			
		||||
  late final AuthenticationProvider _auth = Get.find();
 | 
			
		||||
  late final UserPreferencesProvider _preferences = Get.find();
 | 
			
		||||
 | 
			
		||||
  String? get _albumArt =>
 | 
			
		||||
      (_playback.state.value.activeTrack?.album?.images).asUrlString(
 | 
			
		||||
@@ -59,20 +56,6 @@ class _PlayerScreenState extends State<PlayerScreen> {
 | 
			
		||||
 | 
			
		||||
  static const double maxAlbumSize = 360;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void activate() {
 | 
			
		||||
    super.activate();
 | 
			
		||||
    if (_preferences.state.value.playerWakelock) {
 | 
			
		||||
      WakelockPlus.enable();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void deactivate() {
 | 
			
		||||
    super.deactivate();
 | 
			
		||||
    WakelockPlus.disable();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    final size = MediaQuery.of(context).size;
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,8 @@ PODS:
 | 
			
		||||
    - sqlite3/rtree
 | 
			
		||||
  - url_launcher_macos (0.0.1):
 | 
			
		||||
    - FlutterMacOS
 | 
			
		||||
  - wakelock_plus (0.0.1):
 | 
			
		||||
    - FlutterMacOS
 | 
			
		||||
  - window_manager (0.2.0):
 | 
			
		||||
    - FlutterMacOS
 | 
			
		||||
 | 
			
		||||
@@ -74,6 +76,7 @@ DEPENDENCIES:
 | 
			
		||||
  - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
 | 
			
		||||
  - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`)
 | 
			
		||||
  - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
 | 
			
		||||
  - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`)
 | 
			
		||||
  - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
 | 
			
		||||
 | 
			
		||||
SPEC REPOS:
 | 
			
		||||
@@ -116,6 +119,8 @@ EXTERNAL SOURCES:
 | 
			
		||||
    :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos
 | 
			
		||||
  url_launcher_macos:
 | 
			
		||||
    :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
 | 
			
		||||
  wakelock_plus:
 | 
			
		||||
    :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos
 | 
			
		||||
  window_manager:
 | 
			
		||||
    :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
 | 
			
		||||
 | 
			
		||||
@@ -139,6 +144,7 @@ SPEC CHECKSUMS:
 | 
			
		||||
  sqlite3: 0bb0e6389d824e40296f531b858a2a0b71c0d2fb
 | 
			
		||||
  sqlite3_flutter_libs: 5ca46c1a04eddfbeeb5b16566164aa7ad1616e7b
 | 
			
		||||
  url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
 | 
			
		||||
  wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
 | 
			
		||||
  window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
 | 
			
		||||
 | 
			
		||||
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
 | 
			
		||||
 
 | 
			
		||||
@@ -574,11 +574,9 @@
 | 
			
		||||
				CLANG_ENABLE_MODULES = YES;
 | 
			
		||||
				CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
 | 
			
		||||
				CODE_SIGN_IDENTITY = "Apple Development";
 | 
			
		||||
				"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
 | 
			
		||||
				CODE_SIGN_STYLE = Manual;
 | 
			
		||||
				CODE_SIGN_STYLE = Automatic;
 | 
			
		||||
				COMBINE_HIDPI_IMAGES = YES;
 | 
			
		||||
				DEVELOPMENT_TEAM = "";
 | 
			
		||||
				"DEVELOPMENT_TEAM[sdk=macosx*]" = W7HPZ53V6B;
 | 
			
		||||
				DEVELOPMENT_TEAM = W7HPZ53V6B;
 | 
			
		||||
				INFOPLIST_FILE = Runner/Info.plist;
 | 
			
		||||
				INFOPLIST_KEY_CFBundleDisplayName = GroovyBox;
 | 
			
		||||
				INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
 | 
			
		||||
@@ -714,11 +712,9 @@
 | 
			
		||||
				CLANG_ENABLE_MODULES = YES;
 | 
			
		||||
				CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
 | 
			
		||||
				CODE_SIGN_IDENTITY = "Apple Development";
 | 
			
		||||
				"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
 | 
			
		||||
				CODE_SIGN_STYLE = Manual;
 | 
			
		||||
				CODE_SIGN_STYLE = Automatic;
 | 
			
		||||
				COMBINE_HIDPI_IMAGES = YES;
 | 
			
		||||
				DEVELOPMENT_TEAM = "";
 | 
			
		||||
				"DEVELOPMENT_TEAM[sdk=macosx*]" = W7HPZ53V6B;
 | 
			
		||||
				DEVELOPMENT_TEAM = W7HPZ53V6B;
 | 
			
		||||
				INFOPLIST_FILE = Runner/Info.plist;
 | 
			
		||||
				INFOPLIST_KEY_CFBundleDisplayName = GroovyBox;
 | 
			
		||||
				INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
 | 
			
		||||
@@ -741,11 +737,9 @@
 | 
			
		||||
				CLANG_ENABLE_MODULES = YES;
 | 
			
		||||
				CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
 | 
			
		||||
				CODE_SIGN_IDENTITY = "Apple Development";
 | 
			
		||||
				"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
 | 
			
		||||
				CODE_SIGN_STYLE = Manual;
 | 
			
		||||
				CODE_SIGN_STYLE = Automatic;
 | 
			
		||||
				COMBINE_HIDPI_IMAGES = YES;
 | 
			
		||||
				DEVELOPMENT_TEAM = "";
 | 
			
		||||
				"DEVELOPMENT_TEAM[sdk=macosx*]" = W7HPZ53V6B;
 | 
			
		||||
				DEVELOPMENT_TEAM = W7HPZ53V6B;
 | 
			
		||||
				INFOPLIST_FILE = Runner/Info.plist;
 | 
			
		||||
				INFOPLIST_KEY_CFBundleDisplayName = GroovyBox;
 | 
			
		||||
				INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 | 
			
		||||
<plist version="1.0">
 | 
			
		||||
<dict>
 | 
			
		||||
	<key>com.apple.developer.aps-environment</key>
 | 
			
		||||
	<string>development</string>
 | 
			
		||||
	<key>com.apple.security.app-sandbox</key>
 | 
			
		||||
	<true/>
 | 
			
		||||
	<key>com.apple.security.cs.allow-jit</key>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 | 
			
		||||
<plist version="1.0">
 | 
			
		||||
<dict>
 | 
			
		||||
	<key>com.apple.developer.aps-environment</key>
 | 
			
		||||
	<string>development</string>
 | 
			
		||||
	<key>com.apple.security.app-sandbox</key>
 | 
			
		||||
	<true/>
 | 
			
		||||
	<key>com.apple.security.device.bluetooth</key>
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
 | 
			
		||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 | 
			
		||||
# In Windows, build-name is used as the major, minor, and patch parts
 | 
			
		||||
# of the product and file versions while build-number is used as the build suffix.
 | 
			
		||||
version: 1.0.0+7
 | 
			
		||||
version: 1.0.0+8
 | 
			
		||||
 | 
			
		||||
environment:
 | 
			
		||||
  sdk: ^3.5.0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user