π
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
| lazy var profileNode: ASNetworkImageNode = { | |
| let node = ASNetworkImageNode() | |
| ... | |
| return node | |
| }() | |
| lazy var usernameNode: ASTextNode = { | |
| let node = ASTextNode() | |
| ... | |
| return node |
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
| func profileAreaLayoutSpec() -> ASLayoutSpec { | |
| let profileRelativeLayout = ASRelativeLayoutSpec(horizontalPosition: .start, | |
| verticalPosition: .start, | |
| sizingOption: [], | |
| child: profileNode) | |
| return profileRelativeLayout | |
| } |
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
| func engageNodeLayoutSpec() -> ASLayoutSpec { | |
| return ASRelativeLayoutSpec(horizontalPosition: .start, | |
| verticalPosition: .end, | |
| sizingOption: [], | |
| child: engageNode) | |
| } |
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
| func engageNodeLayoutSpec() -> ASLayoutSpec { | |
| return ASRelativeLayoutSpec(horizontalPosition: .start, | |
| verticalPosition: .end, | |
| sizingOption: [], | |
| child: engageNode) | |
| } |
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
| private func talkBalloonContentLayoutSpec(_ constrainedSize: ASSizeRange, | |
| isLeft: Bool) -> ASLayoutSpec { | |
| let talkTailLayout = ASAbsoluteLayoutSpec(sizing: .sizeToFit, | |
| children: [self.talkTailNode]) | |
| let stackElements: [ASLayoutElement] = [self.contentAreaNode, | |
| talkTailLayout] | |
| let stackLayout = ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 0.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
| lazy var talkTailNode: ASImageNode = { | |
| let node = ASImageNode() | |
| node.style.preferredSize = Const.talkTailSize | |
| node.style.layoutPosition = Const.talkTailPosition | |
| switch self.location { | |
| case .left: | |
| node.image = #imageLiteral(resourceName: "imgReplyLeftpoint") | |
| case .right, .write: | |
| node.image = #imageLiteral(resourceName: "imgReplyRightpoint") | |
| case .admin: |
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 stackLayout = | |
| ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 10.0, | |
| justifyContent: .start, | |
| alignItems: .center, | |
| children: [profileImageNode, | |
| descriptionNode]) | |
| let stackLayout2 = |
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 stackLayout = | |
| ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 10.0, | |
| justifyContent: .start, | |
| alignItems: .center, | |
| children: [profileImageNode, | |
| descriptionNode]) | |
| stackLayout.style.flexShrink = 1.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
| override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { | |
| let stackLayout = | |
| ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 10.0, | |
| justifyContent: .start, | |
| alignItems: .center, | |
| children: [profileImageNode, | |
| descriptionNode]) | |
| stackLayout.style.flexShrink = 1.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
| class CatFeedViewController: UIViewController { | |
| let backgroundNode = ASDisplayNode() | |
| let feedNode = ASTableNode() | |
| init() { | |
| super.init(nibName: nil, bundle: nil) | |
| self.view.addSubnode(backgroundNode) | |
| backgroundNode.automaticallyManagesSubnodes = true | |
| backgroundNode.layoutSpecBlock = { [weak self] (node, constraintSize) -> ASLayoutSpec in |
OlderNewer