Skip to content

Instantly share code, notes, and snippets.

@dodikk
Created September 20, 2017 10:09
Show Gist options
  • Save dodikk/1061ea57cffa68d8963171ea05fd2822 to your computer and use it in GitHub Desktop.
Save dodikk/1061ea57cffa68d8963171ea05fd2822 to your computer and use it in GitHub Desktop.
NMessenger node with text, timestamp and media attachments table
class VHMessageContentNode: ContentNode {
public var textNode: ASTextNode?
public var timestampNode: ASTextNode?
public var attachmentsNode: CollectionViewContentNode?
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
let children: [ASLayoutElement?] = [self.timestampNode,
self.textNode,
self.attachmentsNode]
let stackSpec = ASStackLayoutSpec(direction: .vertical,
spacing: 5,
justifyContent: .start,
alignItems: .start,
children: children.flatMap { $0 })
let insets = UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 15)
let insetSpec = ASInsetLayoutSpec(insets: insets,
child: stackSpec)
return insetSpec
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment