Last active
May 7, 2019 12:57
-
-
Save hlung/d95ea4d9116f3ac1a700534f21b1dd9f to your computer and use it in GitHub Desktop.
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 ArticleView: UIView { | |
var totalCommentCount: Int = 0 { | |
didSet { | |
setNeedsLayout() | |
} | |
} | |
var hasComment: Bool = false { | |
didSet { | |
setNeedsLayout() | |
} | |
} | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
reactionInfoView.commentCount = totalCommentCount | |
commentsTableHeaderView.isHidden = !hasComment | |
} | |
lazy var reactionInfoView: ReactionInfoView = { | |
let view = ReactionInfoView() | |
view.translatesAutoresizingMaskIntoConstraints = false | |
view.backgroundColor = .white | |
return view | |
}() | |
lazy var commentsTableView: ContentFitTableView = { | |
let tableView = ContentFitTableView() | |
tableView.translatesAutoresizingMaskIntoConstraints = false | |
tableView.estimatedRowHeight = 154 | |
tableView.rowHeight = UITableView.automaticDimension | |
return tableView | |
}() | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment