Skip to content

Commit

Permalink
add and improve list placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Nov 8, 2024
1 parent 5fa083a commit eaab425
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/components/AlbumScreen/album_screen_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ class _SongsSliverListState extends State<SongsSliverList> {

@override
Widget build(BuildContext context) {
if (widget.childrenForList.isEmpty) {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
child: Text(
AppLocalizations.of(context)!.emptyTopTracksList,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
),
);
}
return SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
Expand Down
9 changes: 5 additions & 4 deletions lib/components/ArtistScreen/artist_screen_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class _ArtistScreenContentState extends State<ArtistScreenContent> {
builder: (context, snapshot) {
var songs = snapshot.data?.elementAtOrNull(0) ?? [];
var albums = snapshot.data?.elementAtOrNull(1) ?? [];
var topTracks = songs
.takeWhile((s) => (s.userData?.playCount ?? 0) > 0)
.take(5)
.toList();

return CustomScrollView(slivers: <Widget>[
SliverAppBar(
Expand Down Expand Up @@ -156,10 +160,7 @@ class _ArtistScreenContentState extends State<ArtistScreenContent> {
if (!isOffline &&
FinampSettingsHelper.finampSettings.showArtistsTopSongs)
SongsSliverList(
childrenForList: songs
.takeWhile((s) => (s.userData?.playCount ?? 0) > 0)
.take(5)
.toList(),
childrenForList: topTracks,
childrenForQueue: Future.value(songs),
showPlayCount: true,
isOnArtistScreen: true,
Expand Down
39 changes: 39 additions & 0 deletions lib/components/MusicScreen/music_screen_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import 'dart:async';
import 'dart:math';

import 'package:collection/collection.dart';
import 'package:finamp/components/Buttons/cta_medium.dart';
import 'package:finamp/components/Buttons/simple_button.dart';
import 'package:finamp/services/finamp_user_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
import 'package:get_it/get_it.dart';
import 'package:hive/hive.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

import '../../models/finamp_models.dart';
import '../../models/jellyfin_models.dart';
Expand Down Expand Up @@ -314,6 +318,39 @@ class _MusicScreenTabViewState extends State<MusicScreenTabView>
refreshHash = newRefreshHash;
}

final emptyListIndicator = Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
child: Column(
children: [
Text(
AppLocalizations.of(context)!.emptyFilteredListTitle,
style: TextStyle(
fontSize: 24,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
AppLocalizations.of(context)!.emptyFilteredListSubtitle,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
CTAMedium(
icon: TablerIcons.filter_x,
text: AppLocalizations.of(context)!.resetFiltersButton,
onPressed: () {
FinampSettingsHelper.setOnlyShowFavourite(false);
FinampSettingsHelper.setOnlyShowFullyDownloaded(false);
},
)
],
),
);

var tabContent = box.get("FinampSettings")!.contentViewType ==
ContentViewType.list ||
widget.tabContentType == TabContentType.songs
Expand Down Expand Up @@ -357,6 +394,7 @@ class _MusicScreenTabViewState extends State<MusicScreenTabView>
const FirstPageProgressIndicator(),
newPageProgressIndicatorBuilder: (_) =>
const NewPageProgressIndicator(),
noItemsFoundIndicatorBuilder: (_) => emptyListIndicator,
),
separatorBuilder: (context, index) => const SizedBox.shrink(),
)
Expand Down Expand Up @@ -387,6 +425,7 @@ class _MusicScreenTabViewState extends State<MusicScreenTabView>
const FirstPageProgressIndicator(),
newPageProgressIndicatorBuilder: (_) =>
const NewPageProgressIndicator(),
noItemsFoundIndicatorBuilder: (_) => emptyListIndicator,
),
gridDelegate: FinampSettingsHelper
.finampSettings.useFixedSizeGridTiles
Expand Down
16 changes: 16 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1773,5 +1773,21 @@
"showFeatureChipsToggleSubtitle": "Show advanced track info like codec, bit rate, and more on the player screen.",
"@showFeatureChipsToggleSubtitle": {
"description": "Subtitle for the setting that controls if the feature chips showing advanced track info are shown on the player screen"
},
"emptyTopTracksList": "You haven't listened to any track by this artist yet.",
"@emptyTopTracksList": {
"description": "Message shown as a placeholder when the top tracks list for an artist is empty"
},
"emptyFilteredListTitle": "No items found",
"@emptyFilteredListTitle": {
"description": "Message shown when a list of items is filtered and no items match the filter"
},
"emptyFilteredListSubtitle": "No items match the filter. Try turning off the filter or changing the search term.",
"@emptyFilteredListSubtitle": {
"description": "Message shown when a list of items is filtered and no items match the filter"
},
"resetFiltersButton": "Reset filters",
"@resetFiltersButton": {
"description": "Button to reset filters on a list of items"
}
}

0 comments on commit eaab425

Please sign in to comment.