diff --git a/lib/providers/error_notifier.dart b/lib/providers/error_notifier.dart index 4939054..68aa594 100644 --- a/lib/providers/error_notifier.dart +++ b/lib/providers/error_notifier.dart @@ -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, diff --git a/lib/providers/user_preferences.dart b/lib/providers/user_preferences.dart index 1c6b5a3..268e501 100644 --- a/lib/providers/user_preferences.dart +++ b/lib/providers/user_preferences.dart @@ -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); } } diff --git a/lib/screens/player/lyrics.dart b/lib/screens/player/lyrics.dart index e08a574..6104e56 100644 --- a/lib/screens/player/lyrics.dart +++ b/lib/screens/player/lyrics.dart @@ -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 { - 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( diff --git a/lib/screens/player/mini.dart b/lib/screens/player/mini.dart index 4e609c3..5fe142a 100644 --- a/lib/screens/player/mini.dart +++ b/lib/screens/player/mini.dart @@ -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 { - late final UserPreferencesProvider _preferences = Get.find(); - bool _wasMaximized = false; bool _areaActive = false; @@ -55,20 +51,6 @@ class _MiniPlayerScreenState extends State { } } - @override - void activate() { - super.activate(); - if (_preferences.state.value.playerWakelock) { - WakelockPlus.enable(); - } - } - - @override - void deactivate() { - super.deactivate(); - WakelockPlus.disable(); - } - @override void initState() { super.initState(); diff --git a/lib/screens/player/view.dart b/lib/screens/player/view.dart index 16fdf9b..f3ad594 100644 --- a/lib/screens/player/view.dart +++ b/lib/screens/player/view.dart @@ -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 { 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 { 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; diff --git a/macos/Podfile.lock b/macos/Podfile.lock index c40d270..1abf957 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -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 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 4dd6574..9924282 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -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"; diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index 6926603..e7473f5 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -2,6 +2,8 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.cs.allow-jit diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index 9a7b7e7..c69d0ca 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -2,6 +2,8 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.device.bluetooth diff --git a/pubspec.yaml b/pubspec.yaml index 6ef2c17..59faa04 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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