Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add long press preview for images #252

Merged
merged 1 commit into from
Jan 27, 2020
Merged

Add long press preview for images #252

merged 1 commit into from
Jan 27, 2020

Conversation

smeshko
Copy link

@smeshko smeshko commented Jan 13, 2020

Purpose

Adds long press preview to images.

Details

This PR adds support for long press previews of photos/videos.

On iOS versions <13.0 it only shows a preview of the selected asset, while on iOS 13+ it also adds a contextual menu with the option to select/deselect the previewed photo.

The previews support static photos, live photos and videos.

Changes

In order to achieve this, a new read-only property was added to TLPhotoCollectionViewCell:
open internal(set) var asset: PHAsset? as well as 2 delegate callbacks to TLPhotosPickerViewController.

public func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? is used for iOS <13 devices and only shows a preview of the photo on a force touch.

public func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? is used for iOS 13+ devices and shows the context menu to select/deselect the photo.

Screenshots

@smeshko smeshko requested a review from tilltue January 20, 2020 13:52
@tilltue tilltue merged commit 37a1067 into tilltue:master Jan 27, 2020
@tilltue
Copy link
Owner

tilltue commented Jan 27, 2020

@smeshko
Thanks for the PR!
I added a preview option, the default option is false to preserve the previous user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants