mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix thumbnails
This commit is contained in:
parent
5e0f13cace
commit
e3daa738ce
@ -3,38 +3,18 @@ import SwiftUI
|
||||
|
||||
struct ThumbnailView: View {
|
||||
var url: URL?
|
||||
|
||||
@ObservedObject private var imageManager = ImageManager()
|
||||
private var thumbnails = ThumbnailsModel.shared
|
||||
|
||||
init(url: URL? = nil) {
|
||||
self.url = url
|
||||
}
|
||||
@ObservedObject private var thumbnails = ThumbnailsModel.shared
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if imageManager.image != nil {
|
||||
Group {
|
||||
#if os(macOS)
|
||||
Image(nsImage: imageManager.image!)
|
||||
.resizable()
|
||||
#else
|
||||
Image(uiImage: imageManager.image!)
|
||||
.resizable()
|
||||
#endif
|
||||
WebImage(url: url)
|
||||
.resizable()
|
||||
.onFailure { _ in
|
||||
if let url {
|
||||
thumbnails.insertUnloadable(url)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
.placeholder {
|
||||
Rectangle().fill(Color("PlaceholderColor"))
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
guard let url else { return }
|
||||
|
||||
self.imageManager.setOnFailure { _ in
|
||||
self.thumbnails.insertUnloadable(url)
|
||||
}
|
||||
self.imageManager.load(url: url)
|
||||
}
|
||||
.onDisappear { self.imageManager.cancel() }
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ struct VideoCell: View {
|
||||
.contextMenu {
|
||||
VideoContextMenuView(video: video)
|
||||
}
|
||||
.id(video.videoID)
|
||||
}
|
||||
|
||||
private var thumbnailRoundingCornerRadius: Double {
|
||||
|
Loading…
Reference in New Issue
Block a user