-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: categories not showing for oauth exception, maximized window siz…
…e is stored feat: UserLibrary and UserAlbums using fl_query
- Loading branch information
Showing
8 changed files
with
88 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
import 'package:fl_query_hooks/fl_query_hooks.dart'; | ||
import 'package:flutter/material.dart' hide Image; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:spotube/components/Album/AlbumCard.dart'; | ||
import 'package:spotube/components/LoaderShimmers/ShimmerPlaybuttonCard.dart'; | ||
import 'package:spotube/provider/SpotifyDI.dart'; | ||
import 'package:spotube/provider/SpotifyRequests.dart'; | ||
import 'package:spotube/utils/type_conversion_utils.dart'; | ||
|
||
class UserAlbums extends ConsumerWidget { | ||
class UserAlbums extends HookConsumerWidget { | ||
const UserAlbums({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context, ref) { | ||
final albums = ref.watch(currentUserAlbumsQuery); | ||
final albumsQuery = useQuery( | ||
job: currentUserAlbumsQueryJob, | ||
externalData: ref.watch(spotifyProvider), | ||
); | ||
|
||
if (albumsQuery.isLoading || !albumsQuery.hasData) { | ||
return const Center(child: ShimmerPlaybuttonCard(count: 7)); | ||
} | ||
|
||
return albums.when( | ||
data: (data) => SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Wrap( | ||
spacing: 20, // gap between adjacent chips | ||
runSpacing: 20, // gap between lines | ||
alignment: WrapAlignment.center, | ||
children: data | ||
.map((album) => | ||
AlbumCard(TypeConversionUtils.simpleAlbum_X_Album(album))) | ||
.toList(), | ||
), | ||
return SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Wrap( | ||
spacing: 20, // gap between adjacent chips | ||
runSpacing: 20, // gap between lines | ||
alignment: WrapAlignment.center, | ||
children: albumsQuery.data! | ||
.map((album) => | ||
AlbumCard(TypeConversionUtils.simpleAlbum_X_Album(album))) | ||
.toList(), | ||
), | ||
), | ||
loading: () => const Center(child: ShimmerPlaybuttonCard(count: 7)), | ||
error: (_, __) => const Text("Failure is the pillar of success"), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,54 @@ | ||
import 'package:fl_query_hooks/fl_query_hooks.dart'; | ||
import 'package:flutter/material.dart' hide Image; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:spotify/spotify.dart'; | ||
import 'package:spotube/components/LoaderShimmers/ShimmerPlaybuttonCard.dart'; | ||
import 'package:spotube/components/Playlist/PlaylistCard.dart'; | ||
import 'package:spotube/components/Playlist/PlaylistCreateDialog.dart'; | ||
import 'package:spotube/provider/SpotifyDI.dart'; | ||
import 'package:spotube/provider/SpotifyRequests.dart'; | ||
|
||
class UserPlaylists extends ConsumerWidget { | ||
class UserPlaylists extends HookConsumerWidget { | ||
const UserPlaylists({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context, ref) { | ||
final playlists = ref.watch(currentUserPlaylistsQuery); | ||
final playlistsQuery = useQuery( | ||
job: currentUserPlaylistsQueryJob, | ||
externalData: ref.watch(spotifyProvider), | ||
); | ||
Image image = Image(); | ||
image.height = 300; | ||
image.width = 300; | ||
PlaylistSimple likedTracksPlaylist = PlaylistSimple(); | ||
likedTracksPlaylist.name = "Liked Tracks"; | ||
likedTracksPlaylist.type = "playlist"; | ||
likedTracksPlaylist.collaborative = false; | ||
likedTracksPlaylist.public = false; | ||
likedTracksPlaylist.id = "user-liked-tracks"; | ||
image.url = "https://t.scdn.co/images/3099b3803ad9496896c43f22fe9be8c4.png"; | ||
likedTracksPlaylist.images = [image]; | ||
|
||
return playlists.when( | ||
loading: () => const Center(child: ShimmerPlaybuttonCard(count: 7)), | ||
data: (data) { | ||
Image image = Image(); | ||
image.height = 300; | ||
image.width = 300; | ||
PlaylistSimple likedTracksPlaylist = PlaylistSimple(); | ||
likedTracksPlaylist.name = "Liked Tracks"; | ||
likedTracksPlaylist.type = "playlist"; | ||
likedTracksPlaylist.collaborative = false; | ||
likedTracksPlaylist.public = false; | ||
likedTracksPlaylist.id = "user-liked-tracks"; | ||
image.url = | ||
"https://t.scdn.co/images/3099b3803ad9496896c43f22fe9be8c4.png"; | ||
likedTracksPlaylist.images = [image]; | ||
return SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Wrap( | ||
spacing: 20, // gap between adjacent chips | ||
runSpacing: 20, // gap between lines | ||
alignment: WrapAlignment.center, | ||
children: [ | ||
const PlaylistCreateDialog(), | ||
PlaylistCard(likedTracksPlaylist), | ||
...data.map((playlist) => PlaylistCard(playlist)).toList(), | ||
], | ||
), | ||
), | ||
); | ||
}, | ||
error: (_, __) => const Text("Failure is the pillar of success")); | ||
if (playlistsQuery.isLoading || !playlistsQuery.hasData) { | ||
return const Center(child: ShimmerPlaybuttonCard(count: 7)); | ||
} | ||
|
||
return SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Wrap( | ||
spacing: 20, // gap between adjacent chips | ||
runSpacing: 20, // gap between lines | ||
alignment: WrapAlignment.center, | ||
children: [ | ||
const PlaylistCreateDialog(), | ||
PlaylistCard(likedTracksPlaylist), | ||
...playlistsQuery.data! | ||
.map((playlist) => PlaylistCard(playlist)) | ||
.toList(), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters