From ee7f6c78f0cc01e3183579794d9e5eaa518cfe33 Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Tue, 13 Aug 2024 16:52:04 +0200 Subject: [PATCH 1/2] recommendations-iPad-fix (#1369) * wip * fix --------- Co-authored-by: Adrian Sergheev --- .../GridView/AdRecommendationsGridView.swift | 11 +++-------- .../GridView/AdRecommendationsGridViewLayout.swift | 14 ++++++++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridView.swift b/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridView.swift index 33d8c853a5..074d0d379a 100644 --- a/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridView.swift +++ b/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridView.swift @@ -1,7 +1,3 @@ -// -// Copyright © FINN.no AS, Inc. All rights reserved. -// - import UIKit public protocol AdRecommendationsGridViewDelegate: AnyObject { @@ -51,15 +47,14 @@ public class AdRecommendationsGridView: UIView { private let imageCache = ImageMemoryCache() - private lazy var collectionViewLayout: AdRecommendationsGridViewLayout = { + private func collectionViewLayout() -> AdRecommendationsGridViewLayout { let layout = AdRecommendationsGridViewLayout() layout.delegate = self return layout - }() + } - // Have the collection view be private so nobody messes with it. public private(set) lazy var collectionView: UICollectionView = { - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: collectionViewLayout) + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: collectionViewLayout()) collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.delegate = self collectionView.dataSource = self diff --git a/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridViewLayout.swift b/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridViewLayout.swift index 77e16c0ba6..7216ff0d49 100644 --- a/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridViewLayout.swift +++ b/FinniversKit/Sources/Recycling/GridViews/AdRecommendations/GridView/AdRecommendationsGridViewLayout.swift @@ -1,7 +1,3 @@ -// -// Copyright © FINN.no AS, Inc. All rights reserved. -// - import UIKit protocol AdRecommendationsGridViewLayoutDelegate: AnyObject { @@ -75,7 +71,7 @@ class AdRecommendationsGridViewLayout: UICollectionViewLayout { override func prepare() { super.prepare() - itemAttributes = [UICollectionViewLayoutAttributes]() + itemAttributes.removeAll() guard let collectionView = collectionView else { return @@ -122,7 +118,13 @@ class AdRecommendationsGridViewLayout: UICollectionViewLayout { } override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { - return itemAttributes[indexPath.row] + guard itemAttributes.indices.contains(indexPath.row) + else { return nil } + if itemAttributes[indexPath.row].representedElementCategory == .cell { + return itemAttributes[indexPath.row] + } else { + return nil + } } override var collectionViewContentSize: CGSize { From bc9a446aae34339f30ddcbf3c1b35f2de67fc83e Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Tue, 13 Aug 2024 16:54:07 +0200 Subject: [PATCH 2/2] Bumped podspec and Info.plist(s) version to 143.6.1 --- Demo/SnapshotTests/Info.plist | 2 +- Demo/Sources/Info.plist | 2 +- FinniversKit.podspec | 2 +- FinniversKit/Sources/Info.plist | 2 +- FinniversKit/UnitTests/Info.plist | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Demo/SnapshotTests/Info.plist b/Demo/SnapshotTests/Info.plist index 162dec17c1..0adf580d89 100644 --- a/Demo/SnapshotTests/Info.plist +++ b/Demo/SnapshotTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 143.6.0 + 143.6.1 CFBundleVersion 1 NSPrincipalClass diff --git a/Demo/Sources/Info.plist b/Demo/Sources/Info.plist index 7b47313b8c..6dfcb2797f 100644 --- a/Demo/Sources/Info.plist +++ b/Demo/Sources/Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 143.6.0 + 143.6.1 CFBundleVersion 1 ITSAppUsesNonExemptEncryption diff --git a/FinniversKit.podspec b/FinniversKit.podspec index 8ebc479e23..1287209914 100644 --- a/FinniversKit.podspec +++ b/FinniversKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FinniversKit' - s.version = '143.6.0' + s.version = '143.6.1' s.summary = "FINN's iOS Components" s.author = 'FINN.no' s.homepage = 'https://schibsted.frontify.com/d/oCLrx0cypXJM/design-system' diff --git a/FinniversKit/Sources/Info.plist b/FinniversKit/Sources/Info.plist index b6581241d1..8dc5f42221 100644 --- a/FinniversKit/Sources/Info.plist +++ b/FinniversKit/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 143.6.0 + 143.6.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/FinniversKit/UnitTests/Info.plist b/FinniversKit/UnitTests/Info.plist index 5f716ef0a5..53d4fae080 100644 --- a/FinniversKit/UnitTests/Info.plist +++ b/FinniversKit/UnitTests/Info.plist @@ -15,6 +15,6 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 143.6.0 + 143.6.1