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
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Delta",
platforms: [.iOS(.v14)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Delta",
targets: ["Delta"]),
],
dependencies: [
.package(url: "https://github.com/Quick/Quick", from: "5.0.0"),
.package(url: "https://github.com/Quick/Nimble", from: "10.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Delta",
dependencies: []),
.testTarget(
name: "DeltaTests",
dependencies: [
"Delta",
.product(name: "Quick", package: "quick"),
.product(name: "Nimble", package: "nimble")
]),
]
)
File renamed without changes.
2 changes: 1 addition & 1 deletion sources/delta.swift → Sources/Delta/delta.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func generateSectionRecords<Section: DeltaSection>(from: [Section], to: [Section
let records = changes(from: from, to: to)
let recordsWithoutChange = records.filter { record in
switch record {
case .change(_):
case .change(_, _):
return false
default:
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit

public extension UICollectionView {

public typealias CollectionViewUpdateCallback = (_ from: IndexPath, _ to: IndexPath) -> Void
typealias CollectionViewUpdateCallback = (_ from: IndexPath, _ to: IndexPath) -> Void

/// Perform updates on the collection view.
///
Expand All @@ -13,7 +13,7 @@ public extension UICollectionView {
/// Note: due to internals in UITableView’s and UICollecitonView’s we need
/// to query the cell using the old index path, and update the cell with
/// data from the new index path.
public func performUpdates(_ records: [CollectionRecord], update: CollectionViewUpdateCallback? = nil) {
func performUpdates(_ records: [CollectionRecord], update: CollectionViewUpdateCallback? = nil) {
self.performBatchUpdates({
for record in records {
switch record {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit

public extension UITableView {

public typealias TableViewUpdateCallback = (_ from: IndexPath, _ to: IndexPath) -> Void
typealias TableViewUpdateCallback = (_ from: IndexPath, _ to: IndexPath) -> Void

/// Perform updates on the table view.
///
Expand All @@ -13,7 +13,7 @@ public extension UITableView {
/// Note: due to internals in UITableView’s and UICollecitonView’s we need
/// to query the cell using the old index path, and update the cell with
/// data from the new index path.
public func performUpdates(_ records: [CollectionRecord], update: TableViewUpdateCallback? = nil) {
func performUpdates(_ records: [CollectionRecord], update: TableViewUpdateCallback? = nil) {
var changeRecords: [CollectionRecord] = []

self.beginUpdates()
Expand Down
4 changes: 2 additions & 2 deletions sources/processor.swift → Sources/Delta/processor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func changes<Item: DeltaItem>(from: [Item], to: [Item]) -> [DeltaChange] where I
typealias DeltaCache = [Item.DeltaIdentifier: (index: Int, item: Item)]

func added(_ to: [Item], fromCache: DeltaCache) -> [DeltaChange] {
return to.enumerated().flatMap { (index, element) -> DeltaChange? in
return to.enumerated().compactMap { (index, element) -> DeltaChange? in
if fromCache[element.deltaIdentifier] == nil {
return .add(index: index)
}
Expand All @@ -19,7 +19,7 @@ func changes<Item: DeltaItem>(from: [Item], to: [Item]) -> [DeltaChange] where I
}

func removed(_ from: [Item], toCache: DeltaCache) -> [DeltaChange] {
return from.enumerated().flatMap { (index, item) -> DeltaChange? in
return from.enumerated().compactMap { (index, item) -> DeltaChange? in
if let cacheEntry = toCache[item.deltaIdentifier] {
if cacheEntry.item != item {
return .change(index: cacheEntry.index, from: index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Nimble
@testable import Delta

struct Section: DeltaSection, Equatable {

let identifier: Int
let items: [Model]
var deltaIdentifier: Int { return self.identifier }
Expand Down
File renamed without changes.