2021-04-28 09:02:34 +02:00
|
|
|
//
|
|
|
|
// MediaPreviewableViewController.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-4-28.
|
|
|
|
//
|
|
|
|
|
2021-04-28 13:06:45 +02:00
|
|
|
import UIKit
|
2021-04-28 09:02:34 +02:00
|
|
|
|
2021-05-11 10:11:00 +02:00
|
|
|
protocol MediaPreviewableViewController: UIViewController {
|
2021-04-28 09:02:34 +02:00
|
|
|
var mediaPreviewTransitionController: MediaPreviewTransitionController { get }
|
2021-04-28 13:06:45 +02:00
|
|
|
func sourceFrame(transitionItem: MediaPreviewTransitionItem, index: Int) -> CGRect?
|
|
|
|
}
|
|
|
|
|
|
|
|
extension MediaPreviewableViewController {
|
|
|
|
func sourceFrame(transitionItem: MediaPreviewTransitionItem, index: Int) -> CGRect? {
|
|
|
|
switch transitionItem.source {
|
2022-01-27 14:23:39 +01:00
|
|
|
case .attachment(let mediaView):
|
|
|
|
return mediaView.superview?.convert(mediaView.frame, to: nil)
|
|
|
|
case .attachments(let mediaGridContainerView):
|
|
|
|
guard index < mediaGridContainerView.mediaViews.count else { return nil }
|
|
|
|
let mediaView = mediaGridContainerView.mediaViews[index]
|
|
|
|
return mediaView.superview?.convert(mediaView.frame, to: nil)
|
2021-04-28 14:10:17 +02:00
|
|
|
case .profileAvatar(let profileHeaderView):
|
2022-01-27 14:23:39 +01:00
|
|
|
return profileHeaderView.avatarButton.superview?.convert(profileHeaderView.avatarButton.frame, to: nil)
|
2022-07-14 21:42:41 +02:00
|
|
|
case .profileBanner(let profileHeaderView):
|
|
|
|
return profileHeaderView.bannerImageView.superview?.convert(profileHeaderView.bannerImageView.frame, to: nil)
|
2021-04-28 13:06:45 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|