Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin committed May 6, 2024
1 parent f00945a commit b090456
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,55 @@ import UIKit

extension MPConfigurationMaker {
@discardableResult
public func setAllowImage(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setAllowImage(_ value: Bool) -> Self {
generalConfig.allowImage = value
return self
}

@discardableResult
public func setAllowGif(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setAllowGif(_ value: Bool) -> Self {
generalConfig.allowGif = value
return self
}

@discardableResult
public func setAllowVideo(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setAllowVideo(_ value: Bool) -> Self {
generalConfig.allowVideo = value
return self
}

@discardableResult
public func setAllowLivePhoto(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setAllowLivePhoto(_ value: Bool) -> Self {
generalConfig.allowLivePhoto = value
return self
}

@discardableResult
public func setMaxMediaSelectCount(_ value: Int) -> MPConfigurationMakerExtendable {
public func setMaxMediaSelectCount(_ value: Int) -> Self {
generalConfig.maxMediaSelectCount = value
return self
}

@discardableResult
public func setBundleLangsDeploy(_ value: Bundle) -> MPConfigurationMakerExtendable {
public func setBundleLangsDeploy(_ value: Bundle) -> Self {
generalConfig.bundleLangsDeploy = value
return self
}

@discardableResult
public func setKeysLangsDeploy(_ value: [String: String]) -> MPConfigurationMakerExtendable {
public func setKeysLangsDeploy(_ value: [String: String]) -> Self {
generalConfig.keysLangsDeploy = value
return self
}

@discardableResult
public func setStringCatalogType(_ value: MPGeneralConfiguration.StringCatalogType) -> MPConfigurationMakerExtendable {
public func setStringCatalogType(_ value: MPGeneralConfiguration.StringCatalogType) -> Self {
generalConfig.stringCatalogType = value
return self
}

@discardableResult
public func setGeneralConfiguration(_ value: MPGeneralConfiguration) -> MPConfigurationMakerExtendable {
public func setGeneralConfiguration(_ value: MPGeneralConfiguration) -> Self {
generalConfig = value
return self
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Extensions/MPConfigurationMaker+MPUIConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,43 @@ import UIKit

extension MPConfigurationMaker {
@discardableResult
public func setShowCounterOnSelectionButton(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setShowCounterOnSelectionButton(_ value: Bool) -> Self {
uiConfig.showCounterOnSelectionButton = value
return self
}

@discardableResult
public func setSelectionButtonCornersStyle(_ value: MPCheckboxStyle) -> MPConfigurationMakerExtendable {
public func setSelectionButtonCornersStyle(_ value: MPCheckboxStyle) -> Self {
uiConfig.selectionButtonCornersStyle = value
return self
}

@discardableResult
public func setSelectionButtonColorStyle(_ value: MPCheckboxColor) -> MPConfigurationMakerExtendable {
public func setSelectionButtonColorStyle(_ value: MPCheckboxColor) -> Self {
uiConfig.selectionButtonColorStyle = value
return self
}

@discardableResult
public func setNavigationAppearance(_ value: MPNavigationAppearance) -> MPConfigurationMakerExtendable {
public func setNavigationAppearance(_ value: MPNavigationAppearance) -> Self {
uiConfig.navigationAppearance = value
return self
}

@discardableResult
public func setPrimaryBackgroundColor(_ value: UIColor) -> MPConfigurationMakerExtendable {
public func setPrimaryBackgroundColor(_ value: UIColor) -> Self {
uiConfig.primaryBackgroundColor = value
return self
}

@discardableResult
public func setShowCameraCell(_ value: Bool) -> MPConfigurationMakerExtendable {
public func setShowCameraCell(_ value: Bool) -> Self {
uiConfig.showCameraCell = value
return self
}

@discardableResult
public func setUIConfiguration(_ value: MPUIConfiguration) -> MPConfigurationMakerExtendable {
public func setUIConfiguration(_ value: MPUIConfiguration) -> Self {
uiConfig = value
return self
}
Expand Down
36 changes: 18 additions & 18 deletions Sources/General/MPConfigurationMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@
import UIKit

public protocol MPUIConfigMakerExtendable: NSObjectProtocol {
func setShowCounterOnSelectionButton(_ value: Bool) -> MPConfigurationMakerExtendable
func setSelectionButtonCornersStyle(_ value: MPCheckboxStyle) -> MPConfigurationMakerExtendable
func setSelectionButtonColorStyle(_ value: MPCheckboxColor) -> MPConfigurationMakerExtendable
func setNavigationAppearance(_ value: MPNavigationAppearance) -> MPConfigurationMakerExtendable
func setPrimaryBackgroundColor(_ value: UIColor) -> MPConfigurationMakerExtendable
func setShowCameraCell(_ value: Bool) -> MPConfigurationMakerExtendable
func setUIConfiguration(_ value: MPUIConfiguration) -> MPConfigurationMakerExtendable
func setShowCounterOnSelectionButton(_ value: Bool) -> Self
func setSelectionButtonCornersStyle(_ value: MPCheckboxStyle) -> Self
func setSelectionButtonColorStyle(_ value: MPCheckboxColor) -> Self
func setNavigationAppearance(_ value: MPNavigationAppearance) -> Self
func setPrimaryBackgroundColor(_ value: UIColor) -> Self
func setShowCameraCell(_ value: Bool) -> Self
func setUIConfiguration(_ value: MPUIConfiguration) -> Self
}

public protocol MPGeneralConfigMakerExtendable: NSObjectProtocol {
func setAllowImage(_ value: Bool) -> MPConfigurationMakerExtendable
func setAllowGif(_ value: Bool) -> MPConfigurationMakerExtendable
func setAllowVideo(_ value: Bool) -> MPConfigurationMakerExtendable
func setAllowLivePhoto(_ value: Bool) -> MPConfigurationMakerExtendable
func setMaxMediaSelectCount(_ value: Int) -> MPConfigurationMakerExtendable
func setBundleLangsDeploy(_ value: Bundle) -> MPConfigurationMakerExtendable
func setKeysLangsDeploy(_ value: [String: String]) -> MPConfigurationMakerExtendable
func setStringCatalogType(_ value: MPGeneralConfiguration.StringCatalogType) -> MPConfigurationMakerExtendable
func setGeneralConfiguration(_ value: MPGeneralConfiguration) -> MPConfigurationMakerExtendable
func setAllowImage(_ value: Bool) -> Self
func setAllowGif(_ value: Bool) -> Self
func setAllowVideo(_ value: Bool) -> Self
func setAllowLivePhoto(_ value: Bool) -> Self
func setMaxMediaSelectCount(_ value: Int) -> Self
func setBundleLangsDeploy(_ value: Bundle) -> Self
func setKeysLangsDeploy(_ value: [String: String]) -> Self
func setStringCatalogType(_ value: MPGeneralConfiguration.StringCatalogType) -> Self
func setGeneralConfiguration(_ value: MPGeneralConfiguration) -> Self
}

public protocol MPConfigurationMakerExtendable: MPUIConfigMakerExtendable, MPGeneralConfigMakerExtendable {
var uiConfig: MPUIConfiguration { get }
var generalConfig: MPGeneralConfiguration { get }
static var `default`: MPConfigurationMakerExtendable { get }
static var `default`: Self { get }
}

public final class MPConfigurationMaker: NSObject, MPConfigurationMakerExtendable {
public static var `default`: MPConfigurationMakerExtendable {
public static var `default`: MPConfigurationMaker {
self.init()
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/General/MPPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final class MPPresenter: NSObject {
private var preSelectedResults: [MPPhotoModel]
private var selectedResult: (([MPResultModel]) -> ())? = nil
private var preSelectedResult: (([MPPhotoModel]) -> ())? = nil
private var config: MPConfigurationMakerExtendable = MPConfigurationMaker()
private var config = MPConfigurationMaker()
//private var uiConfig: MPUIConfiguration = .default()
//private var generalConfig: MPGeneralConfiguration = .default()

Expand All @@ -52,7 +52,7 @@ public final class MPPresenter: NSObject {
}

public func showMediaPicker(
configuration: ((MPConfigurationMakerExtendable) -> (MPConfigurationMakerExtendable))? = nil,
configuration: ((MPConfigurationMaker) -> (MPConfigurationMaker))? = nil,
selectedResult: @escaping ([MPResultModel]) -> (),
customPresentationStyle: ((UINavigationController) -> ())? = nil
) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/General/UILayer/MPCameraCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ final class MPCameraCell: CollectionViewCell {

private var photoOutput: AVCapturePhotoOutput?

private var previewLayer: AVCaptureVideoPreviewLayer?

private var videoOutput: AVCaptureVideoDataOutput?

private var previewLayer: AVCaptureVideoPreviewLayer?

var processSampleBuffer: ((CMSampleBuffer, CVImageBuffer, AVCaptureConnection) -> Void)?

var isEnable = true {
Expand Down Expand Up @@ -148,7 +148,7 @@ final class MPCameraCell: CollectionViewCell {
previewLayer?.videoGravity = .resizeAspectFill
contentView.layer.insertSublayer(previewLayer!, at: 0)

DispatchQueue.mp.background(qos: .userInitiated, background: { [weak self] in
DispatchQueue.mp.background(qos: .background, background: { [weak self] in
self?.session?.startRunning()
}, completion: { [weak self] in
self?.backgroundThumgnail.mp.setIsHidden(true, duration: 0.3)
Expand Down
31 changes: 0 additions & 31 deletions Sources/General/UILayer/MPViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ final class MPViewController: UIViewController {

private var wasCreateSnapshot: Bool = false

private var didAttemptToDismissWasCall = false

private var allowDragAndDrop = false
private var lastContentOffset: CGPoint = .zero
private var lastViewHeight: CGFloat = .zero
Expand Down Expand Up @@ -1088,18 +1086,6 @@ extension MPViewController: UICollectionViewDropDelegate {
previewParameters.backgroundColor = .clear
return previewParameters
}

func collectionView(_ collectionView: UICollectionView, dropSessionDidEnd session: any UIDropSession) {
debugPrint("collectionView dropSessionDidEnd")
}

func collectionView(_ collectionView: UICollectionView, dropSessionDidExit session: any UIDropSession) {
debugPrint("collectionView dropSessionDidExit")
}

func collectionView(_ collectionView: UICollectionView, dropSessionDidEnter session: any UIDropSession) {
debugPrint("collectionView dropSessionDidEnter")
}
}

// MARK: Photo library change observer
Expand Down Expand Up @@ -1208,28 +1194,11 @@ extension MPViewController: MediaPreviewControllerDelegate {

// MARK: - UISheetPresentationControllerDelegate
extension MPViewController: UISheetPresentationControllerDelegate {
func sheetPresentationControllerDidChangeSelectedDetentIdentifier(_ sheetPresentationController: UISheetPresentationController) {
debugPrint("sheetPresentationController view frame \(view.frame)")
debugPrint("sheetPresentationController view bounds \(view.bounds)")
}

func presentationControllerShouldDismiss(_ presentationController: UIPresentationController) -> Bool {
selectedModels.isEmpty
//if selectedModels.isEmpty {
// return true
//} else {
// // scheduledTimer is required to handle cases of attempting to close the sheet with tap outside
// didAttemptToDismissWasCall = false
// Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false, block: { [weak self] (_) in
// guard let strongSelf = self, !strongSelf.didAttemptToDismissWasCall else { return }
// strongSelf.dismissAlert(needDismiss: false)
// })
// return false
//}
}

func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) {
//didAttemptToDismissWasCall = true
dismissAlert(needDismiss: false)
}
}
Loading

0 comments on commit b090456

Please sign in to comment.