Skip to content

Commit

Permalink
feat: Add Go to Album option in track option #917
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Dec 2, 2023
1 parent f86d544 commit b0beeca
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
21 changes: 20 additions & 1 deletion lib/components/shared/track_tile/track_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/collections/spotube_icons.dart';
Expand All @@ -12,6 +13,7 @@ import 'package:spotube/components/shared/dialogs/playlist_add_track_dialog.dart
import 'package:spotube/components/shared/dialogs/track_details_dialog.dart';
import 'package:spotube/components/shared/heart_button.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/extensions/constrains.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/models/local_track.dart';
import 'package:spotube/provider/authentication_provider.dart';
Expand All @@ -22,6 +24,7 @@ import 'package:spotube/services/mutations/mutations.dart';
import 'package:spotube/utils/type_conversion_utils.dart';

enum TrackOptionValue {
album,
share,
addToPlaylist,
addToQueue,
Expand Down Expand Up @@ -79,9 +82,12 @@ class TrackOptions extends HookConsumerWidget {

@override
Widget build(BuildContext context, ref) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
final mediaQuery = MediaQuery.of(context);
final router = GoRouter.of(context);

final playlist = ref.watch(ProxyPlaylistNotifier.provider);
final playback = ref.watch(ProxyPlaylistNotifier.notifier);
final scaffoldMessenger = ScaffoldMessenger.of(context);
final auth = ref.watch(AuthenticationNotifier.provider);
ref.watch(downloadManagerProvider);
final downloadManager = ref.watch(downloadManagerProvider.notifier);
Expand Down Expand Up @@ -122,6 +128,12 @@ class TrackOptions extends HookConsumerWidget {
final adaptivePopSheetList = AdaptivePopSheetList<TrackOptionValue>(
onSelected: (value) async {
switch (value) {
case TrackOptionValue.album:
await router.push(
'/album/${track.album!.id}',
extra: track.album!,
);
break;
case TrackOptionValue.delete:
await File((track as LocalTrack).path).delete();
ref.refresh(localTracksProvider);
Expand Down Expand Up @@ -233,6 +245,13 @@ class TrackOptions extends HookConsumerWidget {
)
],
_ => [
if (mediaQuery.smAndDown)
PopSheetEntry(
value: TrackOptionValue.album,
leading: const Icon(SpotubeIcons.album),
title: Text(context.l10n.go_to_album),
subtitle: Text(track.album!.name!),
),
if (!playlist.containsTrack(track)) ...[
PopSheetEntry(
value: TrackOptionValue.addToQueue,
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,6 @@
"password": "Password",
"login": "Login",
"login_with_your_lastfm": "Login with your Last.fm account",
"scrobble_to_lastfm": "Scrobble to Last.fm"
"scrobble_to_lastfm": "Scrobble to Last.fm",
"go_to_album": "Go to Album"
}
62 changes: 61 additions & 1 deletion untranslated_messages.json
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
{}
{
"ar": [
"go_to_album"
],

"bn": [
"go_to_album"
],

"ca": [
"go_to_album"
],

"de": [
"go_to_album"
],

"es": [
"go_to_album"
],

"fa": [
"go_to_album"
],

"fr": [
"go_to_album"
],

"hi": [
"go_to_album"
],

"ja": [
"go_to_album"
],

"pl": [
"go_to_album"
],

"pt": [
"go_to_album"
],

"ru": [
"go_to_album"
],

"tr": [
"go_to_album"
],

"uk": [
"go_to_album"
],

"zh": [
"go_to_album"
]
}

0 comments on commit b0beeca

Please sign in to comment.