IGListKit/Examples/Examples-iOS/IGListKitExamples/Models/GridItem.swift
Maxime Ollivier 7fe78a887d add grid to UICollectionViewCompositionalLayout example
Summary: Adding a grid

Differential Revision: D52260530

fbshipit-source-id: 82e0ef4c1b0cad4a95e0c802d783d7c3f44c5f3b
2023-12-19 07:17:30 -08:00

44 lines
899 B
Swift

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import IGListKit
import Foundation
final class GridItem: NSObject {
let color: UIColor
let itemCount: Int
var items: [String] = []
init(color: UIColor, itemCount: Int) {
self.color = color
self.itemCount = itemCount
super.init()
self.items = computeItems()
}
private func computeItems() -> [String] {
return [Int](1...itemCount).map {
String(describing: $0)
}
}
}
extension GridItem: ListDiffable {
func diffIdentifier() -> NSObjectProtocol {
return self
}
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
return self === object ? true : self.isEqual(object)
}
}