Skip to content

Commit

Permalink
Merge pull request #1 from redfin/rw-spm-swift5.9
Browse files Browse the repository at this point in the history
Migrated to SPM and Swift5.9
  • Loading branch information
redfinwyland authored Jan 26, 2024
2 parents b6d5bee + 44ad660 commit 9d15b95
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2
5.9
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion INSPhotoGallery.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion INSPhotoGallery/INSPhoto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 4 additions & 4 deletions INSPhotoGallery/INSPhotoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
Expand Down Expand Up @@ -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 = {
Expand All @@ -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()
Expand All @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion INSPhotoGallery/INSPhotosDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion INSPhotoGallery/INSPhotosInteractionAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions INSPhotoGallery/INSPhotosOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion INSPhotoGallery/INSPhotosTransitionAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions INSPhotoGallery/INSPhotosViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
Expand All @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions INSPhotoGallery/INSScalingImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class INSScalingImageView: UIScrollView {
showsVerticalScrollIndicator = false
showsHorizontalScrollIndicator = false;
bouncesZoom = true;
decelerationRate = UIScrollViewDecelerationRateFast;
decelerationRate = UIScrollView.DecelerationRate.fast;
}

func centerScrollViewContents() {
Expand All @@ -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?) {
Expand Down
22 changes: 22 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"
)
]
)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9d15b95

Please sign in to comment.