Skip to content

Commit

Permalink
Merge branch 'master' into release_4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenceLove committed May 18, 2024
2 parents 7783de2 + b712ae4 commit ab67ad9
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github: [silence]
github: Silencelove
custom: [https://github.com/sponsors/SilenceLove]
2 changes: 1 addition & 1 deletion HXPhotoPicker-Lite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Pod::Spec.new do |spec|

spec.subspec 'Core' do |core|
core.source_files = "Sources/HXPhotoPicker/Core/**/*.{swift}"
core.dependency 'HXPhotoPicker/Resources'
core.dependency 'HXPhotoPicker-Lite/Resources'
end

spec.subspec 'Resources' do |resources|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class CameraNormalPreviewView: UIView {
connection.isVideoMirrored = true
}
}
DispatchQueue.main.async {
self.resetOrientation()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/HXPhotoPicker/Core/HXPhotoPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public enum HX {
}
#endif

#if HXPICKER_ENABLE_CAMERA
#if HXPICKER_ENABLE_CAMERA && !targetEnvironment(macCatalyst)
@available(iOS 13.0, *)
@MainActor
public static func capture(
Expand Down
2 changes: 1 addition & 1 deletion Sources/HXPhotoPicker/Core/Util/PhotoManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public final class PhotoManager: NSObject {
}
#endif

#if HXPICKER_ENABLE_CAMERA
#if HXPICKER_ENABLE_CAMERA && !targetEnvironment(macCatalyst)
var cameraType: CameraController.CameraType = .normal
#endif

Expand Down
134 changes: 76 additions & 58 deletions Sources/HXPhotoPicker/Picker/Transition/PhotoBrowserAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ open class PhotoBrowserAnimator: NSObject, PhotoBrowserAnimationTransitioning {
animatedImageView.image = image
}
}
#if canImport(Kingfisher)
if let networkImage = photoAsset.networkImageAsset {
requestNetworkImage(networkImage)
}
#endif
if UIDevice.isPad {
toRect = PhotoTools.transformImageSize(
photoAsset.imageSize,
Expand All @@ -125,48 +120,76 @@ open class PhotoBrowserAnimator: NSObject, PhotoBrowserAnimationTransitioning {
}else {
previewView?.isHidden = true
}
let duration = transitionDuration(using: transitionContext)
let colorDuration = duration - 0.15
let colorDelay: TimeInterval = 0.05
UIView.animate(withDuration: colorDuration, delay: colorDelay, options: [ .curveLinear]) {
toVC.previewViewController?.photoToolbar.alpha = 1
toVC.previewViewController?.navBgView?.alpha = 1
contentView.backgroundColor = backgroundColor.withAlphaComponent(1)
}
UIView.animate(
withDuration: duration,
delay: 0,
usingSpringWithDamping: 0.8,
initialSpringVelocity: 0,
options: [.layoutSubviews, .curveEaseOut]
) {
toVC.navigationBar.alpha = 1
if self.animatedImageView.layer.cornerRadius > 0 {
self.animatedImageView.layer.cornerRadius = 0
func animateHandler() {
let duration = transitionDuration(using: transitionContext)
let colorDuration = duration - 0.15
let colorDelay: TimeInterval = 0.05
UIView.animate(withDuration: colorDuration, delay: colorDelay, options: [ .curveLinear]) {
toVC.previewViewController?.photoToolbar.alpha = 1
toVC.previewViewController?.navBgView?.alpha = 1
contentView.backgroundColor = backgroundColor.withAlphaComponent(1)
}
self.animatedImageView.frame = toRect
toVC.pickerDelegate?
.pickerController(toVC, animateTransition: .present)
} completion: { _ in
previewView?.isHidden = false
toVC.isBrowserTransitioning = false
if let requestID = self.requestID {
PHImageManager.default().cancelImageRequest(requestID)
self.requestID = nil
UIView.animate(
withDuration: duration,
delay: 0,
usingSpringWithDamping: 0.8,
initialSpringVelocity: 0,
options: [.layoutSubviews, .curveEaseOut]
) {
toVC.navigationBar.alpha = 1
if self.animatedImageView.layer.cornerRadius > 0 {
self.animatedImageView.layer.cornerRadius = 0
}
self.animatedImageView.frame = toRect
toVC.pickerDelegate?
.pickerController(toVC, animateTransition: .present)
} completion: { _ in
previewView?.isHidden = false
toVC.isBrowserTransitioning = false
if let requestID = self.requestID {
PHImageManager.default().cancelImageRequest(requestID)
self.requestID = nil
}
toVC.pickerDelegate?.pickerController(
toVC,
previewPresentComplete: previewIndex
)
toVC.previewViewController?.view.backgroundColor = backgroundColor.withAlphaComponent(1)
toVC.previewViewController?.setCurrentCellImage(image: self.animatedImageView.image)
toVC.previewViewController?.collectionView.isHidden = false
toVC.previewViewController?.updateColors()
toVC.setupBackgroundColor()
self.animatedImageView.removeFromSuperview()
contentView.removeFromSuperview()
transitionContext.completeTransition(true)
}
toVC.pickerDelegate?.pickerController(
toVC,
previewPresentComplete: previewIndex
)
toVC.previewViewController?.view.backgroundColor = backgroundColor.withAlphaComponent(1)
toVC.previewViewController?.setCurrentCellImage(image: self.animatedImageView.image)
toVC.previewViewController?.collectionView.isHidden = false
toVC.previewViewController?.updateColors()
toVC.setupBackgroundColor()
self.animatedImageView.removeFromSuperview()
contentView.removeFromSuperview()
transitionContext.completeTransition(true)
}
#if canImport(Kingfisher)
if let networkImage = photoAsset?.networkImageAsset, networkImage.imageSize.equalTo(.zero) {
requestNetworkImage(networkImage) { [weak self] image in
guard let self, let image else {
animateHandler()
return
}
if self.animatedImageView.image == nil {
self.animatedImageView.image = image
}
photoAsset?.networkImageAsset?.imageSize = image.size
if UIDevice.isPad {
toRect = PhotoTools.transformImageSize(
image.size,
toViewSize: toVC.view.size,
directions: [.horizontal]
)
}else {
toRect = PhotoTools.transformImageSize(image.size, to: toVC.view)
}
animateHandler()
}
return
}
#endif
animateHandler()
}

open func requestAssetImage(for asset: PHAsset) {
Expand All @@ -191,22 +214,19 @@ open class PhotoBrowserAnimator: NSObject, PhotoBrowserAnimationTransitioning {
}

#if canImport(Kingfisher)
open func requestNetworkImage(_ networkImage: NetworkImageAsset) {
open func requestNetworkImage(_ networkImage: NetworkImageAsset, completion: @escaping(UIImage?) -> Void) {
if let cacheKey = networkImage.originalURL?.cacheKey,
ImageCache.default.isCached(forKey: cacheKey) {
ImageCache.default.retrieveImage(
forKey: cacheKey,
options: [],
callbackQueue: .mainAsync
) { [weak self] in
guard let self = self else { return }
) {
switch $0 {
case .success(let value):
if let image = value.image, self.animatedImageView.superview != nil {
self.animatedImageView.setImage(image, duration: 0.4, animated: true)
}
completion(value.image)
default:
break
completion(nil)
}
}
return
Expand All @@ -217,19 +237,17 @@ open class PhotoBrowserAnimator: NSObject, PhotoBrowserAnimationTransitioning {
forKey: cacheKey,
options: [],
callbackQueue: .mainAsync
) { [weak self] in
guard let self = self else { return }
) {
switch $0 {
case .success(let value):
if let image = value.image,
self.animatedImageView.superview != nil {
self.animatedImageView.setImage(image, duration: 0.4, animated: true)
}
completion(value.image)
default:
break
completion(nil)
}
}
return
}
completion(nil)
}
#endif

Expand Down
4 changes: 1 addition & 3 deletions Sources/HXPhotoPicker/Resources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict/>
</array>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
Expand Down

0 comments on commit ab67ad9

Please sign in to comment.