Skip to content

Commit

Permalink
[CENG-1897] Bugfixes to use package in cooking (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
osvaldonytimes authored Oct 29, 2022
1 parent 351125f commit 6958d35
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes for users of the library currently on `5.0.8`:
- using metadata to add summary to share activity

## [5.0.7](https://github.com/nytimes/NYTPhotoViewer/releases/tag/5.0.7)

Changes for users of the library currently on `5.0.7`:
Expand Down
28 changes: 25 additions & 3 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "NYTPhotosOverlayView.h"
#import "NYTPhotoCaptionView.h"
#import "NSBundle+NYTPhotoViewer.h"
#import <LinkPresentation/LPLinkMetadata.h>

#ifdef ANIMATED_GIF_SUPPORT
#if SWIFT_PACKAGE
Expand All @@ -37,7 +38,7 @@
static const CGFloat NYTPhotosViewControllerInterPhotoSpacing = 16.0;
static const UIEdgeInsets NYTPhotosViewControllerCloseButtonImageInsets = {3, 0, -3, 0};

@interface NYTPhotosViewController () <UIPageViewControllerDataSource, UIPageViewControllerDelegate, NYTPhotoViewControllerDelegate>
@interface NYTPhotosViewController () <UIActivityItemSource, UIPageViewControllerDataSource, UIPageViewControllerDelegate, NYTPhotoViewControllerDelegate>

- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

Expand Down Expand Up @@ -298,8 +299,7 @@ - (void)actionButtonTapped:(id)sender {

if (!clientDidHandle && (self.currentlyDisplayedPhoto.image || self.currentlyDisplayedPhoto.imageData)) {
UIImage *image = self.currentlyDisplayedPhoto.image ? self.currentlyDisplayedPhoto.image : [UIImage imageWithData:self.currentlyDisplayedPhoto.imageData];
NSString *summary = self.currentlyDisplayedPhoto.attributedCaptionSummary.string;
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[summary, image] applicationActivities:nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self, image] applicationActivities:nil];
activityViewController.popoverPresentationController.barButtonItem = sender;
activityViewController.completionWithItemsHandler = ^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
if (completed && [self.delegate respondsToSelector:@selector(photosViewController:actionCompletedWithActivityType:)]) {
Expand Down Expand Up @@ -654,4 +654,26 @@ - (void)pageViewController:(UIPageViewController *)pageViewController didFinishA
}
}

#pragma mark UIActivityItemSource protocol procedures to support sharesheet

/// called to fetch data after an activity is selected. you can return nil.
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
{
return nil;
}

/// called to determine data type. only the class of the return type is consulted. it should match what -itemForActivityType: returns later
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController
{
return nil;
}

/// called to fetch LinkPresentation metadata for the activity item. iOS 13.0
- (LPLinkMetadata *)activityViewControllerLinkMetadata:(UIActivityViewController *)activityViewController API_AVAILABLE(ios(13.0))
{
LPLinkMetadata * metaData = [[LPLinkMetadata alloc] init];
metaData.title = self.currentlyDisplayedPhoto.attributedCaptionSummary.string;
return metaData;
}

@end

0 comments on commit 6958d35

Please sign in to comment.