|
|
@ -22,15 +22,6 @@ protocol StatusViewDelegate { |
|
|
|
func hideTapped() |
|
|
|
} |
|
|
|
|
|
|
|
extension StatusViewDelegate { |
|
|
|
func loadMoreTapped(status: StatusMO, direction: PaginationDirection) {} |
|
|
|
func boostTapped() {} |
|
|
|
func favoriteTapped() {} |
|
|
|
func replyTapped(status: StatusMO) {} |
|
|
|
func revealTapped() {} |
|
|
|
func hideTapped() {} |
|
|
|
} |
|
|
|
|
|
|
|
class StatusView: UIView { |
|
|
|
@IBOutlet var contentView: UIView! |
|
|
|
@IBOutlet var boostView: UIView! |
|
|
@ -244,6 +235,7 @@ class StatusView: UIView { |
|
|
|
|
|
|
|
public func update(withStatus status: StatusMO) { |
|
|
|
self.status = status |
|
|
|
let statusCellHidden = status.hidden |
|
|
|
|
|
|
|
boostView.isHidden = true |
|
|
|
replyView.isHidden = true |
|
|
@ -267,52 +259,52 @@ class StatusView: UIView { |
|
|
|
|
|
|
|
if let content = status.content { |
|
|
|
contentTextView.attributedText = content.htmlAttributed(size: 15.0) |
|
|
|
|
|
|
|
if status.hidden { |
|
|
|
if spoilerView == nil { |
|
|
|
let spoilerText = UILabel(frame: contentTextView.frame) |
|
|
|
spoilerText.textColor = UIColor(named: "Primary") |
|
|
|
spoilerText.font = UIFont.systemFont(ofSize: 15, weight: .bold) |
|
|
|
spoilerText.textAlignment = .center |
|
|
|
spoilerText.text = status.spoilerText |
|
|
|
spoilerText.numberOfLines = 0 |
|
|
|
spoilerText.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
|
|
|
|
let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffect.Style.light)) |
|
|
|
blurEffectView.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
blurEffectView.contentView.addSubview(spoilerText) |
|
|
|
|
|
|
|
NSLayoutConstraint.activate([ |
|
|
|
spoilerText.leadingAnchor.constraint(equalTo: blurEffectView.leadingAnchor), |
|
|
|
spoilerText.trailingAnchor.constraint(equalTo: blurEffectView.trailingAnchor), |
|
|
|
spoilerText.centerYAnchor.constraint(equalTo: blurEffectView.centerYAnchor), |
|
|
|
]) |
|
|
|
|
|
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.reveal)) |
|
|
|
tapGesture.numberOfTapsRequired = 1 |
|
|
|
tapGesture.numberOfTouchesRequired = 1 |
|
|
|
blurEffectView.addGestureRecognizer(tapGesture) |
|
|
|
blurEffectView.isUserInteractionEnabled = true |
|
|
|
|
|
|
|
self.spoilerView = blurEffectView |
|
|
|
self.contentView.addSubview(blurEffectView) |
|
|
|
|
|
|
|
NSLayoutConstraint.activate([ |
|
|
|
blurEffectView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), |
|
|
|
blurEffectView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), |
|
|
|
blurEffectView.topAnchor.constraint(equalTo: contentTextView.topAnchor), |
|
|
|
blurEffectView.bottomAnchor.constraint(equalTo: detailsView.topAnchor), |
|
|
|
]) |
|
|
|
} |
|
|
|
} else { |
|
|
|
if let spoilerView = spoilerView { |
|
|
|
spoilerView.removeFromSuperview() |
|
|
|
self.spoilerView = nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if statusCellHidden { |
|
|
|
if spoilerView == nil { |
|
|
|
let spoilerText = UILabel(frame: contentTextView.frame) |
|
|
|
spoilerText.textColor = UIColor(named: "Primary") |
|
|
|
spoilerText.font = UIFont.systemFont(ofSize: 15, weight: .bold) |
|
|
|
spoilerText.textAlignment = .center |
|
|
|
spoilerText.text = status.spoilerText |
|
|
|
spoilerText.numberOfLines = 0 |
|
|
|
spoilerText.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
|
|
|
|
if let spoilerText = status.spoilerText, !spoilerText.isEmpty { |
|
|
|
spoilerImageView.isHidden = false |
|
|
|
} |
|
|
|
let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffect.Style.light)) |
|
|
|
blurEffectView.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
blurEffectView.contentView.addSubview(spoilerText) |
|
|
|
|
|
|
|
NSLayoutConstraint.activate([ |
|
|
|
spoilerText.leadingAnchor.constraint(equalTo: blurEffectView.leadingAnchor), |
|
|
|
spoilerText.trailingAnchor.constraint(equalTo: blurEffectView.trailingAnchor), |
|
|
|
spoilerText.centerYAnchor.constraint(equalTo: blurEffectView.centerYAnchor), |
|
|
|
]) |
|
|
|
|
|
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.reveal)) |
|
|
|
tapGesture.numberOfTapsRequired = 1 |
|
|
|
tapGesture.numberOfTouchesRequired = 1 |
|
|
|
blurEffectView.addGestureRecognizer(tapGesture) |
|
|
|
blurEffectView.isUserInteractionEnabled = true |
|
|
|
|
|
|
|
self.spoilerView = blurEffectView |
|
|
|
self.contentView.addSubview(blurEffectView) |
|
|
|
|
|
|
|
NSLayoutConstraint.activate([ |
|
|
|
blurEffectView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), |
|
|
|
blurEffectView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), |
|
|
|
blurEffectView.topAnchor.constraint(equalTo: contentTextView.topAnchor), |
|
|
|
blurEffectView.bottomAnchor.constraint(equalTo: detailsView.topAnchor), |
|
|
|
]) |
|
|
|
} |
|
|
|
} else { |
|
|
|
if let spoilerView = spoilerView { |
|
|
|
spoilerView.removeFromSuperview() |
|
|
|
self.spoilerView = nil |
|
|
|
} |
|
|
|
|
|
|
|
if let spoilerText = status.spoilerText, !spoilerText.isEmpty { |
|
|
|
spoilerImageView.isHidden = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|