BoundsChangedFlowLayout.swift 738 B

123456789101112131415161718192021
  1. //
  2. // SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import Foundation
  6. class BoundsChangedFlowLayout: UICollectionViewFlowLayout {
  7. override func invalidationContext(forBoundsChange newBounds: CGRect) -> UICollectionViewLayoutInvalidationContext {
  8. if let context = super.invalidationContext(forBoundsChange: newBounds) as? UICollectionViewFlowLayoutInvalidationContext {
  9. if let collectionView = collectionView {
  10. context.invalidateFlowLayoutDelegateMetrics = collectionView.bounds.size != newBounds.size
  11. }
  12. return context
  13. }
  14. return UICollectionViewLayoutInvalidationContext()
  15. }
  16. }