Compare commits
No commits in common. "d7953470e30c3c7114a7be235e62f6a0979ae804" and "f2e08e96f3347c53528f316e7ebb451b7e109ebe" have entirely different histories.
d7953470e3
...
f2e08e96f3
|
@ -94,9 +94,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
||||||
self.statuses.append(contentsOf: newStatuses.map { ($0.id, .unknown) })
|
self.statuses.append(contentsOf: newStatuses.map { ($0.id, .unknown) })
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
UIView.performWithoutAnimation {
|
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
||||||
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class GalleryViewController: UIPageViewController, UIPageViewControllerDataSourc
|
||||||
switch $0.kind {
|
switch $0.kind {
|
||||||
case .image:
|
case .image:
|
||||||
return AttachmentViewController(attachment: $0)
|
return AttachmentViewController(attachment: $0)
|
||||||
case .video, .audio:
|
case .video:
|
||||||
let vc = AVPlayerViewController()
|
let vc = AVPlayerViewController()
|
||||||
vc.player = AVPlayer(url: $0.url)
|
vc.player = AVPlayer(url: $0.url)
|
||||||
return vc
|
return vc
|
||||||
|
|
|
@ -37,6 +37,8 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
||||||
@IBOutlet weak var bottomControlsView: UIView!
|
@IBOutlet weak var bottomControlsView: UIView!
|
||||||
@IBOutlet weak var descriptionLabel: UILabel!
|
@IBOutlet weak var descriptionLabel: UILabel!
|
||||||
|
|
||||||
|
var initializedTopControlsConstrains = false
|
||||||
|
|
||||||
var image: UIImage?
|
var image: UIImage?
|
||||||
var gifData: Data?
|
var gifData: Data?
|
||||||
var imageDescription: String?
|
var imageDescription: String?
|
||||||
|
@ -118,13 +120,16 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
||||||
|
|
||||||
centerImage()
|
centerImage()
|
||||||
|
|
||||||
if view.safeAreaInsets.top == 44 {
|
if !initializedTopControlsConstrains {
|
||||||
// running on iPhone X style notched device
|
initializedTopControlsConstrains = true
|
||||||
let notchWidth: CGFloat = 209
|
if view.safeAreaInsets.top == 44 {
|
||||||
let earWidth = (view.bounds.width - notchWidth) / 2
|
// running on iPhone X style notched device
|
||||||
let offset = (earWidth - shareButton.bounds.width) / 2
|
let notchWidth: CGFloat = 209
|
||||||
shareButtonLeadingConstraint.constant = offset
|
let earWidth = (view.bounds.width - notchWidth) / 2
|
||||||
closeButtonTrailingConstraint.constant = offset
|
let offset = (earWidth - shareButton.bounds.width) / 2
|
||||||
|
shareButtonLeadingConstraint.constant = offset
|
||||||
|
closeButtonTrailingConstraint.constant = offset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,9 +143,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
self.older = pagination?.older
|
self.older = pagination?.older
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
UIView.performWithoutAnimation {
|
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
||||||
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,10 +224,8 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
let newIndexPaths = (0..<groups.count).map {
|
let newIndexPaths = (0..<groups.count).map {
|
||||||
IndexPath(row: $0, section: 0)
|
IndexPath(row: $0, section: 0)
|
||||||
}
|
}
|
||||||
UIView.performWithoutAnimation {
|
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
||||||
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
|
|
||||||
// maintain the current position in the list (don't scroll to top)
|
// maintain the current position in the list (don't scroll to top)
|
||||||
|
|
|
@ -106,9 +106,7 @@ class TimelineTableViewController: EnhancedTableViewController {
|
||||||
let newIndexPaths = newRows.map { IndexPath(row: $0, section: self.timelineSegments.count - 1) }
|
let newIndexPaths = newRows.map { IndexPath(row: $0, section: self.timelineSegments.count - 1) }
|
||||||
self.timelineSegments[self.timelineSegments.count - 1].append(contentsOf: newStatuses.map { ($0.id, .unknown) })
|
self.timelineSegments[self.timelineSegments.count - 1].append(contentsOf: newStatuses.map { ($0.id, .unknown) })
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
UIView.performWithoutAnimation {
|
self.tableView.insertRows(at: newIndexPaths, with: .none)
|
||||||
self.tableView.insertRows(at: newIndexPaths, with: .none)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,9 +142,7 @@ class TimelineTableViewController: EnhancedTableViewController {
|
||||||
let newIndexPaths = (0..<newStatuses.count).map {
|
let newIndexPaths = (0..<newStatuses.count).map {
|
||||||
IndexPath(row: $0, section: 0)
|
IndexPath(row: $0, section: 0)
|
||||||
}
|
}
|
||||||
UIView.performWithoutAnimation {
|
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
||||||
self.tableView.insertRows(at: newIndexPaths, with: .automatic)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
|
|
||||||
weak var delegate: AttachmentViewDelegate?
|
weak var delegate: AttachmentViewDelegate?
|
||||||
|
|
||||||
var playImageView: UIImageView?
|
var playImageView: UIImageView!
|
||||||
|
|
||||||
var attachment: Attachment!
|
var attachment: Attachment!
|
||||||
var index: Int!
|
var index: Int!
|
||||||
|
@ -54,21 +54,25 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imagePressed)))
|
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imagePressed)))
|
||||||
|
|
||||||
|
playImageView = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
||||||
|
playImageView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
addSubview(playImageView)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
playImageView.widthAnchor.constraint(equalToConstant: 50),
|
||||||
|
playImageView.heightAnchor.constraint(equalToConstant: 50),
|
||||||
|
playImageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||||
|
playImageView.centerYAnchor.constraint(equalTo: centerYAnchor)
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadAttachment() {
|
func loadAttachment() {
|
||||||
guard AttachmentsContainerView.supportedAttachmentTypes.contains(attachment.kind) else {
|
|
||||||
preconditionFailure("invalid attachment type")
|
|
||||||
}
|
|
||||||
switch attachment.kind {
|
switch attachment.kind {
|
||||||
case .image:
|
case .image:
|
||||||
loadImage()
|
loadImage()
|
||||||
case .video:
|
case .video:
|
||||||
loadVideo()
|
loadVideo()
|
||||||
case .audio:
|
|
||||||
loadAudio()
|
|
||||||
default:
|
default:
|
||||||
preconditionFailure("invalid attachment type")
|
fatalError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +89,8 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playImageView.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadVideo() {
|
func loadVideo() {
|
||||||
|
@ -100,36 +106,7 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let playImageView = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
playImageView.isHidden = false
|
||||||
playImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(playImageView)
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
playImageView.widthAnchor.constraint(equalToConstant: 50),
|
|
||||||
playImageView.heightAnchor.constraint(equalToConstant: 50),
|
|
||||||
playImageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
||||||
playImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadAudio() {
|
|
||||||
let label = UILabel()
|
|
||||||
label.text = "Audio Only"
|
|
||||||
let playImageView = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
|
||||||
let stack = UIStackView(arrangedSubviews: [
|
|
||||||
label,
|
|
||||||
playImageView
|
|
||||||
])
|
|
||||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
stack.axis = .vertical
|
|
||||||
stack.spacing = 8
|
|
||||||
stack.alignment = .center
|
|
||||||
addSubview(stack)
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
stack.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
||||||
stack.centerYAnchor.constraint(equalTo: centerYAnchor),
|
|
||||||
playImageView.widthAnchor.constraint(equalToConstant: 50),
|
|
||||||
playImageView.heightAnchor.constraint(equalToConstant: 50),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func display(_ layer: CALayer) {
|
override func display(_ layer: CALayer) {
|
||||||
|
|
|
@ -11,8 +11,6 @@ import Pachyderm
|
||||||
|
|
||||||
class AttachmentsContainerView: UIView {
|
class AttachmentsContainerView: UIView {
|
||||||
|
|
||||||
static let supportedAttachmentTypes = [Attachment.Kind.image, .video, .audio]
|
|
||||||
|
|
||||||
weak var delegate: AttachmentViewDelegate?
|
weak var delegate: AttachmentViewDelegate?
|
||||||
|
|
||||||
var statusID: String!
|
var statusID: String!
|
||||||
|
@ -49,7 +47,7 @@ class AttachmentsContainerView: UIView {
|
||||||
|
|
||||||
func updateUI(status: Status) {
|
func updateUI(status: Status) {
|
||||||
self.statusID = status.id
|
self.statusID = status.id
|
||||||
attachments = status.attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) }
|
attachments = status.attachments.filter { $0.kind == .image || $0.kind == .video }
|
||||||
|
|
||||||
attachmentViews.allObjects.forEach { $0.removeFromSuperview() }
|
attachmentViews.allObjects.forEach { $0.removeFromSuperview() }
|
||||||
attachmentViews.removeAllObjects()
|
attachmentViews.removeAllObjects()
|
||||||
|
|
Loading…
Reference in New Issue