Skip to content

Commit

Permalink
feat: add support for album artists metadata (#1086)
Browse files Browse the repository at this point in the history
Closes #339
  • Loading branch information
Feichtmeier authored Dec 10, 2024
1 parent 52e9c5f commit c385852
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 129 deletions.
4 changes: 2 additions & 2 deletions lib/common/data/audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ class Audio {
artist: data.artist,
title: (data.title?.isNotEmpty == true ? data.title : fileName) ?? path,
album: data.album,
// TODO(#339): wait for https://github.com/ClementBeal/audio_metadata_reader/issues/13
albumArtist: data.artist,
albumArtist:
data.performers.isEmpty ? data.artist : data.performers.toString(),
discNumber: data.discNumber,
discTotal: data.totalDisc,
durationMs: data.duration?.inMilliseconds.toDouble(),
Expand Down
4 changes: 2 additions & 2 deletions lib/local_audio/local_audio_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import '../l10n/l10n.dart';
enum LocalAudioView {
titles,
artists,
// albumArtists,
albumArtists,
albums,
genres,
playlists;

String localize(AppLocalizations l10n) => switch (this) {
titles => l10n.titles,
artists => l10n.artists,
// albumArtists => l10n.albumArtists,
albumArtists => l10n.albumArtists,
albums => l10n.albums,
genres => l10n.genres,
playlists => l10n.playlists,
Expand Down
12 changes: 6 additions & 6 deletions lib/local_audio/view/local_audio_body.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';

import '../../common/data/audio.dart';
import '../local_audio_view.dart';
import 'album_view.dart';
import 'artists_view.dart';
import 'genres_view.dart';
import '../local_audio_view.dart';
import 'playlists_view.dart';
import 'titles_view.dart';

Expand Down Expand Up @@ -43,11 +43,11 @@ class LocalAudioBody extends StatelessWidget {
noResultMessage: noResultMessage,
noResultIcon: noResultIcon,
),
// LocalAudioView.albumArtists => AlbumArtistsView(
// albumArtists: albumArtists,
// noResultMessage: noResultMessage,
// noResultIcon: noResultIcon,
// ),
LocalAudioView.albumArtists => AlbumArtistsView(
albumArtists: albumArtists,
noResultMessage: noResultMessage,
noResultIcon: noResultIcon,
),
LocalAudioView.albums => AlbumsView(
albums: albums,
noResultMessage: noResultMessage,
Expand Down
58 changes: 32 additions & 26 deletions lib/local_audio/view/local_audio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:watch_it/watch_it.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/adaptive_container.dart';
import '../../common/view/header_bar.dart';
import '../../common/view/no_search_result_page.dart';
import '../../common/view/search_button.dart';
import '../../common/view/sliver_filter_app_bar.dart';
import '../../common/view/theme.dart';
Expand Down Expand Up @@ -83,39 +84,44 @@ class _LocalAudioPageState extends State<LocalAudioPage> {
builder: (context, constraints) {
return CustomScrollView(
slivers: [
SliverFilterAppBar(
padding: getAdaptiveHorizontalPadding(constraints: constraints)
.copyWith(
bottom: filterPanelPadding.bottom,
top: filterPanelPadding.top,
if (audios != null && audios.isNotEmpty)
SliverFilterAppBar(
padding:
getAdaptiveHorizontalPadding(constraints: constraints)
.copyWith(
bottom: filterPanelPadding.bottom,
top: filterPanelPadding.top,
),
title: const LocalAudioControlPanel(),
),
title: const LocalAudioControlPanel(),
),
SliverPadding(
padding: getAdaptiveHorizontalPadding(constraints: constraints)
.copyWith(
bottom: bottomPlayerPageGap,
),
sliver: LocalAudioBody(
localAudioView: localAudioView,
titles: audios,
albums: allAlbums,
artists: allArtists,
albumArtists: allAlbumArtists,
genres: allGenres,
playlists: playlists,
noResultIcon: const AnimatedEmoji(AnimatedEmojis.bird),
noResultMessage: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(context.l10n.noLocalTitlesFound),
const SizedBox(
height: kLargestSpace,
sliver: audios != null && audios.isEmpty
? SliverFillNoSearchResultPage(
icon: const AnimatedEmoji(AnimatedEmojis.bird),
message: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(context.l10n.noLocalTitlesFound),
const SizedBox(
height: kLargestSpace,
),
const SettingsButton.important(),
],
),
)
: LocalAudioBody(
localAudioView: localAudioView,
titles: audios,
albums: allAlbums,
artists: allArtists,
albumArtists: allAlbumArtists,
genres: allGenres,
playlists: playlists,
),
const SettingsButton.important(),
],
),
),
),
],
);
Expand Down
4 changes: 2 additions & 2 deletions lib/search/search_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../l10n/l10n.dart';
enum SearchType {
localTitle,
localArtist,
// localAlbumArtist,
localAlbumArtist,
localAlbum,
localGenreName,
localPlaylists,
Expand All @@ -17,7 +17,7 @@ enum SearchType {
String localize(AppLocalizations l10n) => switch (this) {
localTitle => l10n.titles,
localArtist => l10n.artists,
// localAlbumArtist => l10n.albumArtists,
localAlbumArtist => l10n.albumArtists,
localAlbum => l10n.albums,
localGenreName => l10n.genres,
localPlaylists => l10n.playlists,
Expand Down
2 changes: 1 addition & 1 deletion lib/search/view/sliver_local_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _SliverLocalSearchResultState extends State<SliverLocalSearchResult> {
(SearchModel m) => switch (m.searchType) {
SearchType.localAlbum => LocalAudioView.albums,
SearchType.localArtist => LocalAudioView.artists,
// SearchType.localAlbumArtist => LocalAudioView.albumArtists,
SearchType.localAlbumArtist => LocalAudioView.albumArtists,
SearchType.localTitle => LocalAudioView.titles,
SearchType.localGenreName => LocalAudioView.genres,
_ => LocalAudioView.playlists,
Expand Down
4 changes: 2 additions & 2 deletions lib/search/view/sliver_search_type_filter_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class SearchTypeFilterBar extends StatelessWidget with WatchItMixin {
' (${localSearchResult?.albums?.length ?? '0'})',
SearchType.localArtist =>
' (${localSearchResult?.artists?.length ?? '0'})',
// SearchType.localAlbumArtist =>
// ' (${localSearchResult?.albumArtists?.length ?? '0'})',
SearchType.localAlbumArtist =>
' (${localSearchResult?.albumArtists?.length ?? '0'})',
SearchType.localGenreName =>
' (${localSearchResult?.genres?.length ?? '0'})',
SearchType.localPlaylists =>
Expand Down
Loading

0 comments on commit c385852

Please sign in to comment.