diff options
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridFavoriteButtonView.swift')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridFavoriteButtonView.swift | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Sora/Views/Post/Grid/PostGridFavoriteButtonView.swift b/Sora/Views/Post/Grid/PostGridFavoriteButtonView.swift new file mode 100644 index 0000000..bd6b6f9 --- /dev/null +++ b/Sora/Views/Post/Grid/PostGridFavoriteButtonView.swift @@ -0,0 +1,45 @@ +import SwiftUI + +struct PostGridFavoriteButtonView: View { + @EnvironmentObject private var manager: BooruManager + @EnvironmentObject private var settings: SettingsManager + let post: BooruPost + + var isFavorited: Bool { + settings.isFavorite(postId: post.id, provider: manager.provider) + } + + var body: some View { + FavoriteMenuButtonView(post: post) + } +} + +#Preview { + let samplePost = BooruPost( + id: "123", + height: 100, + score: "10", + fileURL: URL(string: "https://example.com/file.jpg")!, + parentID: "0", + sampleURL: URL(string: "https://example.com/sample.jpg")!, + sampleWidth: 100, + sampleHeight: 100, + previewURL: URL(string: "https://example.com/preview.jpg")!, + rating: .safe, + tags: ["sample", "test"], + width: 100, + change: nil, + md5: "abc123", + creatorID: "1", + authorID: nil, + createdAt: Date(), + status: "active", + source: "", + previewWidth: 100, + previewHeight: 100 + ) + + PostGridFavoriteButtonView(post: samplePost) + .environmentObject(SettingsManager()) + .environmentObject(BooruManager(.yandere)) +} |