杨锴
2024-08-14 909e20941e45f8712c012db602034b47da0bfdb0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
//  AnimatableSectionModel.swift
//  RxDataSources
//
//  Created by Krunoslav Zaher on 1/10/16.
//  Copyright © 2016 Krunoslav Zaher. All rights reserved.
//
 
import Foundation
 
public struct AnimatableSectionModel<Section: IdentifiableType, ItemType: IdentifiableType & Equatable> {
    public var model: Section
    public var items: [Item]
 
    public init(model: Section, items: [ItemType]) {
        self.model = model
        self.items = items
    }
    
}
 
extension AnimatableSectionModel
    : AnimatableSectionModelType {
    public typealias Item = ItemType
    public typealias Identity = Section.Identity
 
    public var identity: Section.Identity {
        return model.identity
    }
 
    public init(original: AnimatableSectionModel, items: [Item]) {
        self.model = original.model
        self.items = items
    }
    
    public var hashValue: Int {
        return self.model.identity.hashValue
    }
}
 
 
extension AnimatableSectionModel
    : CustomStringConvertible {
 
    public var description: String {
        return "HashableSectionModel(model: \"\(self.model)\", items: \(items))"
    }
 
}
 
extension AnimatableSectionModel
    : Equatable where Section: Equatable {
    
    public static func == (lhs: AnimatableSectionModel, rhs: AnimatableSectionModel) -> Bool {
        return lhs.model == rhs.model
            && lhs.items == rhs.items
    }
}