Skip to content

Instantly share code, notes, and snippets.

@wendyliga
Created September 25, 2019 09:11
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 wendyliga/49c08b61def9c1ae0e04af5584501702 to your computer and use it in GitHub Desktop.
Save wendyliga/49c08b61def9c1ae0e04af5584501702 to your computer and use it in GitHub Desktop.
TextureGram Main View Controller
import AsyncDisplayKit
class ViewController: ASViewController<ASDisplayNode> {
private let storyNode: StoryNode
private let postNode: PostNode
init() {
self.storyNode = StoryNode(stories: Story.generateDummyStory())
self.postNode = PostNode(posts: Post.generateDummyPosts())
super.init(node: ASDisplayNode())
self.node.backgroundColor = .white
self.node.automaticallyManagesSubnodes = true
self.node.layoutSpecBlock = {_,_ in
let storyNodeWithPadding = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 0), child: self.storyNode)
let mainStack = ASStackLayoutSpec(direction: .vertical,
spacing: 0,
justifyContent: .start,
alignItems: .stretch,
children: [storyNodeWithPadding,
self.postNode])
return mainStack
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment