From cf3829e10362ebefb8d3f64282555f354f7be5ae Mon Sep 17 00:00:00 2001 From: Pato05 Date: Sun, 30 Jun 2024 03:00:04 +0200 Subject: [PATCH] fix lyrics button not showing --- lib/api/definitions.dart | 39 ++++++++++++++------------ lib/api/download/database.dart | 2 -- lib/api/pipe_api.dart | 3 +- lib/ui/player_screen.dart | 35 +++++++++++++---------- pubspec.lock | 51 +++++++++++++++++----------------- pubspec.yaml | 15 ++++++---- 6 files changed, 79 insertions(+), 66 deletions(-) diff --git a/lib/api/definitions.dart b/lib/api/definitions.dart index 8e880fb..04cba11 100644 --- a/lib/api/definitions.dart +++ b/lib/api/definitions.dart @@ -60,8 +60,8 @@ class Track extends DeezerMediaItem { int? trackNumber; @HiveField(7) bool? offline; - @HiveField(8) - Lyrics? lyrics; + //@HiveField(8) + //Lyrics? lyrics; @HiveField(9) bool? favorite; @HiveField(10) @@ -78,6 +78,8 @@ class Track extends DeezerMediaItem { @HiveField(13) List? playbackDetails; + @HiveField(14, defaultValue: false) + bool hasLyrics; Track({ required this.id, @@ -89,7 +91,7 @@ class Track extends DeezerMediaItem { this.artists, this.trackNumber, this.offline, - this.lyrics, + this.hasLyrics = false, this.favorite, this.diskNumber, this.explicit, @@ -123,7 +125,7 @@ class Track extends DeezerMediaItem { extras: { "playbackDetails": jsonEncode(playbackDetails), "thumb": albumArt!.thumb, - "lyrics": jsonEncode(lyrics!.toJson()), + "hasLyrics": hasLyrics, "albumId": album!.id, "trackToken": trackToken, "trackTokenExpiration": trackTokenExpiration, @@ -155,21 +157,21 @@ class Track extends DeezerMediaItem { } return Track( - title: mi.title, - artists: artists, - album: album, - id: mi.id, - albumArt: DeezerImageDetails.fromUrl(mi.artUri.toString()), - duration: mi.duration!, - playbackDetails: playbackDetails, - lyrics: mi.extras?['lyrics'] == null - ? null - : Lyrics.fromJson(jsonDecode(mi.extras!['lyrics']))); + title: mi.title, + artists: artists, + album: album, + id: mi.id, + albumArt: DeezerImageDetails.fromUrl(mi.artUri.toString()), + duration: mi.duration!, + playbackDetails: playbackDetails, + hasLyrics: mi.extras?['hasLyrics'] ?? false, + ); } //JSON factory Track.fromPrivateJson(Map json, {bool favorite = false}) { + print('TRACK JSON: $json'); String? title = json['SNG_TITLE']; if (json['VERSION'] != null && json['VERSION'] != '') { title = "${json['SNG_TITLE']} ${json['VERSION']}"; @@ -185,13 +187,14 @@ class Track extends DeezerMediaItem { .toList(), trackNumber: int.parse((json['TRACK_NUMBER'] ?? '0').toString()), playbackDetails: [json['MD5_ORIGIN'], json['MEDIA_VERSION']], - lyrics: Lyrics(id: json['LYRICS_ID'].toString()), favorite: favorite, diskNumber: int.parse(json['DISK_NUMBER'] ?? '1'), explicit: (json['EXPLICIT_LYRICS'].toString() == '1') ? true : false, addedDate: json['DATE_ADD'], trackToken: json['TRACK_TOKEN'], trackTokenExpiration: json['TRACK_TOKEN_EXPIRE'], + hasLyrics: json['HAS_LYRICS'] ?? + (json['LYRICS_ID'] != null && json['LYRICS_ID'] != 0), ); } Map toSQL({off = false}) => { @@ -203,7 +206,7 @@ class Track extends DeezerMediaItem { 'albumArt': albumArt!.full, 'trackNumber': trackNumber, 'offline': off ? 1 : 0, - 'lyrics': jsonEncode(lyrics!.toJson()), + 'hasLyrics': hasLyrics ? 1 : 0, 'favorite': (favorite ?? false) ? 1 : 0, 'diskNumber': diskNumber, 'explicit': (explicit ?? false) ? 1 : 0, @@ -219,7 +222,7 @@ class Track extends DeezerMediaItem { artists: List.generate(data['artists'].split(',').length, (i) => Artist(id: data['artists'].split(',')[i])), offline: (data['offline'] == 1) ? true : false, - lyrics: Lyrics.fromJson(jsonDecode(data['lyrics'])), + hasLyrics: data['hasLyrics'] == 1, favorite: (data['favorite'] == 1) ? true : false, diskNumber: data['diskNumber'], explicit: (data['explicit'] == 1) ? true : false, @@ -746,7 +749,7 @@ class Lyrics { bool sync; - Lyrics({this.id, this.writers, this.lyrics, this.sync = true}); + Lyrics({this.id, this.writers, required this.lyrics, this.sync = true}); static error() => Lyrics(id: null, writers: null, lyrics: [ Lyric( diff --git a/lib/api/download/database.dart b/lib/api/download/database.dart index be648f4..d943a02 100644 --- a/lib/api/download/database.dart +++ b/lib/api/download/database.dart @@ -52,7 +52,6 @@ class Track { ..albumArt = DeezerImageDetails.from(t.albumArt!) ..trackNumber = t.trackNumber ..offline = t.offline ?? false - ..lyrics = t.lyrics == null ? null : Lyrics.from(t.lyrics!) ..favorite = t.favorite ?? false ..diskNumber = t.diskNumber ..explicit = t.explicit ?? false; @@ -68,7 +67,6 @@ class Track { albumArt: albumArt.to(), trackNumber: trackNumber, offline: offline, - lyrics: lyrics?.to(), favorite: favorite, diskNumber: diskNumber, explicit: explicit, diff --git a/lib/api/pipe_api.dart b/lib/api/pipe_api.dart index b2468a8..fa208fe 100644 --- a/lib/api/pipe_api.dart +++ b/lib/api/pipe_api.dart @@ -50,6 +50,7 @@ class PipeAPI { _jwtExpiration = jwtData['exp']; } + /// Make a call to the Pipe GraphQL API Future> callApi( String operationName, String query, Map variables, {CancelToken? cancelToken}) async { @@ -67,7 +68,7 @@ class PipeAPI { return res.data; } - // -- Not working -- + /// -- Not working -- Future<(String, int)> getTrackToken(String trackId) async { final data = await callApi( 'TrackMediaToken', diff --git a/lib/ui/player_screen.dart b/lib/ui/player_screen.dart index b810dca..24f8a8c 100644 --- a/lib/ui/player_screen.dart +++ b/lib/ui/player_screen.dart @@ -56,9 +56,12 @@ class BackgroundProvider extends ChangeNotifier { final imageProvider = CachedNetworkImageProvider( mediaItem.extras!['thumb'] ?? mediaItem.artUri.toString(), cacheManager: cacheManager); + print(mediaItem.extras!['thumb'] ?? mediaItem.artUri.toString()); //Run in isolate _palette = await PaletteGenerator.fromImageProvider(imageProvider); - _dominantColor = _palette!.dominantColor!.color; + _dominantColor = _palette!.dominantColor?.color ?? + _palette!.lightVibrantColor?.color ?? + _palette!.colors.firstOrNull; _imageProvider = settings.blurPlayerBackground ? imageProvider : null; if (!_isDisposed) notifyListeners(); } @@ -170,8 +173,12 @@ class PlayerScreenBackground extends StatelessWidget { child: provider.imageProvider != null ? DecoratedBox( decoration: BoxDecoration( - color: Color.lerp(provider.dominantColor, - isLightMode ? Colors.white : Colors.black, 0.75)), + color: provider.dominantColor == null + ? Theme.of(context).colorScheme.surface + : Color.lerp( + provider.dominantColor, + isLightMode ? Colors.white : Colors.black, + 0.75)), child: ImageFiltered( imageFilter: ImageFilter.blur( tileMode: TileMode.decal, @@ -194,12 +201,17 @@ class PlayerScreenBackground extends StatelessWidget { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - if (provider.dominantColor != null) - Color.lerp(provider.dominantColor, - isLightMode ? Colors.white : Colors.black, 0.5)!, - Theme.of(context).colorScheme.background, + provider.dominantColor == null + ? Theme.of(context).colorScheme.surface + : Color.lerp( + provider.dominantColor, + isLightMode ? Colors.white : Colors.black, + 0.5)!, + Theme.of(context).colorScheme.surface, ], - stops: const [0.0, 0.6], + stops: provider.dominantColor == null + ? null + : const [0.0, 0.6], )), )), child, @@ -1057,12 +1069,7 @@ class _BigAlbumArtState extends State with WidgetsBindingObserver { return const SizedBox.shrink(); } - final l = snapshot.data!.extras?['lyrics'] == null - ? null - : Lyrics.fromJson( - jsonDecode(snapshot.data!.extras!['lyrics'])); - - if (l == null || l.id == null || l.id == '0') { + if (snapshot.data!.extras?['hasLyrics'] ?? false) { return const SizedBox.shrink(); } diff --git a/pubspec.lock b/pubspec.lock index b744244..2832734 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -261,10 +261,10 @@ packages: dependency: "direct main" description: name: country_pickers - sha256: a71df4a061b25f07b202a881c43a057edc842a30b3410d511382103c68afebc2 + sha256: b10f6618fa64fbba02ffc4ad1b84dc0ca071cc206e5376de1698bddd980b355a url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "3.0.1" cross_file: dependency: transitive description: @@ -374,10 +374,10 @@ packages: dependency: "direct main" description: name: fading_edge_scrollview - sha256: c25c2231652ce774cc31824d0112f11f653881f43d7f5302c05af11942052031 + sha256: "1f84fe3ea8e251d00d5735e27502a6a250e4aa3d3b330d3fdcb475af741464ef" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "4.1.1" fake_async: dependency: transitive description: @@ -707,10 +707,10 @@ packages: dependency: "direct main" description: name: i18n_extension - sha256: "514fca4f34e8eb73cd29d2938225bf139b1ff3cede462c0b2875f60f470e64b2" + sha256: "296f7b091b9feb7f682360cece9c335f5b0b35121c31bd1993bbdcf1985c272e" url: "https://pub.dev" source: hosted - version: "11.0.12" + version: "12.0.1" i18n_extension_core: dependency: transitive description: @@ -747,10 +747,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" io: dependency: transitive description: @@ -843,26 +843,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -882,10 +882,11 @@ packages: marquee: dependency: "direct main" description: - name: marquee - sha256: "4b5243d2804373bdc25fc93d42c3b402d6ec1f4ee8d0bb72276edd04ae7addb8" - url: "https://pub.dev" - source: hosted + path: "." + ref: "support-flutter-3.22.0" + resolved-ref: "620dec0fd2ce24801fa8f08c5e04280fc4bb75b6" + url: "https://github.com/abisoftinc/marquee.git" + source: git version: "2.2.3" matcher: dependency: transitive @@ -939,10 +940,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -1466,10 +1467,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" time: dependency: transitive description: @@ -1650,10 +1651,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" wakelock_plus: dependency: "direct main" description: @@ -1775,5 +1776,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.4.0 <4.0.0" flutter: ">=3.19.2" diff --git a/pubspec.yaml b/pubspec.yaml index 043abe0..b08e8cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,20 +21,23 @@ dependencies: path: ^1.6.4 sqflite: ^2.0.0+3 permission_handler: ^11.2.0 - intl: ^0.18.1 + intl: ^0.19.0 filesize: ^2.0.1 fluttertoast: ^8.0.8 - palette_generator: ^0.3.0 + palette_generator: ^0.3.3+3 flutter_material_color_picker: ^1.0.5 - country_pickers: ^2.0.0 + country_pickers: ^3.0.1 flutter_local_notifications: ^17.1.0 collection: ^1.17.1 html: ^0.15.4 flutter_screenutil: ^5.0.0+2 - marquee: ^2.2.0 + marquee: + git: + url: https://github.com/abisoftinc/marquee.git + ref: 'support-flutter-3.22.0' flutter_cache_manager: ^3.3.2 cached_network_image: ^3.1.0 - i18n_extension: ^11.0.12 + i18n_extension: ^12.0.1 url_launcher: ^6.0.5 uni_links: ^0.5.1 numberpicker: ^2.1.1 @@ -99,7 +102,7 @@ dependencies: ^2.4.1 mini_music_visualizer: git: https://github.com/Pato05/mini_music_visualizer.git - fading_edge_scrollview: ^3.0.0 + fading_edge_scrollview: ^4.1.1 scroll_to_index: ^3.0.1 #deezcryptor: #path: deezcryptor/