diff --git a/Tusker/Extensions/UIViewController+Delegates.swift b/Tusker/Extensions/UIViewController+Delegates.swift index eae9396df6..516d158143 100644 --- a/Tusker/Extensions/UIViewController+Delegates.swift +++ b/Tusker/Extensions/UIViewController+Delegates.swift @@ -58,10 +58,10 @@ extension UIViewController: StatusTableViewCellDelegate { present(vc, animated: true) } - func showLargeAttachment(for attachmentView: AttachmentView) { - let vc = LargeImageViewController.create(image: attachmentView.image!, description: attachmentView.attachment.description) + func showLargeImage(_ image: UIImage, description: String?, animatingFrom originView: UIView) { + let vc = LargeImageViewController.create(image: image, description: description) vc.delegate = self - var frame = attachmentView.convert(attachmentView.bounds, to: view) + var frame = originView.convert(originView.bounds, to: view) if let scrollView = view as? UIScrollView { let scale = scrollView.zoomScale let width = frame.width * scale @@ -71,6 +71,7 @@ extension UIViewController: StatusTableViewCellDelegate { frame = CGRect(x: x, y: y, width: width, height: height) } vc.originFrame = frame + vc.originCornerRadius = originView.layer.cornerRadius vc.transitioningDelegate = self present(vc, animated: true) } diff --git a/Tusker/View Controllers/LargeImageViewController.swift b/Tusker/View Controllers/LargeImageViewController.swift index a50d7f8069..fa1e198456 100644 --- a/Tusker/View Controllers/LargeImageViewController.swift +++ b/Tusker/View Controllers/LargeImageViewController.swift @@ -25,6 +25,7 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate { var delegate: LargeImageViewControllerDelegate? var originFrame: CGRect? + var originCornerRadius: CGFloat? var dismissInteractionController: LargeImageInteractionController? @IBOutlet weak var scrollView: UIScrollView! diff --git a/Tusker/View Controllers/Transitions/LargeImageExpandAnimationController.swift b/Tusker/View Controllers/Transitions/LargeImageExpandAnimationController.swift index eed9b00743..8378a18888 100644 --- a/Tusker/View Controllers/Transitions/LargeImageExpandAnimationController.swift +++ b/Tusker/View Controllers/Transitions/LargeImageExpandAnimationController.swift @@ -32,7 +32,7 @@ class LargeImageExpandAnimationController: NSObject, UIViewControllerAnimatedTra let imageView = UIImageView(frame: originFrame) imageView.image = toVC.image! imageView.contentMode = .scaleAspectFill - imageView.layer.cornerRadius = 5 + imageView.layer.cornerRadius = toVC.originCornerRadius! imageView.layer.masksToBounds = true let blackView = UIView(frame: finalVCFrame) @@ -48,6 +48,7 @@ class LargeImageExpandAnimationController: NSObject, UIViewControllerAnimatedTra let duration = transitionDuration(using: transitionContext) UIView.animate(withDuration: duration, animations: { imageView.frame = finalFrame + imageView.layer.cornerRadius = 0 blackView.alpha = 1 }, completion: { _ in toVC.view.isHidden = false diff --git a/Tusker/View Controllers/Transitions/LargeImageShrinkAnimationController.swift b/Tusker/View Controllers/Transitions/LargeImageShrinkAnimationController.swift index 0638d65c87..e188740ca6 100644 --- a/Tusker/View Controllers/Transitions/LargeImageShrinkAnimationController.swift +++ b/Tusker/View Controllers/Transitions/LargeImageShrinkAnimationController.swift @@ -39,7 +39,7 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra let imageView = UIImageView(frame: originalFrame) imageView.image = fromVC.image! imageView.contentMode = .scaleAspectFill - imageView.layer.cornerRadius = 5 + imageView.layer.cornerRadius = 0 imageView.layer.masksToBounds = true let blackView = UIView(frame: originalVCFrame) @@ -53,6 +53,7 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra let duration = transitionDuration(using: transitionContext) UIView.animate(withDuration: duration, animations: { imageView.frame = finalFrame + imageView.layer.cornerRadius = fromVC.originCornerRadius! blackView.alpha = 0 }, completion: { _ in blackView.removeFromSuperview() diff --git a/Tusker/Views/ConversationMainStatusTableViewCell.swift b/Tusker/Views/ConversationMainStatusTableViewCell.swift index 0248702a92..9498d57499 100644 --- a/Tusker/Views/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/ConversationMainStatusTableViewCell.swift @@ -167,6 +167,6 @@ extension ConversationMainStatusTableViewCell: HTMLContentLabelDelegate { extension ConversationMainStatusTableViewCell: AttachmentViewDelegate { func showLargeAttachment(for attachmentView: AttachmentView) { - delegate?.showLargeAttachment(for: attachmentView) + delegate?.showLargeImage(attachmentView.image!, description: attachmentView.attachment.description, animatingFrom: attachmentView) } } diff --git a/Tusker/Views/ProfileHeaderTableViewCell.swift b/Tusker/Views/ProfileHeaderTableViewCell.swift index fa41192e4b..6b0fe1ae86 100644 --- a/Tusker/Views/ProfileHeaderTableViewCell.swift +++ b/Tusker/Views/ProfileHeaderTableViewCell.swift @@ -35,6 +35,10 @@ class ProfileHeaderTableViewCell: UITableViewCell, PreferencesAdaptive { override func awakeFromNib() { avatarContainerView.layer.masksToBounds = true avatarImageView.layer.masksToBounds = true + avatarImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(avatarPressed))) + avatarImageView.isUserInteractionEnabled = true + headerImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(headerPressed))) + headerImageView.isUserInteractionEnabled = true } func updateUIForPreferences() { @@ -88,6 +92,14 @@ class ProfileHeaderTableViewCell: UITableViewCell, PreferencesAdaptive { delegate?.showMoreOptions() } + @objc func avatarPressed() { + delegate?.showLargeImage(avatarImageView.image!, description: nil, animatingFrom: avatarImageView) + } + + @objc func headerPressed() { + delegate?.showLargeImage(headerImageView.image!, description: nil, animatingFrom: headerImageView) + } + } extension ProfileHeaderTableViewCell: HTMLContentLabelDelegate { diff --git a/Tusker/Views/ProfileHeaderTableViewCell.xib b/Tusker/Views/ProfileHeaderTableViewCell.xib index c151c86e67..5147d9c32d 100644 --- a/Tusker/Views/ProfileHeaderTableViewCell.xib +++ b/Tusker/Views/ProfileHeaderTableViewCell.xib @@ -44,6 +44,7 @@ + diff --git a/Tusker/Views/StatusTableViewCell.swift b/Tusker/Views/StatusTableViewCell.swift index 453fefa079..9cf058dfe5 100644 --- a/Tusker/Views/StatusTableViewCell.swift +++ b/Tusker/Views/StatusTableViewCell.swift @@ -23,7 +23,7 @@ protocol StatusTableViewCellDelegate { func reply(to status: Status) - func showLargeAttachment(for attachmentView: AttachmentView) + func showLargeImage(_ image: UIImage, description: String?, animatingFrom originView: UIView) } @@ -210,6 +210,6 @@ extension StatusTableViewCell: HTMLContentLabelDelegate { extension StatusTableViewCell: AttachmentViewDelegate { func showLargeAttachment(for attachmentView: AttachmentView) { - delegate?.showLargeAttachment(for: attachmentView) + delegate?.showLargeImage(attachmentView.image!, description: attachmentView.attachment.description, animatingFrom: attachmentView) } }