Skip to content

Commit

Permalink
Merge pull request #683 from zrn-ns/feature/add_option_to_disable_pre…
Browse files Browse the repository at this point in the history
…view_on_longpressing_cell

Add option to disable preview on long-pressing cell
  • Loading branch information
zhangao0086 authored Feb 6, 2021
2 parents e61f49b + 05e880c commit 9a00af4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ open class DKImagePickerControllerBaseUIDelegate: NSObject, DKImagePickerControl
return DKAssetGroupCell.self
}

open func needsToShowPreviewOnLongPress() -> Bool {
return true
}

open func imagePickerControllerSelectGroupButton(_ imagePickerController: DKImagePickerController, selectedGroup: DKAssetGroup) -> UIButton {
let button = self.createSelectGroupButtonIfNeeded()
let groupsCount = self.imagePickerController.groupDataManager.groupIds?.count ?? 0
Expand Down
13 changes: 8 additions & 5 deletions Sources/DKImagePickerController/View/DKAssetGroupDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,14 @@ open class DKAssetGroupDetailVC: UIViewController,
cell.thumbnailImage = image
}
}

cell.longPressBlock = { [weak self, weak cell] in
guard let strongSelf = self, let strongCell = cell else { return }

strongSelf.showGallery(from: strongCell)

if let imagePickerController = imagePickerController,
imagePickerController.UIDelegate.needsToShowPreviewOnLongPress() {

cell.longPressBlock = { [weak self, weak cell] in
guard let strongSelf = self, let strongCell = cell else { return }
strongSelf.showGallery(from: strongCell)
}
}
}

Expand Down

0 comments on commit 9a00af4

Please sign in to comment.