Skip to content

Commit

Permalink
chore: add not found for empty lists
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Dec 8, 2023
1 parent 24a2294 commit 581b241
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 36 deletions.
56 changes: 32 additions & 24 deletions lib/components/library/user_albums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:spotube/collections/fake.dart';

import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/album/album_card.dart';
import 'package:spotube/components/shared/fallbacks/not_found.dart';
import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart';
import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart';
import 'package:spotube/components/shared/waypoint.dart';
Expand Down Expand Up @@ -84,30 +85,37 @@ class UserAlbums extends HookConsumerWidget {
padding: const EdgeInsets.all(8.0),
controller: controller,
child: Skeletonizer(
enabled: albums.isEmpty,
child: Wrap(
runSpacing: 20,
alignment: WrapAlignment.center,
runAlignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
if (albums.isEmpty)
...List.generate(
10,
(index) => AlbumCard(FakeData.album),
),
for (final album in albums)
AlbumCard(
TypeConversionUtils.simpleAlbum_X_Album(album),
),
if (albums.isNotEmpty && albumsQuery.hasNextPage)
Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: albumsQuery.fetchNext,
child: AlbumCard(FakeData.album),
)
],
enabled: albums.isEmpty && albumsQuery.isLoadingNextPage,
child: Center(
child: Wrap(
runSpacing: 20,
alignment: WrapAlignment.center,
runAlignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
if (albums.isEmpty && albumsQuery.isLoadingNextPage)
...List.generate(
10,
(index) => AlbumCard(FakeData.album),
)
else if (albums.isEmpty)
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [NotFound()],
),
for (final album in albums)
AlbumCard(
TypeConversionUtils.simpleAlbum_X_Album(album),
),
if (albums.isNotEmpty && albumsQuery.hasNextPage)
Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: albumsQuery.fetchNext,
child: AlbumCard(FakeData.album),
)
],
),
),
),
),
Expand Down
19 changes: 15 additions & 4 deletions lib/components/library/user_artists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:spotube/collections/fake.dart';
import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart';
import 'package:spotube/components/artist/artist_card.dart';
import 'package:spotube/components/shared/fallbacks/not_found.dart';
import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/provider/authentication_provider.dart';
Expand Down Expand Up @@ -97,10 +98,20 @@ class UserArtists extends HookConsumerWidget {
children: artistQuery.isLoading
? List.generate(
10, (index) => ArtistCard(FakeData.artist))
: filteredArtists
.mapIndexed(
(index, artist) => ArtistCard(artist))
.toList(),
: filteredArtists.isEmpty
? [
const Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
NotFound(),
],
)
]
: filteredArtists
.mapIndexed((index, artist) =>
ArtistCard(artist))
.toList(),
),
),
),
Expand Down
10 changes: 10 additions & 0 deletions lib/components/library/user_local_tracks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:spotify/spotify.dart';
import 'package:spotube/collections/fake.dart';
import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/shared/expandable_search/expandable_search.dart';
import 'package:spotube/components/shared/fallbacks/not_found.dart';
import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart';
import 'package:spotube/components/shared/sort_tracks_dropdown.dart';
import 'package:spotube/components/shared/track_tile/track_tile.dart';
Expand Down Expand Up @@ -255,6 +256,15 @@ class UserLocalTracks extends HookConsumerWidget {
.toList();
}, [searchController.text, sortedTracks]);

if (!trackSnapshot.isLoading && filteredTracks.isEmpty) {
return const Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [NotFound()],
),
);
}

return Expanded(
child: RefreshIndicator(
onRefresh: () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:skeletonizer/skeletonizer.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/collections/fake.dart';
import 'package:spotube/components/shared/expandable_search/expandable_search.dart';
import 'package:spotube/components/shared/fallbacks/not_found.dart';
import 'package:spotube/components/shared/track_tile/track_tile.dart';
import 'package:spotube/components/shared/tracks_view/sections/body/track_view_body_headers.dart';
import 'package:spotube/components/shared/tracks_view/sections/body/use_is_user_playlist.dart';
Expand Down Expand Up @@ -92,14 +93,9 @@ class TrackViewBodySection extends HookConsumerWidget {
index: 0,
),
),
emptyBuilder: (context) => Skeletonizer(
enabled: true,
child: Column(
children: List.generate(
10,
(index) => TrackTile(track: FakeData.track, index: index),
),
),
emptyBuilder: (context) => const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [NotFound()],
),
itemBuilder: (context, index) {
final track = tracks[index];
Expand Down
1 change: 1 addition & 0 deletions lib/themes/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) {
),
sliderTheme: SliderThemeData(overlayShape: SliderComponentShape.noOverlay),
searchBarTheme: SearchBarThemeData(
textStyle: const MaterialStatePropertyAll(TextStyle(fontSize: 15)),
constraints: const BoxConstraints(maxWidth: double.infinity),
padding: const MaterialStatePropertyAll(EdgeInsets.all(8)),
backgroundColor: MaterialStatePropertyAll(
Expand Down

0 comments on commit 581b241

Please sign in to comment.