From 89694ca3d22c9d8a60f482f905b5ae07928d17e2 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Thu, 10 Mar 2022 11:57:03 -0800 Subject: [PATCH] constrain grid card image size to 1/3 of card width --- .../App/Views/PrimaryContentView.swift | 2 -- .../Sources/Views/FeedItem/GridCard.swift | 26 ++++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift index 6134bb0a8..a77048444 100644 --- a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift @@ -43,8 +43,6 @@ public struct PrimaryContentView: View { NavigationView { // The first column is the sidebar. PrimaryContentSidebar(categories: categories) - .navigationTitle("") - .navigationBarTitleDisplayMode(.inline) // Second column is the Primary Nav Stack PrimaryContentCategory.feed.destinationView diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index cb58bd770..7304fdbfa 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -121,20 +121,22 @@ public struct GridCard: View { .padding(.horizontal) // Link description and image - HStack(alignment: .top) { - Text(item.description ?? item.title) - .font(.appFootnote) - .foregroundColor(.appGrayTextContrast) - .lineLimit(nil) - .multilineTextAlignment(.leading) + GeometryReader { geo in + HStack(alignment: .top) { + Text(item.description ?? item.title) + .font(.appFootnote) + .foregroundColor(.appGrayTextContrast) + .lineLimit(nil) + .multilineTextAlignment(.leading) - Spacer() + Spacer() - if let imageURL = item.imageURL { - AsyncImage(url: imageURL, isResizable: true) - .aspectRatio(1, contentMode: .fill) - .frame(width: 135, height: 90) - .cornerRadius(3) + if let imageURL = item.imageURL { + AsyncImage(url: imageURL, isResizable: true) + .aspectRatio(1, contentMode: .fill) + .frame(width: min(geo.size.width / 3, 135), height: min((geo.size.width * 2) / 9, 90)) + .cornerRadius(3) + } } } .frame(height: 95)