mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 06:31:26 +00:00
Fix thumbnail aspect ratio in video grid cells
Thumbnails were being stretched vertically due to incorrect aspect ratio handling. Fixed by: - Using .scaledToFill() on thumbnails to fill the container width - Constraining container to 16:9 aspect ratio with .fit mode - Adding matching aspect ratio to placeholder to prevent layout shift during loading This ensures thumbnails maintain proper proportions while filling the full cell width.
This commit is contained in:
@@ -429,17 +429,15 @@ struct VideoCell: View {
|
||||
}
|
||||
.lineLimit(1)
|
||||
}
|
||||
.aspectRatio(Constants.aspectRatio16x9, contentMode: .fit)
|
||||
}
|
||||
|
||||
private var thumbnailImage: some View {
|
||||
Group {
|
||||
VideoCellThumbnail(video: video)
|
||||
|
||||
VideoCellThumbnail(video: video)
|
||||
#if os(tvOS)
|
||||
.frame(minHeight: 320)
|
||||
.frame(minHeight: 320)
|
||||
#endif
|
||||
}
|
||||
.mask(RoundedRectangle(cornerRadius: thumbnailRoundingCornerRadius))
|
||||
.mask(RoundedRectangle(cornerRadius: thumbnailRoundingCornerRadius))
|
||||
}
|
||||
|
||||
private var time: String? {
|
||||
@@ -477,11 +475,13 @@ struct VideoCellThumbnail: View {
|
||||
private var thumbnails: ThumbnailsModel { .shared }
|
||||
|
||||
var body: some View {
|
||||
let (url, quality) = thumbnails.best(video)
|
||||
let aspectRatio = (quality == .default || quality == .high) ? Constants.aspectRatio4x3 : Constants.aspectRatio16x9
|
||||
let (url, _) = thumbnails.best(video)
|
||||
|
||||
ThumbnailView(url: url)
|
||||
.aspectRatio(aspectRatio, contentMode: .fill)
|
||||
.scaledToFill()
|
||||
.frame(maxWidth: .infinity)
|
||||
.aspectRatio(Constants.aspectRatio16x9, contentMode: .fit)
|
||||
.clipped()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user