mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-16 17:05:17 +00:00

Configuration File Removals: .vscode/c_cpp_properties.json: Removed the entire configuration for C/C++ properties. .vscode/launch.json: Removed the Dart launch configurations for different environments and modes. .vscode/settings.json: Removed settings related to CMake, spell checking, file nesting, and Dart Flutter SDK path. .vscode/snippets.code-snippets: Removed code snippets for Dart, including PaginatedState and PaginatedNotifier templates. .vscode/tasks.json: Removed the tasks configuration file. Documentation Updates: CONTRIBUTION.md: Removed heart emoji from the introductory text. README.md: Updated the logo image and made minor text adjustments, including removing emojis and updating section titles. [1] [2] [3] [4] [5] Asset Removals: lib/collections/assets.gen.dart: Removed multiple unused asset references, including images related to Spotube logos and banners. [1] [2] [3] Minor Code Cleanups: cli/commands/build/linux.dart, cli/commands/build/windows.dart, cli/commands/translated.dart, cli/commands/untranslated.dart: Adjusted import statements for consistency. [1] [2] [3] [4] integration_test/app_test.dart: Removed an unnecessary blank line. lib/collections/routes.dart: Commented out the TrackRoute configuration.
80 lines
2.9 KiB
Dart
80 lines
2.9 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart' as material;
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:spotify/spotify.dart';
|
|
import 'package:spotube/components/track_presentation/presentation_props.dart';
|
|
import 'package:spotube/components/track_presentation/track_presentation.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/extensions/image.dart';
|
|
import 'package:spotube/provider/spotify/spotify.dart';
|
|
|
|
@RoutePage()
|
|
class AlbumPage extends HookConsumerWidget {
|
|
static const name = "album";
|
|
|
|
final AlbumSimple album;
|
|
final String id;
|
|
const AlbumPage({
|
|
super.key,
|
|
@PathParam("id") required this.id,
|
|
required this.album,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final tracks = ref.watch(albumTracksProvider(album));
|
|
final tracksNotifier = ref.watch(albumTracksProvider(album).notifier);
|
|
final favoriteAlbumsNotifier = ref.watch(favoriteAlbumsProvider.notifier);
|
|
final isSavedAlbum = ref.watch(albumsIsSavedProvider(album.id!));
|
|
|
|
return material.RefreshIndicator.adaptive(
|
|
onRefresh: () async {
|
|
ref.invalidate(albumTracksProvider(album));
|
|
ref.invalidate(favoriteAlbumsProvider);
|
|
ref.invalidate(albumsIsSavedProvider(album.id!));
|
|
},
|
|
child: TrackPresentation(
|
|
options: TrackPresentationOptions(
|
|
collection: album,
|
|
image: album.images.asUrlString(
|
|
placeholder: ImagePlaceholder.albumArt,
|
|
),
|
|
title: album.name!,
|
|
description:
|
|
"${context.l10n.released} • ${album.releaseDate} • ${album.artists!.first.name}",
|
|
tracks: tracks.asData?.value.items ?? [],
|
|
pagination: PaginationProps(
|
|
hasNextPage: tracks.asData?.value.hasMore ?? false,
|
|
isLoading: tracks.isLoading || tracks.isLoadingNextPage,
|
|
onFetchMore: () async {
|
|
await tracksNotifier.fetchMore();
|
|
},
|
|
onFetchAll: () async {
|
|
return tracksNotifier.fetchAll();
|
|
},
|
|
onRefresh: () async {
|
|
ref.invalidate(albumTracksProvider(album));
|
|
},
|
|
),
|
|
routePath: "/album/${album.id}",
|
|
shareUrl: album.externalUrls?.spotify ??
|
|
"https://open.spotify.com/album/${album.id}",
|
|
isLiked: isSavedAlbum.asData?.value ?? false,
|
|
owner: album.artists!.first.name,
|
|
onHeart: isSavedAlbum.asData?.value == null
|
|
? null
|
|
: () async {
|
|
if (isSavedAlbum.asData!.value) {
|
|
await favoriteAlbumsNotifier.removeFavorites([album.id!]);
|
|
} else {
|
|
await favoriteAlbumsNotifier.addFavorites([album.id!]);
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|