From 18b7b4ee4800be5a2e1c87f3e3cba707ab4dd2b0 Mon Sep 17 00:00:00 2001 From: Mustapha-Tarek Ben Lechhab Date: Tue, 18 Feb 2025 16:11:22 +0100 Subject: [PATCH] PLAYNEXT-1271 Fix media cell layout for different scenario --- Application/Sources/UI/Views/MediaCell.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Application/Sources/UI/Views/MediaCell.swift b/Application/Sources/UI/Views/MediaCell.swift index e5cc84c7c..135f35ccf 100644 --- a/Application/Sources/UI/Views/MediaCell.swift +++ b/Application/Sources/UI/Views/MediaCell.swift @@ -79,6 +79,18 @@ struct MediaCell: View, PrimaryColorSettable, SecondaryColorSettable { } } + private var visualViewContentMode: ImageView.ContentMode { + if ApplicationConfiguration.shared.arePodcastImagesEnabled, media?.mediaType == .audio, aspectRatio == MediaSquareCellSize.defaultAspectRatio { + .aspectFill + } else { + .aspectFit + } + } + + private var isSmallAudioSquaredCell: Bool { + ApplicationConfiguration.shared.arePodcastImagesEnabled && media?.mediaType == .audio && direction == .horizontal + } + init(media: SRGMedia?, style: Style, layout: Layout = .adaptive, action: (() -> Void)? = nil) { self.media = media self.style = style @@ -103,11 +115,12 @@ struct MediaCell: View, PrimaryColorSettable, SecondaryColorSettable { #else Stack(direction: .vertical, spacing: 0) { Stack(direction: direction, spacing: 0) { - MediaVisualView(media: media, size: .small, embeddedDirection: direction) + MediaVisualView(media: media, size: .small, contentMode: visualViewContentMode, embeddedDirection: direction) .aspectRatio(aspectRatio, contentMode: contentMode) .selectionAppearance(when: hasSelectionAppearance, while: isEditing) .cornerRadius(LayoutStandardViewCornerRadius) .redactable() + .layoutPriority(isSmallAudioSquaredCell ? 0 : 1) DescriptionView(media: media, style: style, embeddedDirection: direction) .primaryColor(primaryColor) .secondaryColor(secondaryColor)