Skip to content

Commit

Permalink
Forward preview providing methods too
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela committed Sep 2, 2021
1 parent 7e9b9b9 commit b498546
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Source/IGListKit/IGListSectionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ NS_SWIFT_NAME(ListSectionController)
*/
- (UIContextMenuConfiguration * _Nullable)contextMenuConfigurationForItemAtIndex:(NSInteger)index point:(CGPoint)point API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(tvos);

/**
Tells the section controller that the cell has requested a preview for context menu highlight.
@param configuration Context menu configuration.
@return An object that conforms to `UITargetedPreview`
@note The default implementation does nothing. **Calling super is not required.**
*/
- (UITargetedPreview * _Nullable)previewForHighlightingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(tvos);

/**
Tells the section controller that the cell has requested a preview for context menu dismiss.
@param configuration Context menu configuration.
@return An object that conforms to `UITargetedPreview`
@note The default implementation does nothing. **Calling super is not required.**
*/
- (UITargetedPreview * _Nullable)previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(tvos);

/**
Identifies whether an object can be moved through interactive reordering.
Expand Down
8 changes: 8 additions & 0 deletions Source/IGListKit/IGListSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ - (UIContextMenuConfiguration * _Nullable)contextMenuConfigurationForItemAtIndex
return nil;
}

- (UITargetedPreview * _Nullable)previewForHighlightingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration {
return nil;
}

- (UITargetedPreview * _Nullable)previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration {
return nil;
}

- (BOOL)canMoveItemAtIndex:(NSInteger)index {
return NO;
}
Expand Down
20 changes: 20 additions & 0 deletions Source/IGListKit/Internal/IGListAdapter+UICollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,26 @@ - (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionVie
IGListSectionController * sectionController = [self sectionControllerForSection:indexPath.section];
return [sectionController contextMenuConfigurationForItemAtIndex:indexPath.item point:point];
}

- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForHighlightingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration {
id<UICollectionViewDelegate> collectionViewDelegate = self.collectionViewDelegate;
if ([collectionViewDelegate respondsToSelector:@selector(collectionView:previewForHighlightingContextMenuWithConfiguration:)]) {
return [collectionViewDelegate collectionView:collectionView previewForHighlightingContextMenuWithConfiguration:configuration];
}

IGListSectionController * sectionController = [self sectionControllerForSection:indexPath.section];
return [sectionController previewForHighlightingContextMenuWithConfiguration:configuration];
}

- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration {
id<UICollectionViewDelegate> collectionViewDelegate = self.collectionViewDelegate;
if ([collectionViewDelegate respondsToSelector:@selector(collectionView:previewForDismissingContextMenuWithConfiguration:)]) {
return [collectionViewDelegate collectionView:collectionView previewForDismissingContextMenuWithConfiguration:configuration];
}

IGListSectionController * sectionController = [self sectionControllerForSection:indexPath.section];
return [sectionController previewForDismissingContextMenuWithConfiguration:configuration];
}
#endif

#pragma mark - UICollectionViewDelegateFlowLayout
Expand Down
2 changes: 2 additions & 0 deletions Source/IGListKit/Internal/IGListAdapterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static BOOL isInterceptedSelector(SEL sel) {
sel == @selector(collectionView:didHighlightItemAtIndexPath:) ||
sel == @selector(collectionView:didUnhighlightItemAtIndexPath:) ||
sel == @selector(collectionView:contextMenuConfigurationForItemAtIndexPath:point:) ||
sel == @selector(collectionView:previewForHighlightingContextMenuWithConfiguration:) ||
sel == @selector(collectionView:previewForDismissingContextMenuWithConfiguration:) ||
// UICollectionViewDelegateFlowLayout
sel == @selector(collectionView:layout:sizeForItemAtIndexPath:) ||
sel == @selector(collectionView:layout:insetForSectionAtIndex:) ||
Expand Down

0 comments on commit b498546

Please sign in to comment.