Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "CellKit",
platforms: [.iOS(.v9), .tvOS(.v9)],
platforms: [.iOS(.v13), .tvOS(.v13)],
products: [
.library(
name: "CellKit",
Expand Down
1 change: 1 addition & 0 deletions Sources/CellKit/CellConfigurable.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
public protocol CellConfigurable: AnyObject {
associatedtype Model
func configure(with model: Model)
Expand Down
1 change: 1 addition & 0 deletions Sources/CellKit/CellConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// CellConvertible.swift
public typealias ReusableCellConvertible = CellConvertible & ReusableView

@MainActor
public protocol CellConvertible {
associatedtype Cell: CellConfigurable
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/CellKit/CellModel.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
public protocol CellModel: ReusableView {
var cellHeight: Double { get }
var highlighting: Bool { get }
Expand All @@ -20,6 +21,7 @@ public extension CellModel {
}
}

@MainActor
public protocol SupplementaryViewModel: ReusableView {
var height: Double { get }

Expand Down
2 changes: 2 additions & 0 deletions Sources/CellKit/CellModelDataSource.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import struct Foundation.IndexPath

@MainActor
public protocol CellModelDataSourceDelegate: AnyObject {
func didSelectCellModel(_ cellModel: CellModel, at indexPath: IndexPath)
}

@MainActor
open class CellModelDataSource: AbstractDataSource, DataSource {

public var sections: [CellModelSection]
Expand Down
1 change: 1 addition & 0 deletions Sources/CellKit/CellModelSelectable.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
public protocol CellModelSelectable {
func didSelect()
}
2 changes: 2 additions & 0 deletions Sources/CellKit/DataSource.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit

@MainActor
public protocol DataSource {
associatedtype Section

Expand All @@ -9,6 +10,7 @@ public protocol DataSource {
subscript(index: Int) -> Section { get }
}

@MainActor
open class AbstractDataSource: NSObject {

public weak var delegate: CellModelDataSourceDelegate?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@available(iOS 13.0, tvOS 13.0, *)
@MainActor
public protocol CollectionSupplementaryViewModel: ReusableView {
var kind: SupplementaryElementKind { get }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit

@available(iOS 13.0, tvOS 13.0, *)
@MainActor
public final class LazyCellProvider {
private var registeredIdentifiers: Set<String>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit

@available(iOS 13.0, tvOS 13.0, *)
@MainActor
public final class LazySupplementaryViewProvider {

private var registeredIdentifiers: [String: Set<String>]
Expand Down
1 change: 1 addition & 0 deletions Sources/CellKit/ReusableView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import class Foundation.Bundle
import class UIKit.UINib

@MainActor
public protocol ReusableView {
var registersLazily: Bool { get }
var usesNib: Bool { get }
Expand Down
18 changes: 13 additions & 5 deletions Sources/DiffableCellKit/DifferentiableCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CellKit
#endif

/// Support for determining whether cell model belongs to a certain cell, whether cell should be inserted, removed, updated or moved.
@MainActor
public protocol DifferentiableCellModel: CellModel {

/// Identifier of a cell model inside it's own domain determined by reusable identifier. Assuming model is already presented inside a view, changing of this value will result in it's removal and insertion into the view.
Expand Down Expand Up @@ -31,14 +32,21 @@ extension DifferentiableCellModel where Self: Equatable {

struct DifferentiableCellModelWrapper {
let cellModel: DifferentiableCellModel
let differenceIdentifier: String

@MainActor
init(cellModel: DifferentiableCellModel) {
self.cellModel = cellModel
self.differenceIdentifier = "\(cellModel.reuseIdentifier)<.>\(cellModel.domainIdentifier)"
}
}

extension DifferentiableCellModelWrapper: Equatable, Differentiable {
static func == (lhs: DifferentiableCellModelWrapper, rhs: DifferentiableCellModelWrapper) -> Bool {
lhs.cellModel.hasEqualContent(with: rhs.cellModel)
}

var differenceIdentifier: String {
"\(cellModel.reuseIdentifier)<.>\(cellModel.domainIdentifier)"
// DifferenceKit requires a nonisolated `==`, but wrappers are only ever created and
// diffed by `DifferentiableCellModelDataSource`, which is main actor-isolated.
MainActor.assumeIsolated {
lhs.cellModel.hasEqualContent(with: rhs.cellModel)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import UIKit
import CellKit
#endif

@MainActor
open class DifferentiableCellModelDataSource: AbstractDataSource, DataSource {

private enum Container {
Expand Down