Browse Source

Fix spoiler text issues, add attachment loading indicator, status content padding adjustments

master
Dwayne Harris 6 years ago
parent
commit
1e5322b4a8
  1. 5
      elpha-ios/AbstractStatusTableViewController.swift
  2. 4
      elpha-ios/AttachmentManager.swift
  3. 1
      elpha-ios/AttachmentViewController.swift
  4. 34
      elpha-ios/StatusTableViewController.swift
  5. 100
      elpha-ios/StatusView.swift
  6. 5
      elpha-ios/String+HtmlAttributed.swift

5
elpha-ios/AbstractStatusTableViewController.swift

@ -72,6 +72,11 @@ class AbstractStatusTableViewController: UITableViewController, StatusViewDelega
present(controller, animated: true)
}
func revealTapped() {}
func hideTapped() {}
func boostTapped() {}
func favoriteTapped() {}
}
extension AbstractStatusTableViewController: SFSafariViewControllerDelegate {

4
elpha-ios/AttachmentManager.swift

@ -51,6 +51,7 @@ class AttachmentManager: NSObject {
let imageView = UIImageView()
imageView.contentMode = UIImageView.ContentMode.scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: attachment.url!, placeholder: placeholder, options: [.processor(fullResizingProcessor)])
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(attachmentTapped))
@ -81,6 +82,7 @@ class AttachmentManager: NSObject {
imageView.contentMode = UIImageView.ContentMode.scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: attachment.url!, placeholder: placeholder, options: [.processor(tallResizingProcessor)])
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(attachmentTapped))
@ -124,6 +126,7 @@ class AttachmentManager: NSObject {
imageView.contentMode = UIImageView.ContentMode.scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: attachment.url!, placeholder: placeholder, options: [.processor(processor)])
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(attachmentTapped))
@ -170,6 +173,7 @@ class AttachmentManager: NSObject {
imageView.contentMode = UIImageView.ContentMode.scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: attachment.url!, placeholder: placeholder, options: [.processor(smallResizingProcessor)])
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(attachmentTapped))

1
elpha-ios/AttachmentViewController.swift

@ -34,6 +34,7 @@ class AttachmentViewController: UIViewController {
if let attachment = attachment {
attachmentScrollView.delegate = self
attachmentImageView.kf.indicatorType = .activity
attachmentImageView.kf.setImage(with: attachment.url!)
if let content = attachment.status?.content {

34
elpha-ios/StatusTableViewController.swift

@ -206,6 +206,22 @@ class StatusTableViewController: AbstractStatusTableViewController, UIGestureRec
print("\(error)")
}
}
override func boostTapped() {
loadStatuses()
}
override func favoriteTapped() {
loadStatuses()
}
override func revealTapped() {
loadStatuses()
}
override func hideTapped() {
loadStatuses()
}
}
extension StatusTableViewController {
@ -346,24 +362,6 @@ extension StatusTableViewController {
}
}
extension StatusTableViewController {
func boostTapped() {
loadStatuses()
}
func favoriteTapped() {
loadStatuses()
}
func revealTapped() {
loadStatuses()
}
func hideTapped() {
loadStatuses()
}
}
extension StatusTableViewController: AttachmentManagerDelegate {
func attachmentTapped(index: Int) {
self.attachmentTapped(status: status!, index: index)

100
elpha-ios/StatusView.swift

@ -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
}
}

5
elpha-ios/String+HtmlAttributed.swift

@ -21,9 +21,8 @@ extension String {
color: \(color.hexString()) !important;
text-align: \(centered ? "center" : "initial") !important;
}
p {
margin: 0px !important;
padding: 0px !important;
p:last-child {
margin-bottom: 0px !important;
}
</style>
\(self)

Loading…
Cancel
Save