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