Created
September 20, 2017 10:09
-
-
Save dodikk/1061ea57cffa68d8963171ea05fd2822 to your computer and use it in GitHub Desktop.
NMessenger node with text, timestamp and media attachments table
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 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