Files
GitHawk/Classes/Issues/Comments/Text/IssueCommentTextCell.swift
2017-06-26 21:27:56 -07:00

52 lines
1.3 KiB
Swift

//
// IssueCommentTextCell.swift
// Freetime
//
// Created by Ryan Nystrom on 5/19/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
import IGListKit
final class IssueCommentTextCell: UICollectionViewCell, ListBindable, CollapsibleCell {
static let inset = Styles.Sizes.textCellInset
let textView = AttributedStringView()
let overlay = CreateCollapsibleOverlay()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.backgroundColor = .white
contentView.clipsToBounds = true
contentView.addSubview(textView)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
LayoutCollapsible(layer: overlay, view: contentView)
textView.reposition(width: contentView.bounds.width)
}
// MARK: ListBindable
func bindViewModel(_ viewModel: Any) {
guard let viewModel = viewModel as? NSAttributedStringSizing else { return }
textView.configureAndSizeToFit(text: viewModel, width: contentView.bounds.width)
}
// MARK: CollapsibleCell
func setCollapse(visible: Bool) {
overlay.isHidden = !visible
}
}