diff --git a/.swift-version b/.swift-version index a3ec5a4..95ee81a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.2 +5.9 diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/INSPhotoGallery.podspec b/INSPhotoGallery.podspec index 956b881..5231aa4 100644 --- a/INSPhotoGallery.podspec +++ b/INSPhotoGallery.podspec @@ -11,6 +11,6 @@ Pod::Spec.new do |s| s.ios.resource_bundle = { s.name => ['INSPhotoGallery/INSPhotoGallery.bundle/*'] } s.source_files = 'INSPhotoGallery/**/*.{h,m,swift}' - s.platform = :ios, '8.0' + s.platform = :ios, '15.0' s.frameworks = 'UIKit', 'Foundation' end diff --git a/INSPhotoGallery/INSPhoto.swift b/INSPhotoGallery/INSPhoto.swift index 6e7dd9b..3277dff 100644 --- a/INSPhotoGallery/INSPhoto.swift +++ b/INSPhotoGallery/INSPhoto.swift @@ -23,7 +23,7 @@ import UIKit * This is marked as @objc because of Swift bug http://stackoverflow.com/questions/30100787/fatal-error-array-cannot-be-bridged-from-objective-c-why-are-you-even-trying when passing for example [INSPhoto] array * to INSPhotosViewController */ -@objc public protocol INSPhotoViewable: class { +@objc public protocol INSPhotoViewable: AnyObject { var image: UIImage? { get } var thumbnailImage: UIImage? { get } @objc optional var isDeletable: Bool { get } diff --git a/INSPhotoGallery/INSPhotoViewController.swift b/INSPhotoGallery/INSPhotoViewController.swift index d1ba13b..d6b448a 100644 --- a/INSPhotoGallery/INSPhotoViewController.swift +++ b/INSPhotoGallery/INSPhotoViewController.swift @@ -43,7 +43,7 @@ open class INSPhotoViewController: UIViewController, UIScrollViewDelegate { }() lazy private(set) var activityIndicator: UIActivityIndicatorView = { - let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .white) + let activityIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.medium) activityIndicator.startAnimating() return activityIndicator }() @@ -96,7 +96,7 @@ open class INSPhotoViewController: UIViewController, UIScrollViewDelegate { } private func loadThumbnailImage() { - view.bringSubview(toFront: activityIndicator) + view.bringSubviewToFront(activityIndicator) photo.loadThumbnailImageWithCompletionHandler { [weak self] (image, error) -> () in let completeLoading = { @@ -118,7 +118,7 @@ open class INSPhotoViewController: UIViewController, UIScrollViewDelegate { } private func loadFullSizeImage() { - view.bringSubview(toFront: activityIndicator) + view.bringSubviewToFront(activityIndicator) self.photo.loadImageWithCompletionHandler({ [weak self] (image, error) -> () in let completeLoading = { self?.activityIndicator.stopAnimating() @@ -136,7 +136,7 @@ open class INSPhotoViewController: UIViewController, UIScrollViewDelegate { } @objc private func handleLongPressWithGestureRecognizer(_ recognizer: UILongPressGestureRecognizer) { - if recognizer.state == UIGestureRecognizerState.began { + if recognizer.state == UIGestureRecognizer.State.began { longPressGestureHandler?(recognizer) } } diff --git a/INSPhotoGallery/INSPhotosDataSource.swift b/INSPhotoGallery/INSPhotosDataSource.swift index 36f7480..7fabfa8 100644 --- a/INSPhotoGallery/INSPhotosDataSource.swift +++ b/INSPhotoGallery/INSPhotosDataSource.swift @@ -34,7 +34,7 @@ public struct INSPhotosDataSource { } public func indexOfPhoto(_ photo: INSPhotoViewable) -> Int? { - return photos.index(where: { $0 === photo}) + return photos.firstIndex(where: { $0 === photo}) } public func containsPhoto(_ photo: INSPhotoViewable) -> Bool { diff --git a/INSPhotoGallery/INSPhotosInteractionAnimator.swift b/INSPhotoGallery/INSPhotosInteractionAnimator.swift index 1c74bb3..7aac31d 100644 --- a/INSPhotoGallery/INSPhotosInteractionAnimator.swift +++ b/INSPhotoGallery/INSPhotosInteractionAnimator.swift @@ -60,7 +60,7 @@ public class INSPhotosInteractionAnimator: NSObject, UIViewControllerInteractive let velocityY = gestureRecognizer.velocity(in: gestureRecognizer.view).y var animationDuration = (Double(abs(velocityY)) * returnToCenterVelocityAnimationRatio) + 0.2 - var animationCurve: UIViewAnimationOptions = .curveEaseOut + var animationCurve: UIView.AnimationOptions = .curveEaseOut var finalPageViewCenterPoint = anchorPoint var finalBackgroundAlpha = 1.0 diff --git a/INSPhotoGallery/INSPhotosOverlayView.swift b/INSPhotoGallery/INSPhotosOverlayView.swift index 1005cfc..88c78fd 100644 --- a/INSPhotoGallery/INSPhotosOverlayView.swift +++ b/INSPhotoGallery/INSPhotosOverlayView.swift @@ -19,8 +19,8 @@ import UIKit -public protocol INSPhotosOverlayViewable:class { - weak var photosViewController: INSPhotosViewController? { get set } +public protocol INSPhotosOverlayViewable: AnyObject { + var photosViewController: INSPhotosViewController? { get set } func populateWithPhoto(_ photo: INSPhotoViewable) func setHidden(_ hidden: Bool, animated: Bool) @@ -57,7 +57,7 @@ open class INSPhotosOverlayView: UIView , INSPhotosOverlayViewable { } #if swift(>=4.0) - open var titleTextAttributes: [NSAttributedStringKey : AnyObject] = [:] { + open var titleTextAttributes: [NSAttributedString.Key : AnyObject] = [:] { didSet { navigationBar.titleTextAttributes = titleTextAttributes } diff --git a/INSPhotoGallery/INSPhotosTransitionAnimator.swift b/INSPhotoGallery/INSPhotosTransitionAnimator.swift index be242be..f323cc3 100644 --- a/INSPhotoGallery/INSPhotosTransitionAnimator.swift +++ b/INSPhotoGallery/INSPhotosTransitionAnimator.swift @@ -96,7 +96,7 @@ public class INSPhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTran if dismissing { if let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from) { - transitionContext.containerView.bringSubview(toFront: fromView) + transitionContext.containerView.bringSubviewToFront(fromView) } } } diff --git a/INSPhotoGallery/INSPhotosViewController.swift b/INSPhotoGallery/INSPhotosViewController.swift index bc6f19f..59dc479 100644 --- a/INSPhotoGallery/INSPhotosViewController.swift +++ b/INSPhotoGallery/INSPhotosViewController.swift @@ -206,7 +206,7 @@ open class INSPhotosViewController: UIViewController, UIPageViewControllerDataSo if let overlayView = overlayView as? INSPhotosOverlayView { overlayView.photosViewController = self #if swift(>=4.0) - overlayView.titleTextAttributes = [NSAttributedStringKey.foregroundColor: textColor] + overlayView.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor] #else overlayView.titleTextAttributes = [NSForegroundColorAttributeName: textColor] #endif @@ -224,10 +224,10 @@ open class INSPhotosViewController: UIViewController, UIPageViewControllerDataSo pageViewController.view.addGestureRecognizer(panGestureRecognizer) pageViewController.view.addGestureRecognizer(singleTapGestureRecognizer) - addChildViewController(pageViewController) + addChild(pageViewController) view.addSubview(pageViewController.view) pageViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] - pageViewController.didMove(toParentViewController: self) + pageViewController.didMove(toParent: self) setupOverlayView() } @@ -247,7 +247,7 @@ open class INSPhotosViewController: UIViewController, UIPageViewControllerDataSo } private func setupPageViewControllerWithInitialPhoto(_ initialPhoto: INSPhotoViewable? = nil) { - pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [UIPageViewControllerOptionInterPageSpacingKey: 16.0]) + pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [UIPageViewController.OptionsKey.interPageSpacing: 16.0]) pageViewController.view.backgroundColor = UIColor.clear pageViewController.delegate = self pageViewController.dataSource = self @@ -273,7 +273,7 @@ open class INSPhotosViewController: UIViewController, UIPageViewControllerDataSo - parameter photo: The photo to make the currently displayed photo. - parameter animated: Whether to animate the transition to the new photo. */ - open func changeToPhoto(_ photo: INSPhotoViewable, animated: Bool, direction: UIPageViewControllerNavigationDirection = .forward) { + open func changeToPhoto(_ photo: INSPhotoViewable, animated: Bool, direction: UIPageViewController.NavigationDirection = .forward) { if !dataSource.containsPhoto(photo) { return } diff --git a/INSPhotoGallery/INSScalingImageView.swift b/INSPhotoGallery/INSScalingImageView.swift index e32bae7..19795c8 100644 --- a/INSPhotoGallery/INSScalingImageView.swift +++ b/INSPhotoGallery/INSScalingImageView.swift @@ -71,7 +71,7 @@ class INSScalingImageView: UIScrollView { showsVerticalScrollIndicator = false showsHorizontalScrollIndicator = false; bouncesZoom = true; - decelerationRate = UIScrollViewDecelerationRateFast; + decelerationRate = UIScrollView.DecelerationRate.fast; } func centerScrollViewContents() { @@ -92,7 +92,7 @@ class INSScalingImageView: UIScrollView { } // Use `contentInset` to center the contents in the scroll view. Reasoning explained here: http://petersteinberger.com/blog/2013/how-to-center-uiscrollview/ - self.contentInset = UIEdgeInsetsMake(verticalInset, horizontalInset, verticalInset, horizontalInset); + self.contentInset = UIEdgeInsets(top: verticalInset, left: horizontalInset, bottom: verticalInset, right: horizontalInset); } private func updateImage(_ image: UIImage?) { diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..f9ef9a0 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "INSPhotoGallery", + platforms: [ + .iOS(.v15) + ], + products: [ + .library( + name: "INSPhotoGallery", + targets: ["INSPhotoGallery"]), + ], + targets: [ + .target( + name: "INSPhotoGallery", + path: "INSPhotoGallery" + ) + ] +) diff --git a/README.md b/README.md index 2770786..2a73d8f 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,15 @@ pod 'INSPhotoGallery' If you don't have CocoaPods installed, you can learn how to do so [here](http://cocoapods.org). +## SPM + +For this forked repo, add a new package dependency using: +``` +https://github.com/redfin/INSPhotoGallery.git +``` + +And target a commit hash if a release version has not been published yet. + ## Contact [inspace.io](http://inspace.io)