Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/Helpers/Permissions/YPPermissionCheckable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
import UIKit

internal protocol YPPermissionCheckable {
func doAfterLibraryPermissionCheck(block: @escaping () -> Void)
func doAfterLibraryPermissionCheck(block: @escaping () -> Void, permissionDeniedBlock: (() -> Void)?)
func doAfterCameraPermissionCheck(block: @escaping () -> Void)
func checkLibraryPermission()
func checkCameraPermission()
}

internal extension YPPermissionCheckable where Self: UIViewController {
func doAfterLibraryPermissionCheck(block: @escaping () -> Void) {
func doAfterLibraryPermissionCheck(block: @escaping () -> Void, permissionDeniedBlock: (() -> Void)? = nil) {
YPPermissionManager.checkLibraryPermissionAndAskIfNeeded(sourceVC: self) { hasPermission in
if hasPermission {
block()
} else {
permissionDeniedBlock?()
ypLog("Not enough permissions.")
}
}
Expand Down
9 changes: 7 additions & 2 deletions Source/Pages/Gallery/YPLibraryVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,17 @@ public final class YPLibraryVC: UIViewController, YPPermissionCheckable {
addToSelection(assetIndex: 0)
}
} else {
delegate?.libraryViewHaveNoItems()
libraryViewHaveNoItems()
}

scrollToTop()
}


func libraryViewHaveNoItems() {
v.hideLoader()
delegate?.libraryViewHaveNoItems()
}

func buildPHFetchOptions() -> PHFetchOptions {
// Sorting condition
if let userOpt = YPConfig.library.options {
Expand Down
4 changes: 2 additions & 2 deletions Source/YPImagePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ open class YPImagePicker: UINavigationController {
}

extension YPImagePicker: YPPickerVCDelegate {
func libraryHasNoItems() {
public func libraryHasNoItems() {
self.imagePickerDelegate?.imagePickerHasNoItemsInLibrary(self)
}

func shouldAddToSelection(indexPath: IndexPath, numSelections: Int) -> Bool {
public func shouldAddToSelection(indexPath: IndexPath, numSelections: Int) -> Bool {
return self.imagePickerDelegate?.shouldAddToSelection(indexPath: indexPath, numSelections: numSelections)
?? true
}
Expand Down
10 changes: 6 additions & 4 deletions Source/YPPickerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import Stevia
import Photos

protocol YPPickerVCDelegate: AnyObject {
public protocol YPPickerVCDelegate: AnyObject {
func libraryHasNoItems()
func shouldAddToSelection(indexPath: IndexPath, numSelections: Int) -> Bool
}
Expand All @@ -26,7 +26,7 @@ open class YPPickerVC: YPBottomPager, YPBottomPagerDelegate {
let albumsManager = YPAlbumsManager()
var shouldHideStatusBar = false
var initialStatusBarHidden = false
weak var pickerVCDelegate: YPPickerVCDelegate?
public weak var pickerVCDelegate: YPPickerVCDelegate?

override open var prefersStatusBarHidden: Bool {
return (shouldHideStatusBar || initialStatusBarHidden) && YPConfig.hidesStatusBar
Expand Down Expand Up @@ -181,9 +181,11 @@ open class YPPickerVC: YPBottomPager, YPBottomPagerDelegate {

// Re-trigger permission check
if let vc = vc as? YPLibraryVC {
vc.doAfterLibraryPermissionCheck { [weak vc] in
vc.doAfterLibraryPermissionCheck(block: { [weak vc] in
vc?.initialize()
}
}, permissionDeniedBlock: { [weak vc] in
vc?.libraryViewHaveNoItems()
})
} else if let cameraVC = vc as? YPCameraVC {
cameraVC.start()
} else if let videoVC = vc as? YPVideoCaptureVC {
Expand Down
Loading