π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol Mergeable { | |
func merge(_ target: Self) | |
} | |
extension Mergeable { | |
func merge(_ target: Self) { | |
guard let source = self as? NSObject else { return } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User: NSObject, Decodable, Mergeable { | |
@objc var username: String = "" | |
@objc var profileURL: URL? | |
enum CodingKeys: String, CodingKey { | |
case username = "login" | |
case profileURL = "avatar_url" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AsyncDisplayKit | |
public protocol ChatNodeDelegate: ASCollectionDelegate { | |
func shouldAppendBatchFetch(for chatNode: ASCollectionNode) -> Bool | |
func shouldPrependBatchFetch(for chatNode: ASCollectionNode) -> Bool | |
func chatNode(_ chatNode: ASCollectionNode, | |
willBeginAppendBatchFetchWith context: ASBatchContext) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AsyncDisplayKit | |
class ChatFlowLayoutExample: UICollectionViewFlowLayout { | |
private var topVisibleItem = Int.max | |
private var bottomVisibleItem = -Int.max | |
private var offset: CGFloat = 0.0 | |
private var visibleAttributes: [UICollectionViewLayoutAttributes]? | |
private var isPrepend: Bool = false | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class mothorNode: ASDisplayNode { | |
let childNode = ASDisplayNode() | |
// ....omit..... | |
override func layoutDidFinish() { | |
super.layoutDidFinish() | |
self.childNode | |
.gradientBackgroundColor([UIColor.red.cgColor, UIColor.white.cgColor], | |
direction: .horizontal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { | |
let contentLayout = contentLayoutSpec() | |
contentLayout.style.flexShrink = 1.0 | |
contentLayout.style.flexGrow = 1.0 | |
userProfileNode.style.flexShrink = 1.0 | |
userProfileNode.style.flexGrow = 0.0 | |
let stackLayout = ASStackLayoutSpec(direction: .horizontal, | |
spacing: 10.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class VideoFeedController: ASViewController<ASTableNode>, ASTableDataSource { | |
required init() { | |
super.init(node: ASTableNode.init(style: .plain)) | |
self.node.dataSource = self | |
} | |
required init?(coder aDecoder: NSCoder) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
struct VideoProcessing { | |
private static let loadOperation: OperationQueue = { | |
let operationQueue = OperationQueue() | |
operationQueue.maxConcurrentOperationCount = 3 | |
operationQueue.name = "com.VideoFeedController.VideoLoaderOperation" | |
operationQueue.qualityOfService = .utility | |
return operationQueue | |
}() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxCocoa | |
import RxSwift | |
import Foundation | |
// Model Syncronizer | |
struct UserSyncronizer { | |
static private let syncronizer = PublishRelay<User?>() | |
static func observable(_ id: Int) -> Observable<User?> { | |
// subscribe on background('default') scheduler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
extension ASDisplayNode { | |
enum GradientDirection { | |
case horizontal | |
case vertical | |
case adjust(CGPoint, CGPoint) | |
var points: (start: CGPoint, end: CGPoint) { | |
switch self { |