Skip to content

Commit

Permalink
Merge branch 'swift-4.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	ImageSlideshow.podspec
  • Loading branch information
zvonicek committed Sep 26, 2018
2 parents f19fe97 + b3ff211 commit 1eaef69
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
12 changes: 6 additions & 6 deletions Example/ImageSlideshow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
D0E8A9F51D97EB94007EC517 /* UIImage+AspectFit.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E8A9EE1D97EB94007EC517 /* UIImage+AspectFit.swift */; };
D0E8A9F61D97EB94007EC517 /* UIImageView+Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E8A9EF1D97EB94007EC517 /* UIImageView+Tools.swift */; };
D0E8A9F71D97EB94007EC517 /* ZoomAnimatedTransitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E8A9F01D97EB94007EC517 /* ZoomAnimatedTransitioning.swift */; };
F539204C210F03610057EFB3 /* SwiftSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = F539204B210F03600057EFB3 /* SwiftSupport.swift */; };
F802998F20CE9EA7009D64DD /* PageIndicatorPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = F802998E20CE9EA7009D64DD /* PageIndicatorPosition.swift */; };
F802999020CE9EA7009D64DD /* PageIndicatorPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = F802998E20CE9EA7009D64DD /* PageIndicatorPosition.swift */; };
F802999120CE9EA7009D64DD /* PageIndicatorPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = F802998E20CE9EA7009D64DD /* PageIndicatorPosition.swift */; };
Expand Down Expand Up @@ -73,6 +74,7 @@
D0E8A9EE1D97EB94007EC517 /* UIImage+AspectFit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImage+AspectFit.swift"; path = "../../ImageSlideshow/Classes/Core/UIImage+AspectFit.swift"; sourceTree = "<group>"; };
D0E8A9EF1D97EB94007EC517 /* UIImageView+Tools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImageView+Tools.swift"; path = "../../ImageSlideshow/Classes/Core/UIImageView+Tools.swift"; sourceTree = "<group>"; };
D0E8A9F01D97EB94007EC517 /* ZoomAnimatedTransitioning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ZoomAnimatedTransitioning.swift; path = ../../ImageSlideshow/Classes/Core/ZoomAnimatedTransitioning.swift; sourceTree = "<group>"; };
F539204B210F03600057EFB3 /* SwiftSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftSupport.swift; path = ../../ImageSlideshow/Classes/Core/SwiftSupport.swift; sourceTree = "<group>"; };
F802998E20CE9EA7009D64DD /* PageIndicatorPosition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PageIndicatorPosition.swift; path = ../../ImageSlideshow/Classes/Core/PageIndicatorPosition.swift; sourceTree = "<group>"; };
FD45C56C18E7B8EC08371B86 /* Pods-ImageSlideshow_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageSlideshow_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ImageSlideshow_Example/Pods-ImageSlideshow_Example.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -205,6 +207,7 @@
D0E8A9E31D97EB6D007EC517 /* ImageSlideshow_framework */ = {
isa = PBXGroup;
children = (
F539204B210F03600057EFB3 /* SwiftSupport.swift */,
D0E8A9EA1D97EB94007EC517 /* FullScreenSlideshowViewController.swift */,
D0B974AF202738F6006217CF /* PageIndicator.swift */,
F802998E20CE9EA7009D64DD /* PageIndicatorPosition.swift */,
Expand Down Expand Up @@ -450,6 +453,7 @@
F802999120CE9EA7009D64DD /* PageIndicatorPosition.swift in Sources */,
D0E8A9F51D97EB94007EC517 /* UIImage+AspectFit.swift in Sources */,
D0E8A9F11D97EB94007EC517 /* FullScreenSlideshowViewController.swift in Sources */,
F539204C210F03610057EFB3 /* SwiftSupport.swift in Sources */,
D0B974B0202738F6006217CF /* PageIndicator.swift in Sources */,
D0E8A9F31D97EB94007EC517 /* ImageSlideshowItem.swift in Sources */,
);
Expand Down Expand Up @@ -537,7 +541,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -585,7 +589,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -602,7 +606,6 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -618,7 +621,6 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -678,7 +680,6 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -706,7 +707,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.zvo.ImageSlideshow-framework";
PRODUCT_NAME = ImageSlideshow;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
2 changes: 1 addition & 1 deletion Example/ImageSlideshow/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ViewController: UIViewController {

slideshow.slideshowInterval = 5.0
slideshow.pageIndicatorPosition = .init(horizontal: .center, vertical: .under)
slideshow.contentScaleMode = UIViewContentMode.scaleAspectFill
slideshow.contentScaleMode = UIView.ContentMode.scaleAspectFill

let pageControl = UIPageControl()
pageControl.currentPageIndicatorTintColor = UIColor.lightGray
Expand Down
62 changes: 31 additions & 31 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
PODS:
- AFNetworking (3.1.0):
- AFNetworking/NSURLSession (= 3.1.0)
- AFNetworking/Reachability (= 3.1.0)
- AFNetworking/Security (= 3.1.0)
- AFNetworking/Serialization (= 3.1.0)
- AFNetworking/UIKit (= 3.1.0)
- AFNetworking/NSURLSession (3.1.0):
- AFNetworking (3.2.1):
- AFNetworking/NSURLSession (= 3.2.1)
- AFNetworking/Reachability (= 3.2.1)
- AFNetworking/Security (= 3.2.1)
- AFNetworking/Serialization (= 3.2.1)
- AFNetworking/UIKit (= 3.2.1)
- AFNetworking/NSURLSession (3.2.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (3.1.0)
- AFNetworking/Security (3.1.0)
- AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0):
- AFNetworking/Reachability (3.2.1)
- AFNetworking/Security (3.2.1)
- AFNetworking/Serialization (3.2.1)
- AFNetworking/UIKit (3.2.1):
- AFNetworking/NSURLSession
- Alamofire (4.5.1)
- AlamofireImage (3.3.0):
- Alamofire (~> 4.5)
- ImageSlideshow (1.6):
- ImageSlideshow/Core (= 1.6)
- ImageSlideshow/AFURL (1.6):
- Alamofire (4.7.3)
- AlamofireImage (3.4.1):
- Alamofire (~> 4.7)
- ImageSlideshow (1.6.0):
- ImageSlideshow/Core (= 1.6.0)
- ImageSlideshow/AFURL (1.6.0):
- AFNetworking (~> 3.0)
- ImageSlideshow/Core
- ImageSlideshow/Alamofire (1.6):
- ImageSlideshow/Alamofire (1.6.0):
- AlamofireImage (~> 3.0)
- ImageSlideshow/Core
- ImageSlideshow/Core (1.6)
- ImageSlideshow/Kingfisher (1.6):
- ImageSlideshow/Core (1.6.0)
- ImageSlideshow/Kingfisher (1.6.0):
- ImageSlideshow/Core
- Kingfisher (> 3.0)
- ImageSlideshow/SDWebImage (1.6):
- ImageSlideshow/SDWebImage (1.6.0):
- ImageSlideshow/Core
- SDWebImage (< 5.0, >= 3.7)
- Kingfisher (4.0.1)
- SDWebImage (3.8.2):
- SDWebImage/Core (= 3.8.2)
- SDWebImage/Core (3.8.2)
- Kingfisher (4.10.0)
- SDWebImage (4.4.2):
- SDWebImage/Core (= 4.4.2)
- SDWebImage/Core (4.4.2)

DEPENDENCIES:
- ImageSlideshow (from `../`)
Expand All @@ -57,12 +57,12 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
Alamofire: 2d95912bf4c34f164fdfc335872e8c312acaea4a
AlamofireImage: 2e784dc5d00f04903a52c1d169181469c805c3df
ImageSlideshow: f06168438862e8b2c901b2066f3abb5d20f7dd50
Kingfisher: b771785e9461ed4b8686d40e7145f9e58100cb24
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c
AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
AlamofireImage: 78d67ccbb763d87ba44b21583d2153500a195630
ImageSlideshow: 17a44fe50c43779149f83c3e369a3d9701f06d65
Kingfisher: 43c4b802d8b5256cf1f4379e9cd10b329be6d3e2
SDWebImage: 624d6e296c69b244bcede364c72ae0430ac14681

PODFILE CHECKSUM: 9f5f0235fb1728554054ee3ff7128ff5d4729418

Expand Down
4 changes: 2 additions & 2 deletions ImageSlideshow.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "ImageSlideshow"
s.version = "1.6.1"
s.version = "1.7.0"
s.summary = "Image slideshow written in Swift with circular scrolling, timer and full screen viewer"

# This description is used to generate tags and improve search results.
Expand All @@ -27,7 +27,7 @@ Image slideshow is a Swift library providing customizable image slideshow with c
s.source = { :git => "https://github.com/zvonicek/ImageSlideshow.git", :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/zvonicek'

s.swift_version = '4.0'
s.swift_version = '4.2'
s.platform = :ios, '8.0'
s.requires_arc = true

Expand Down
9 changes: 7 additions & 2 deletions ImageSlideshow/Classes/Core/ActivityIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,27 @@ extension UIActivityIndicatorView: ActivityIndicatorView {
@objcMembers
open class DefaultActivityIndicator: ActivityIndicatorFactory {
/// activity indicator style
open var style: UIActivityIndicatorViewStyle
open var style: UIActivityIndicatorView.Style

/// activity indicator color
open var color: UIColor?

/// Create a new ActivityIndicator for UIActivityIndicatorView
///
/// - style: activity indicator style
/// - color: activity indicator color
public init(style: UIActivityIndicatorViewStyle = .gray, color: UIColor? = nil) {
public init(style: UIActivityIndicatorView.Style = .gray, color: UIColor? = nil) {
self.style = style
self.color = color
}

/// create ActivityIndicatorView instance
open func create() -> ActivityIndicatorView {
#if swift(>=4.2)
let activityIndicator = UIActivityIndicatorView(style: style)
#else
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: style)
#endif
activityIndicator.color = color
activityIndicator.hidesWhenStopped = true

Expand Down
4 changes: 2 additions & 2 deletions ImageSlideshow/Classes/Core/ImageSlideshow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum ImagePreload {
open class ImageSlideshow: UIView {

/// Scroll View to wrap the slideshow
open let scrollView = UIScrollView()
public let scrollView = UIScrollView()

/// Page Control shown in the slideshow
@available(*, deprecated, message: "Use pageIndicator.view instead")
Expand Down Expand Up @@ -170,7 +170,7 @@ open class ImageSlideshow: UIView {
open var preload = ImagePreload.all

/// Content mode of each image in the slideshow
open var contentScaleMode: UIViewContentMode = UIViewContentMode.scaleAspectFit {
open var contentScaleMode: UIView.ContentMode = UIView.ContentMode.scaleAspectFit {
didSet {
for view in slideshowItems {
view.imageView.contentMode = contentScaleMode
Expand Down
8 changes: 4 additions & 4 deletions ImageSlideshow/Classes/Core/ImageSlideshowItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import UIKit
open class ImageSlideshowItem: UIScrollView, UIScrollViewDelegate {

/// Image view to hold the image
open let imageView = UIImageView()
public let imageView = UIImageView()

/// Activity indicator shown during image loading, when nil there won't be shown any
open let activityIndicator: ActivityIndicatorView?
public let activityIndicator: ActivityIndicatorView?

/// Input Source for the item
open let image: InputSource
public let image: InputSource

/// Guesture recognizer to detect double tap to zoom
open var gestureRecognizer: UITapGestureRecognizer?

/// Holds if the zoom feature is enabled
open let zoomEnabled: Bool
public let zoomEnabled: Bool

/// If set to true image is initially zoomed in
open var zoomInInitially = false
Expand Down
18 changes: 18 additions & 0 deletions ImageSlideshow/Classes/Core/SwiftSupport.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// SwiftSupport.swift
// ImageSlideshow
//
// Created by Pierluigi Cifani on 30/07/2018.
//

import UIKit

#if swift(>=4.2)
typealias UIViewContentMode = UIView.ContentMode
typealias UIActivityIndicatorViewStyle = UIActivityIndicatorView.Style
typealias UIControlState = UIControl.State
typealias UIViewAnimationOptions = UIView.AnimationOptions
typealias UIControlEvents = UIControl.Event
typealias UIViewAutoresizing = UIView.AutoresizingMask
#else
#endif
21 changes: 17 additions & 4 deletions ImageSlideshow/Classes/Core/ZoomAnimatedTransitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ open class ZoomAnimatedTransitioningDelegate: NSObject, UIViewControllerTransiti
return
}

let percent = min(max(fabs(gesture.translation(in: gesture.view!).y) / 200.0, 0.0), 1.0)
let percent = min(max(abs(gesture.translation(in: gesture.view!).y) / 200.0, 0.0), 1.0)

if gesture.state == .began {
interactionController = UIPercentDrivenInteractiveTransition()
Expand All @@ -76,7 +76,7 @@ open class ZoomAnimatedTransitioningDelegate: NSObject, UIViewControllerTransiti
} else if gesture.state == .ended || gesture.state == .cancelled || gesture.state == .failed {
let velocity = gesture.velocity(in: referenceSlideshowView)

if fabs(velocity.y) > 500 {
if abs(velocity.y) > 500 {
if let pageSelected = referenceSlideshowController.pageSelected {
pageSelected(referenceSlideshowController.slideshow.currentPage)
}
Expand Down Expand Up @@ -141,7 +141,7 @@ extension ZoomAnimatedTransitioningDelegate: UIGestureRecognizerDelegate {

if let view = gestureRecognizer.view {
let velocity = gestureRecognizer.velocity(in: view)
return fabs(velocity.x) < fabs(velocity.y)
return abs(velocity.x) < abs(velocity.y)
}

return true
Expand Down Expand Up @@ -192,8 +192,14 @@ class ZoomInAnimator: ZoomAnimator, UIViewControllerAnimatedTransitioning {
let transitionBackgroundView = UIView(frame: containerView.frame)
transitionBackgroundView.backgroundColor = toViewController.backgroundColor
containerView.addSubview(transitionBackgroundView)

#if swift(>=4.2)
containerView.sendSubviewToBack(transitionBackgroundView)
#else
containerView.sendSubview(toBack: transitionBackgroundView)
#endif


let finalFrame = toViewController.view.frame

var transitionView: UIImageView?
Expand Down Expand Up @@ -270,8 +276,11 @@ class ZoomOutAnimator: ZoomAnimator, UIViewControllerAnimatedTransitioning {
toViewController.view.frame = transitionContext.finalFrame(for: toViewController)
toViewController.view.alpha = 0
containerView.addSubview(toViewController.view)
#if swift(>=4.2)
containerView.sendSubviewToBack(toViewController.view)
#else
containerView.sendSubview(toBack: toViewController.view)

#endif
var transitionViewInitialFrame: CGRect
if let currentSlideshowItem = fromViewController.slideshow.currentSlideshowItem {
if let image = currentSlideshowItem.imageView.image {
Expand Down Expand Up @@ -307,7 +316,11 @@ class ZoomOutAnimator: ZoomAnimator, UIViewControllerAnimatedTransitioning {
let transitionBackgroundView = UIView(frame: containerView.frame)
transitionBackgroundView.backgroundColor = fromViewController.backgroundColor
containerView.addSubview(transitionBackgroundView)
#if swift(>=4.2)
containerView.sendSubviewToBack(transitionBackgroundView)
#else
containerView.sendSubview(toBack: transitionBackgroundView)
#endif

let transitionView: UIImageView = UIImageView(image: fromViewController.slideshow.currentSlideshowItem?.imageView.image)
transitionView.contentMode = UIViewContentMode.scaleAspectFill
Expand Down

0 comments on commit 1eaef69

Please sign in to comment.