mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +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.
94 lines
2.6 KiB
Dart
94 lines
2.6 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:spotify/spotify.dart';
|
|
import 'package:spotube/components/heart_button/use_track_toggle_like.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/provider/authentication/authentication.dart';
|
|
import 'package:spotube/provider/spotify/spotify.dart';
|
|
|
|
class HeartButton extends HookConsumerWidget {
|
|
final bool isLiked;
|
|
final void Function()? onPressed;
|
|
final IconData? icon;
|
|
final Color? color;
|
|
final String? tooltip;
|
|
final ButtonVariance variance;
|
|
final ButtonSize size;
|
|
const HeartButton({
|
|
required this.isLiked,
|
|
required this.onPressed,
|
|
this.color,
|
|
this.tooltip,
|
|
this.icon,
|
|
this.variance = ButtonVariance.ghost,
|
|
this.size = ButtonSize.normal,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final auth = ref.watch(authenticationProvider);
|
|
|
|
if (auth.asData?.value == null) return const SizedBox.shrink();
|
|
|
|
return Tooltip(
|
|
tooltip: TooltipContainer(child: Text(tooltip ?? "")),
|
|
child: IconButton(
|
|
variance: variance,
|
|
size: size,
|
|
icon: AnimatedSwitcher(
|
|
switchInCurve: Curves.fastOutSlowIn,
|
|
switchOutCurve: Curves.fastOutSlowIn,
|
|
duration: const Duration(milliseconds: 300),
|
|
transitionBuilder: (child, animation) {
|
|
return ScaleTransition(
|
|
scale: animation,
|
|
child: child,
|
|
);
|
|
},
|
|
child: Icon(
|
|
icon ??
|
|
(isLiked
|
|
? Icons.favorite_rounded
|
|
: Icons.favorite_outline_rounded),
|
|
key: ValueKey(isLiked),
|
|
color: color ?? (isLiked ? color ?? Colors.red : null),
|
|
),
|
|
),
|
|
onPressed: onPressed,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class TrackHeartButton extends HookConsumerWidget {
|
|
final Track track;
|
|
const TrackHeartButton({
|
|
super.key,
|
|
required this.track,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final savedTracks = ref.watch(likedTracksProvider);
|
|
final me = ref.watch(meProvider);
|
|
final (:isLiked, :toggleTrackLike) = useTrackToggleLike(track, ref);
|
|
|
|
if (me.isLoading) {
|
|
return const CircularProgressIndicator();
|
|
}
|
|
|
|
return HeartButton(
|
|
tooltip: isLiked
|
|
? context.l10n.remove_from_favorites
|
|
: context.l10n.save_as_favorite,
|
|
isLiked: isLiked,
|
|
onPressed: savedTracks.asData?.value != null
|
|
? () {
|
|
toggleTrackLike(track);
|
|
}
|
|
: null,
|
|
);
|
|
}
|
|
}
|