Skip to content

Commit

Permalink
Отображение название альбома трека на экране параметров трека.
Browse files Browse the repository at this point in the history
Затычка "Перейти к альбому".
  • Loading branch information
Zensonaton committed Dec 15, 2024
1 parent 0d70ecd commit b82e06e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Анимация загрузки трека (в мини-плеере) отображается не сразу, а после небольшой задержки.
- Пропуск копирования уже существующих (скопированных) треков при импорте настроек.
- Корректное отображение длительности трека в мини-плеере, если трек ещё не загружен.
- Отображение название альбома трека на экране параметров трека.

# Исправления

Expand Down
11 changes: 11 additions & 0 deletions lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@
"music_detailsAddToPlaylistTitle": "Добавить в плейлист",
"music_detailsPlayNextTitle": "Сыграть следующим",

"music_detailsGoToAlbumTitle": "Перейти к альбому",
"music_detailsGoToAlbumDescription": "Откроет страницу альбома «{title}»",
"@music_detailsGoToAlbumDescription": {
"placeholders": {
"title": {
"type": "String",
"description": "Название альбома, к которому переходит пользователь."
}
}
},

"music_detailsGeniusSearchTitle": "Поиск по Genius",
"music_detailsGeniusSearchDescription": "Текст песни, и прочая информация с Genius",

Expand Down
32 changes: 32 additions & 0 deletions lib/routes/home/music/bottom_audio_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ class BottomAudioOptionsDialog extends HookConsumerWidget {
context.pop();
}

void onGoToAlbumTap() {
if (newAudio.album == null) {
throw Exception("This audio doesn't have an album");
}

if (!networkRequiredDialog(ref, context)) return;

showWipDialog(context);
}

void onGeniusSearchTap() async {
if (hasGeniusInfo.value == null) {
throw Exception("Genius info isn't loaded yet");
Expand Down Expand Up @@ -405,6 +415,7 @@ class BottomAudioOptionsDialog extends HookConsumerWidget {
child: ListView(
controller: controller,
children: [
// Изображение трека.
Padding(
padding: const EdgeInsets.only(
left: 4,
Expand All @@ -417,6 +428,7 @@ class BottomAudioOptionsDialog extends HookConsumerWidget {
AudioTrackTile(
audio: newAudio,
allowTextSelection: true,
showAlbumName: true,
),
const Gap(8),

Expand Down Expand Up @@ -481,6 +493,26 @@ class BottomAudioOptionsDialog extends HookConsumerWidget {
onTap: onAddToQueueTap,
),

// TODO: Перейти к альбому.
if (kDebugMode)
ListTile(
leading: const Icon(
Icons.album,
),
title: Text(
l18n.music_detailsGoToAlbumTitle,
),
subtitle: newAudio.album != null
? Text(
l18n.music_detailsGoToAlbumDescription(
newAudio.album!.title,
),
)
: null,
enabled: newAudio.album != null,
onTap: onGoToAlbumTap,
),

// Поиск по Genius.
ListTile(
leading: hasGeniusInfo.value == null
Expand Down
20 changes: 20 additions & 0 deletions lib/widgets/audio_track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ class AudioTrackTitle extends ConsumerWidget {
/// Подпись трека. Может отсутствовать.
final String? subtitle;

/// Название альбома. Может отсутствовать.
final String? album;

/// Доступен ли трек.
///
/// Если false, то текст становится серым.
Expand All @@ -330,6 +333,7 @@ class AudioTrackTitle extends ConsumerWidget {
required this.title,
required this.artist,
this.subtitle,
this.album,
this.isAvailable = true,
this.isExplicit = true,
this.isSelected = false,
Expand Down Expand Up @@ -367,6 +371,17 @@ class AudioTrackTitle extends ConsumerWidget {
color: primaryTextColor.withValues(alpha: isAvailable ? 0.9 : 0.5),
),
),

// Название альбома, если это разрешено и альбом есть.
if (album != null)
Text(
album!,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color:
primaryTextColor.withValues(alpha: isAvailable ? 0.75 : 0.5),
),
),
],
);

Expand Down Expand Up @@ -602,6 +617,9 @@ class AudioTrackTile extends HookConsumerWidget {
/// Указывает, что в случае, если [isSelected] равен true, то у данного виджета будет эффект "свечения".
final bool glowIfSelected;

/// Указывает, что под именем исполнителя будет отображаться название альбома (если он присутствует).
final bool showAlbumName;

/// Указывает, что будут указаны иконки состояния справа (кэширования, локальной замены, недоступности, ...).
final bool showStatusIcons;

Expand Down Expand Up @@ -651,6 +669,7 @@ class AudioTrackTile extends HookConsumerWidget {
this.isPlaying = false,
this.isAvailable = true,
this.glowIfSelected = false,
this.showAlbumName = false,
this.showStatusIcons = true,
this.allowImageCache = true,
this.showDuration = true,
Expand Down Expand Up @@ -751,6 +770,7 @@ class AudioTrackTile extends HookConsumerWidget {
title: audio.title,
artist: audio.artist,
subtitle: audio.subtitle,
album: showAlbumName ? audio.album?.title : null,
isAvailable: isAvailable,
isExplicit: isExplicit,
isSelected: isSelected,
Expand Down

0 comments on commit b82e06e

Please sign in to comment.