From 76939e8a1900942d654809599076406f84d3fbb8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 7 Nov 2021 23:27:09 +0100 Subject: [PATCH] Improve cell height calculation --- Shared/Videos/HorizontalCells.swift | 17 +++++++++++------ Shared/Videos/VideoCell.swift | 7 ++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Shared/Videos/HorizontalCells.swift b/Shared/Videos/HorizontalCells.swift index bb867c3e..003a0393 100644 --- a/Shared/Videos/HorizontalCells.swift +++ b/Shared/Videos/HorizontalCells.swift @@ -4,6 +4,8 @@ import SwiftUI struct HorizontalCells: View { var items = [ContentItem]() + @Default(.channelOnThumbnail) private var channelOnThumbnail + var body: some View { ScrollView(.horizontal, showsIndicators: false) { LazyHStack(spacing: 20) { @@ -27,14 +29,17 @@ struct HorizontalCells: View { .padding(.vertical, 10) #endif } - #if os(tvOS) - .frame(height: 560) - #else - .frame(height: 290) - #endif - + .frame(height: cellHeight) .edgesIgnoringSafeArea(.horizontal) } + + var cellHeight: Double { + #if os(tvOS) + 560 + #else + 290 - (channelOnThumbnail ? 23 : 0) + #endif + } } struct HorizontalCells_Previews: PreviewProvider { diff --git a/Shared/Videos/VideoCell.swift b/Shared/Videos/VideoCell.swift index 5d2d05eb..16ca7868 100644 --- a/Shared/Videos/VideoCell.swift +++ b/Shared/Videos/VideoCell.swift @@ -168,13 +168,14 @@ struct VideoCell: View { .padding(.bottom, 6) } } + .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading) } #if os(tvOS) .frame(minHeight: channelOnThumbnail ? 80 : 120, alignment: .top) #elseif os(macOS) - .frame(minHeight: 60, alignment: .top) + .frame(minHeight: 35, alignment: .top) #else - .frame(minHeight: 80, alignment: .top) + .frame(minHeight: 50, alignment: .top) #endif .padding(.bottom, 4) @@ -315,7 +316,7 @@ struct VideoCell_Preview: PreviewProvider { VideoCell(video: Video.fixture) } #if os(macOS) - .frame(maxWidth: 600, maxHeight: 400) + .frame(maxWidth: 300, maxHeight: 250) #elseif os(iOS) .frame(maxWidth: 300, maxHeight: 200) #endif