Skip to content

Commit

Permalink
Merge pull request #8 from cellular/feature/Xcode13.3_RenameType
Browse files Browse the repository at this point in the history
Feature/xcode13.3 rename type
  • Loading branch information
dimitribrukakis authored Apr 7, 2022
2 parents 94e8e81 + 2b71ed3 commit 0f09db3
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension ModelCollection {
public mutating func appendSection<M, D: ModelDataSourceViewDisplayable>(_ model: M,
view: D.Type,
ofKind kind: DataSourceView.DecorativeKind)
-> Int where D.Model == M, D.Size == DataSourceView.Dimension {
-> Int where D.Model == M, D.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {
return append(section: .init(decorative: .init(model: model, view: view), ofKind: kind))
}

Expand All @@ -35,15 +35,15 @@ extension ModelCollection {
view: D.Type,
ofKind: DataSourceView.DecorativeKind,
inSection: Index? = nil)
-> Index where D.Model == M, D.Size == DataSourceView.Dimension {
-> Index where D.Model == M, D.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {

return append(decorative: .init(model: model, view: view), ofKind: ofKind)
}

@available(*, deprecated, renamed: "append(item:inSection:)")
@discardableResult
public mutating func append<M, C: ModelDataSourceViewDisplayable>(_ model: M, cell: C.Type, inSection: Index? = nil)
-> IndexPath where C.Model == M, C.Size == DataSourceView.Dimension {
-> IndexPath where C.Model == M, C.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {

return append(item: .init(model: model, cell: cell), inSection: inSection)
}
Expand All @@ -53,14 +53,14 @@ extension ModelCollection {
public mutating func appendContentsOf<M, C: ModelDataSourceViewDisplayable>(_ models: [M],
cell: C.Type,
inSection: Index? = nil) -> [IndexPath]
where C.Model == M, C.Size == DataSourceView.Dimension {
where C.Model == M, C.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {

return append(contentsOf: models, cell: cell, inSection: inSection)
}

@available(*, deprecated, renamed: "insert(item:index:)")
public mutating func insert<M, C: ModelDataSourceViewDisplayable>(_ model: M, cell: C.Type, index: IndexPath) where C.Model == M,
C.Size == DataSourceView.Dimension {
C.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {

insert(item: .init(model: model, cell: cell), indexPath: index)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ModelDataSource/Collection/ModelCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extension ModelCollection {
public mutating func append<M, C: ModelDataSourceViewDisplayable>(contentsOf models: [M],
cell: C.Type,
inSection: Index? = nil)
-> [IndexPath] where C.Model == M, C.Size == DataSourceView.Dimension {
-> [IndexPath] where C.Model == M, C.ModelDataSourceViewDisplayableDimension == DataSourceView.Dimension {

return models.map { append(item: .init(model: $0, cell: cell), inSection: inSection) }
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ModelDataSource/Collection/ModelDecorative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct ModelDecorative<V: ModelDataSourceView> {
/// Assigns the model to the given decorative. Returns true if the model was assigned successfully.
public let assignModel: (V.DecorativeView) -> Bool

public init<M, D: ModelDataSourceViewDisplayable>(model: M, view: D.Type) where D.Model == M, D.Size == V.Dimension {
public init<M, D: ModelDataSourceViewDisplayable>(model: M, view: D.Type) where D.Model == M, D.ModelDataSourceViewDisplayableDimension == V.Dimension {
self.model = model
self.view = view
self.reuseIdentifier = view.reuseIdentifier
Expand Down
2 changes: 1 addition & 1 deletion Sources/ModelDataSource/Collection/ModelItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct ModelItem<V: ModelDataSourceView> {
/// Assigns the model to the given decorative. Returns true if the model was assigned successfully.
public let assignModel: (V.Cell) -> Bool

public init<M, C: ModelDataSourceViewDisplayable>(model: M, cell: C.Type) where C.Model == M, C.Size == V.Dimension {
public init<M, C: ModelDataSourceViewDisplayable>(model: M, cell: C.Type) where C.Model == M, C.ModelDataSourceViewDisplayableDimension == V.Dimension {
self.model = model
self.cell = cell
self.reuseIdentifier = cell.reuseIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,25 @@ extension UICollectionView: ModelDataSourceView {
/// https://stackoverflow.com/questions/71563154/how-to-implement-static-variables-of-associated-types-in-protocol-extensions-in

extension UICollectionViewCell {
public typealias Size = CGSize
public typealias ModelDataSourceViewDisplayableDimension = CGSize
}

extension UICollectionReusableView {
public typealias Size = CGSize
public typealias ModelDataSourceViewDisplayableDimension = CGSize
}

extension ModelDataSourceViewDisplayable where Self: UICollectionViewCell {

/// Optional fixed size definition to override dynamic height calculations.
public static var staticSize: Size? {
public static var staticSize: ModelDataSourceViewDisplayableDimension? {
return nil
}
}

extension ModelDataSourceViewDisplayable where Self: UICollectionReusableView {

/// Optional fixed size definition to override dynamic height calculations.
public static var staticSize: Size? {
public static var staticSize: ModelDataSourceViewDisplayableDimension? {
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ extension UITableView: ModelDataSourceView {
/// https://stackoverflow.com/questions/71563154/how-to-implement-static-variables-of-associated-types-in-protocol-extensions-in

extension UITableViewCell {
public typealias Size = CGFloat
public typealias ModelDataSourceViewDisplayableDimension = CGFloat
}

extension UITableViewHeaderFooterView {
public typealias Size = CGFloat
public typealias ModelDataSourceViewDisplayableDimension = CGFloat
}

extension ModelDataSourceViewDisplayable where Self: UITableViewCell {

/// Optional fixed size definition to override dynamic height calculations.
public static var staticSize: Size? {
public static var staticSize: ModelDataSourceViewDisplayableDimension? {
return nil
}
}

extension ModelDataSourceViewDisplayable where Self: UITableViewHeaderFooterView {

/// Optional fixed size definition to override dynamic height calculations.
public static var staticSize: Size? {
public static var staticSize: ModelDataSourceViewDisplayableDimension? {
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public protocol ModelDataSourceViewDisplayable: class {
associatedtype Model

/// The variable/dynamic dimension of the cell for sizing calculations.
associatedtype Size
associatedtype ModelDataSourceViewDisplayableDimension

/// The source file of the decorative view. Used to register/dequeue & calculate size of the receiver.
static var source: Source<Self> { get }
Expand All @@ -15,7 +15,7 @@ public protocol ModelDataSourceViewDisplayable: class {
static var reuseIdentifier: String { get }

/// Optional fixed size definition to override dynamic height calculations.
static var staticSize: Size? { get }
static var staticSize: ModelDataSourceViewDisplayableDimension? { get }

/// Model that was associated with the cell on initialization or reuse.
var model: Model? { get set }
Expand Down
10 changes: 5 additions & 5 deletions Tests/ModelDataSourceTests/ModelCollectionDeprecatedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private class ModelCollectionDeprecatedTesting<C: ModelCollection> {
}

func testAppendSectionWithDecorative<M, D: ModelDataSourceViewDisplayable>(_ model: M, view: D.Type)
where M == D.Model, D.Size == C.DataSourceView.Dimension {
where M == D.Model, D.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {

guard let decorativeKind = decorativeKinds?().first, let modelDecorative = createDecorative?("Decorative") else {
return XCTFail("\(collectionName) failed to create decoratives.")
Expand All @@ -162,7 +162,7 @@ private class ModelCollectionDeprecatedTesting<C: ModelCollection> {
XCTAssertNotNil(deprecatedCollection.first?[decorativeKind], "Deprecated \(collectionName) failed to create decorative.")
}

func testAppendDecorative<M, D: ModelDataSourceViewDisplayable>(_ model: M, view: D.Type) where M == D.Model, D.Size == C.DataSourceView.Dimension {
func testAppendDecorative<M, D: ModelDataSourceViewDisplayable>(_ model: M, view: D.Type) where M == D.Model, D.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {

guard let decorativeKind = decorativeKinds?().first, let modelDecorative = createDecorative?("Decorative") else {
return XCTFail("\(collectionName) failed to create decoratives.")
Expand Down Expand Up @@ -199,7 +199,7 @@ private class ModelCollectionDeprecatedTesting<C: ModelCollection> {
}

func testAppendItem<M, Cell: ModelDataSourceViewDisplayable>(_ model: M, cell: Cell.Type)
where Cell.Model == M, Cell.Size == C.DataSourceView.Dimension {
where Cell.Model == M, Cell.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {

guard let modelItem = createItem?("Item") else {
return XCTFail("\(collectionName) failed to create item.")
Expand Down Expand Up @@ -236,7 +236,7 @@ private class ModelCollectionDeprecatedTesting<C: ModelCollection> {
}

func testAppendContentsOfItems<M, Cell: ModelDataSourceViewDisplayable>(_ models: [M], cell: Cell.Type)
where Cell.Model == M, Cell.Size == C.DataSourceView.Dimension {
where Cell.Model == M, Cell.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {

var collection: C = .init()
var deprecatedCollection: C = .init()
Expand Down Expand Up @@ -269,7 +269,7 @@ private class ModelCollectionDeprecatedTesting<C: ModelCollection> {
}

func testInsertItemAtIndexPath<M, Cell: ModelDataSourceViewDisplayable>(_ model: M, insertCell: Cell.Type)
where Cell.Model == M, Cell.Size == C.DataSourceView.Dimension {
where Cell.Model == M, Cell.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {

guard let modelItem = createItem?("Item"), let searchItem = createSearchItem?("searchItem"),
let searchClass = searchItemClass else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelDataSourceTests/ModelCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private class ModelCollectionTesting<C: ModelCollection> {
}
}

func testAppendItemList<Cell: TestModelDataSourceViewDisplayable>(cell: Cell.Type) where Cell.Size == C.DataSourceView.Dimension {
func testAppendItemList<Cell: TestModelDataSourceViewDisplayable>(cell: Cell.Type) where Cell.ModelDataSourceViewDisplayableDimension == C.DataSourceView.Dimension {
var collection: C = .init()
let modelCount = 5
let models: [Cell.Model] = .init(repeating: Cell.testModel, count: modelCount)
Expand Down

0 comments on commit 0f09db3

Please sign in to comment.