Skip to content

Commit

Permalink
PLAYNEXT-1271 Fix media cell layout for different scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
mutaben committed Feb 24, 2025
1 parent cf57bc6 commit 18b7b4e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Application/Sources/UI/Views/MediaCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 18b7b4e

Please sign in to comment.