mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-05-25 18:32:22 +08:00
52 lines
1.3 KiB
Swift
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
|
|
}
|
|
|
|
}
|