mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-12 00:14:44 +08:00
* 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
61 lines
1.3 KiB
Swift
61 lines
1.3 KiB
Swift
//
|
|
// Label.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 6/2/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import IGListKit
|
|
|
|
final class RepositoryLabel: ListDiffable, Hashable, Equatable, ListSwiftDiffable {
|
|
|
|
let color: String
|
|
let name: String
|
|
|
|
init(color: String, name: String) {
|
|
self.color = color
|
|
self.name = name
|
|
}
|
|
|
|
// MARK: ListDiffable
|
|
|
|
func diffIdentifier() -> NSObjectProtocol {
|
|
return name as NSObjectProtocol
|
|
}
|
|
|
|
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
|
|
if self === object { return true }
|
|
guard let object = object as? RepositoryLabel else { return false }
|
|
return color == object.color
|
|
}
|
|
|
|
// MARK: Hashable
|
|
|
|
var hashValue: Int {
|
|
return color.hashValue
|
|
.combineHash(with: name.hashValue)
|
|
}
|
|
|
|
// MARK: Equatable
|
|
|
|
static func ==(lhs: RepositoryLabel, rhs: RepositoryLabel) -> Bool {
|
|
if lhs === rhs { return true }
|
|
return lhs.color == rhs.color
|
|
&& lhs.name == rhs.name
|
|
}
|
|
|
|
// MARK: ListSwiftDiffable
|
|
|
|
var identifier: String {
|
|
return name
|
|
}
|
|
|
|
func isEqual(to object: ListSwiftDiffable) -> Bool {
|
|
guard let object = object as? RepositoryLabel else { return false }
|
|
return self == object
|
|
}
|
|
|
|
}
|