mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-30 04:54:57 +08:00
New Inbox design (#1870)
* New Inbox design * rename ident to number * use ax animation * building with old notifications removed * remove "2" suffix * use latest IGLK+Swift * apply IGLK perf fixes * fix build * Update with IGLK binding bug fix
This commit is contained in:
@@ -39,7 +39,7 @@ public extension ListAdapter {
|
||||
@return The `ListSectionController`, if the value is a member of the `IGListAdapter`.
|
||||
*/
|
||||
public func sectionController(for value: ListSwiftDiffable) -> ListSectionController? {
|
||||
return sectionController(for: value.boxed)
|
||||
return sectionController(for: value.sectionBox)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ public extension ListAdapter {
|
||||
@return The section, if the value is a member of the adapter.
|
||||
*/
|
||||
public func section(for value: ListSwiftDiffable) -> Int? {
|
||||
let section = self.section(for: value.boxed)
|
||||
let section = self.section(for: value.sectionBox)
|
||||
return section == NSNotFound ? nil : section
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public extension ListAdapter {
|
||||
@return All currently visible cells in the `UICollectionView`. Array is empty if no cells are visible.
|
||||
*/
|
||||
public func visibleCells(for value: ListSwiftDiffable) -> [UICollectionViewCell] {
|
||||
return visibleCells(for: value.boxed)
|
||||
return visibleCells(for: value.sectionBox)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public extension ListAdapter {
|
||||
animated: Bool = true
|
||||
) {
|
||||
scroll(
|
||||
to: value.boxed,
|
||||
to: value.sectionBox,
|
||||
supplementaryKinds: supplementaryKinds,
|
||||
scrollDirection: scrollDirection,
|
||||
scrollPosition: scrollPosition,
|
||||
|
||||
21
Pods/IGListKit/Source/Swift/ListDiffableBox.swift
generated
21
Pods/IGListKit/Source/Swift/ListDiffableBox.swift
generated
@@ -22,13 +22,22 @@ internal final class ListDiffableBox: ListDiffable {
|
||||
*/
|
||||
let value: ListSwiftDiffable
|
||||
|
||||
/**
|
||||
*/
|
||||
let boxesSectionValue: Bool
|
||||
|
||||
private let _diffIdentifier: NSObjectProtocol
|
||||
|
||||
/**
|
||||
Initialize a new `ListDiffableBox` object.
|
||||
|
||||
@param value The value to be boxed.
|
||||
*/
|
||||
init(value: ListSwiftDiffable) {
|
||||
init(value: ListSwiftDiffable, boxesSectionValue: Bool) {
|
||||
self.value = value
|
||||
self.boxesSectionValue = boxesSectionValue
|
||||
// namespace the identifier with the value type to help prevent collisions
|
||||
self._diffIdentifier = "\(type(of: value))\(value.identifier)" as NSObjectProtocol
|
||||
}
|
||||
|
||||
// MARK: ListDiffable
|
||||
@@ -37,16 +46,18 @@ internal final class ListDiffableBox: ListDiffable {
|
||||
:nodoc:
|
||||
*/
|
||||
func diffIdentifier() -> NSObjectProtocol {
|
||||
// namespace the identifier with the value type to help prevent collisions
|
||||
return "\(value.self)\(value.identifier)" as NSObjectProtocol
|
||||
return _diffIdentifier
|
||||
}
|
||||
|
||||
/**
|
||||
:nodoc:
|
||||
*/
|
||||
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
|
||||
// always true since objects are updated with ListSwiftSectionController which handles updates at the cell level
|
||||
return true
|
||||
// always true when using section models since ListSwiftSectionController handles updates at the cell level
|
||||
guard boxesSectionValue == false,
|
||||
let box = object as? ListDiffableBox
|
||||
else { return true }
|
||||
return value.isEqual(to: box.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class ListSwiftAdapter: NSObject, ListAdapterDataSource {
|
||||
guard let dataSource = self.dataSource else { return [] }
|
||||
|
||||
return dataSource.values(adapter: self).map {
|
||||
let box = ListDiffableBox(value: $0.value)
|
||||
let box = $0.value.sectionBox
|
||||
// side effect: store the function for use in listAdapter(:, sectionControllerFor object:)
|
||||
map[box.functionLookupHash] = $0.constructor
|
||||
return box
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
*/
|
||||
|
||||
// Not very clean, but it's not possible to write extensions on a composed Protocols.
|
||||
internal extension ListSwiftIdentifiable where Self: ListSwiftEquatable {
|
||||
internal extension ListSwiftDiffable {
|
||||
|
||||
var boxed: ListDiffable {
|
||||
return ListDiffableBox(value: self)
|
||||
var sectionBox: ListDiffable {
|
||||
return ListDiffableBox(value: self, boxesSectionValue: true)
|
||||
}
|
||||
|
||||
var viewModelBox: ListDiffable {
|
||||
return ListDiffableBox(value: self, boxesSectionValue: false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,12 +7,7 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
public protocol ListSwiftIdentifiable {
|
||||
public protocol ListSwiftDiffable {
|
||||
var identifier: String { get }
|
||||
}
|
||||
|
||||
public protocol ListSwiftEquatable {
|
||||
func isEqual(to value: ListSwiftDiffable) -> Bool
|
||||
}
|
||||
|
||||
public typealias ListSwiftDiffable = ListSwiftIdentifiable & ListSwiftEquatable
|
||||
|
||||
@@ -11,7 +11,7 @@ import UIKit
|
||||
|
||||
public enum ListCellType<T: UICollectionViewCell> {
|
||||
case `class`(T.Type)
|
||||
case storyboard(T.Type, String, Bundle?)
|
||||
case storyboard(T.Type, String)
|
||||
case nib(T.Type, String, Bundle?)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public struct ListBinder {
|
||||
|
||||
enum CellType {
|
||||
case cellClass(UICollectionViewCell.Type)
|
||||
case storyboard(String, Bundle?)
|
||||
case storyboard(String)
|
||||
case nib(String, Bundle?)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ open class ListSwiftSectionController<T: ListSwiftDiffable>: ListSectionControll
|
||||
let nestedCellType: ListBinder.CellType
|
||||
switch cellType {
|
||||
case let .class(type): nestedCellType = .cellClass(type)
|
||||
case let .storyboard(_, type, bundle): nestedCellType = .storyboard(type, bundle)
|
||||
case let .storyboard(_, type): nestedCellType = .storyboard(type)
|
||||
case let .nib(_, type, bundle): nestedCellType = .nib(type, bundle)
|
||||
}
|
||||
|
||||
@@ -146,15 +146,17 @@ open class ListSwiftSectionController<T: ListSwiftDiffable>: ListSectionControll
|
||||
let value = strongSelf.value
|
||||
else { return }
|
||||
|
||||
let fromBoxed = strongSelf.binders.map { $0.value.boxed }
|
||||
let fromBoxed = strongSelf.binders.map { $0.value.viewModelBox }
|
||||
let to = strongSelf.createBinders(from: value)
|
||||
let toBoxed = to.map { $0.value.boxed }
|
||||
let toBoxed = to.map { $0.value.viewModelBox }
|
||||
let result = ListDiff(
|
||||
oldArray: fromBoxed,
|
||||
newArray: toBoxed,
|
||||
option: .equality
|
||||
)
|
||||
|
||||
strongSelf.binders = to
|
||||
|
||||
for (i, _) in result.updates.enumerated() {
|
||||
let identifier = fromBoxed[i].diffIdentifier()
|
||||
let toIndex = result.newIndex(forIdentifier: identifier)
|
||||
@@ -210,7 +212,7 @@ open class ListSwiftSectionController<T: ListSwiftDiffable>: ListSectionControll
|
||||
rawCell = collectionContext.dequeueReusableCell(of: type, for: self, at: index)
|
||||
case let .nib(type, bundle):
|
||||
rawCell = collectionContext.dequeueReusableCell(withNibName: type, bundle: bundle, for: self, at: index)
|
||||
case let .storyboard(type, bundle):
|
||||
case let .storyboard(type):
|
||||
rawCell = collectionContext.dequeueReusableCellFromStoryboard(withIdentifier: type, for: self, at: index)
|
||||
}
|
||||
|
||||
|
||||
2
Pods/Manifest.lock
generated
2
Pods/Manifest.lock
generated
@@ -185,7 +185,7 @@ CHECKOUT OPTIONS:
|
||||
:commit: 4f7e90477619b8dc4b9e641efd10952c22150c5c
|
||||
:git: https://github.com/GitHawkApp/Highlightr.git
|
||||
IGListKit:
|
||||
:commit: 49413f2c37ffb8833d0810c7e641c85e91ffe037
|
||||
:commit: 5c1c92b600f0d8094f22fff48e26ded323568194
|
||||
:git: https://github.com/Instagram/IGListKit.git
|
||||
MessageViewController:
|
||||
:commit: b39c89ea688b79cc8daeb29c214a925c9a1c4396
|
||||
|
||||
2432
Pods/Pods.xcodeproj/project.pbxproj
generated
2432
Pods/Pods.xcodeproj/project.pbxproj
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user