session-ios/Session/Media Viewing & Editing/Transitions/MediaPresentationContext.swift
Morgan Pretty aabf656d89 Finished off the MediaGallery logic
Updated the config message generation for GRDB
Migrated more preferences into GRDB
Added paging to the MediaTileViewController and sorted out the various animations/transitions
Fixed an issue where the 'recipientState' for the 'baseQuery' on the ConversationCell.ViewModel wasn't grouping correctly
Fixed an issue where the MediaZoomAnimationController could fail if the contextual info wasn't available
Fixed an issue where the MediaZoomAnimationController bounce looked odd when returning to the detail screen from the tile screen
Fixed an issue where the MediaZoomAnimationController didn't work for videos
Fixed a bug where the YDB to GRDB migration wasn't properly handling video files
Fixed a number of minor UI bugs with the GalleryRailView
Deleted a bunch of legacy code
2022-05-20 17:58:39 +10:00

54 lines
2.1 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
enum Media {
case gallery(MediaGalleryViewModel.Item)
case image(UIImage)
var image: UIImage? {
switch self {
case let .gallery(item):
// For videos attempt to load a large thumbnail, for other items just try to load
// the source file directly
guard !item.isVideo else { return item.attachment.existingThumbnail(size: .large) }
guard let originalFilePath: String = item.attachment.originalFilePath else { return nil }
return UIImage(contentsOfFile: originalFilePath)
case let .image(image): return image
}
}
}
struct MediaPresentationContext {
let mediaView: UIView
let presentationFrame: CGRect
let cornerRadius: CGFloat
let cornerMask: CACornerMask
}
// There are two kinds of AnimationControllers that interact with the media detail view. Both
// appear to transition the media view from one VC to it's corresponding location in the
// destination VC.
//
// MediaPresentationContextProvider is either a target or destination VC which can provide the
// details necessary to facilite this animation.
//
// First, the MediaZoomAnimationController is non-interactive. We use it whenever we're going to
// show the Media detail pager.
//
// We can get there several ways:
// From conversation settings, this can be a push or a pop from the tileView.
// From conversationView/MessageDetails this can be a modal present or a pop from the tile view.
//
// The other animation controller, the MediaDismissAnimationController is used when we're going to
// stop showing the media pager. This can be a pop to the tile view, or a modal dismiss.
protocol MediaPresentationContextProvider {
func mediaPresentationContext(mediaItem: Media, in coordinateSpace: UICoordinateSpace) -> MediaPresentationContext?
// The transitionView will be presented below this view.
// If nil, the transitionView will be presented above all
func snapshotOverlayView(in coordinateSpace: UICoordinateSpace) -> (UIView, CGRect)?
}