Files
GitHawk/Classes/Issues/DiffHunk/IssueDiffHunkPreviewCell.swift
Ryan Nystrom e56c29a9a6 Redesigned Issues interface (#1983)
* clean up title model

* update title style

* organize issue SC method

* remove background colors from styled text in issues

* collection view bg white

* remove card inset and clean up snap superview code

* clean up label design

* thread is root and change base font size

* remove borders on comment cells

* adjust collapse design

* adjust comment line spacing and make non-root body smaller

* refactor detail view

* viewer header background color

* more buttons in reaction cell

* vertical spacers working

* design basically finished;

* scroll to bottom accounts for inset

* PR review background color white

* fixup PR review comments

* spacing on merge and review

* readme background white

* rename to just "spacer"

* horizontal spacing

* fix tests
2018-07-27 11:03:09 -04:00

56 lines
1.3 KiB
Swift

//
// IssueDiffHunkPreviewCell.swift
// Freetime
//
// Created by Ryan Nystrom on 7/3/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import IGListKit
import StyledTextKit
final class IssueDiffHunkPreviewCell: IssueCommentBaseCell, ListBindable {
static let textViewInset = UIEdgeInsets(
top: Styles.Sizes.rowSpacing,
left: 0,
bottom: Styles.Sizes.rowSpacing,
right: 0
)
let scrollView = UIScrollView()
let textView = StyledTextView()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.addSubview(scrollView)
scrollView.addSubview(textView)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
scrollView.frame = CGRect(
x: 0,
y: 0,
width: contentView.bounds.width,
height: scrollView.contentSize.height
)
}
// MARK: ListBindable
func bindViewModel(_ viewModel: Any) {
guard let viewModel = viewModel as? StyledTextRenderer else { return }
let width: CGFloat = 0
scrollView.contentSize = viewModel.viewSize(in: width)
textView.configure(with: viewModel, width: width)
}
}