[ABANDONED] Mastodon iOS client.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

//
// AttachmentViewController.swift
// elpha-ios
//
// Created by Dwayne Harris on 11/1/18.
// Copyright © 2018 Elpha. All rights reserved.
//
import Kingfisher
import UIKit
class AttachmentViewController: UIViewController {
@IBOutlet var attachmentScrollView: UIScrollView!
@IBOutlet var attachmentImageView: UIImageView!
@IBOutlet var statusTextView: UITextView!
var attachment: AttachmentMO?
@IBAction func closeTapped(_ sender: Any) {
if let controller = self.parent as? AttachmentPageViewController {
controller.dismissController()
}
}
@IBAction func shareTapped(_ sender: Any) {
if let image = attachmentImageView.image {
let controller = UIActivityViewController(activityItems: [image], applicationActivities: nil)
present(controller, animated: true)
}
}
override func viewDidLoad() {
super.viewDidLoad()
if let attachment = attachment {
attachmentScrollView.delegate = self
attachmentImageView.kf.indicatorType = .activity
attachmentImageView.kf.setImage(with: attachment.url!)
if let content = attachment.status?.content {
statusTextView.attributedText = content.htmlAttributed(size: 14, centered: true, color: UIColor.white)
}
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override var prefersStatusBarHidden: Bool {
return true
}
}
extension AttachmentViewController: UIScrollViewDelegate {
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return attachmentImageView
}
}