Version 1.4 - Translations, Like toasts Queue redesign.
This commit is contained in:
@@ -10,9 +10,12 @@ import SwiftUI
|
||||
/// Reusable heart button for toggling favorites on artists, albums, and tracks.
|
||||
struct FavoriteButton: View {
|
||||
@Environment(MAService.self) private var service
|
||||
@Environment(MAToastManager.self) private var toastManager
|
||||
let uri: String
|
||||
var size: CGFloat = 22
|
||||
var showInLight: Bool = false
|
||||
/// Display name shown in the toast when the item is liked. Pass nil to suppress the toast.
|
||||
var itemName: String? = nil
|
||||
|
||||
private var isFavorite: Bool {
|
||||
service.libraryManager.isFavorite(uri: uri)
|
||||
@@ -20,11 +23,19 @@ struct FavoriteButton: View {
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
let wasAlreadyFavorite = isFavorite
|
||||
Task {
|
||||
await service.libraryManager.toggleFavorite(
|
||||
uri: uri,
|
||||
currentlyFavorite: isFavorite
|
||||
currentlyFavorite: wasAlreadyFavorite
|
||||
)
|
||||
if let name = itemName {
|
||||
if wasAlreadyFavorite {
|
||||
toastManager.show(name, icon: "heart.slash", iconColor: .secondary)
|
||||
} else {
|
||||
toastManager.show(name, icon: "heart.fill", iconColor: .red)
|
||||
}
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: isFavorite ? "heart.fill" : "heart")
|
||||
|
||||
Reference in New Issue
Block a user