Skip to content

Instantly share code, notes, and snippets.

@codeOfRobin
Created May 20, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeOfRobin/a43eb25ddb84cf1bc6e7f261d0ba7973 to your computer and use it in GitHub Desktop.
Save codeOfRobin/a43eb25ddb84cf1bc6e7f261d0ba7973 to your computer and use it in GitHub Desktop.
//
// TagCell.swift
// ChannelExample
//
// Created by Robin Malhotra on 24/04/18.
// Copyright © 2018 Robin Malhotra. All rights reserved.
//
import AsyncDisplayKit
class TagCell: ASCellNode {
let tagNodes: [TagNode]
init(_ tags: [String]) {
self.tagNodes = tags.map(TagNode.init)
super.init()
self.automaticallyManagesSubnodes = true
}
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
let tagSpecs = tagNodes.map{
return ASInsetLayoutSpec(insets: UIEdgeInsets.init(top: 4, left: 4, bottom: 4, right: 4), child: $0)
}
return ASStackLayoutSpec(direction: .horizontal, spacing: 4.0, justifyContent: .start, alignItems: .center, flexWrap: .wrap, alignContent: .start, children: tagSpecs)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment