Skip to content

Commit

Permalink
Merge pull request #37 from jcavar/swift4
Browse files Browse the repository at this point in the history
Swift 4
  • Loading branch information
jcavar committed Sep 23, 2017
2 parents 44534b4 + 824a713 commit c0604d3
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: objective-c
osx_image: xcode8
script: xcodebuild test -scheme Refresher -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3'
language: swift
osx_image: xcode9
script: xcodebuild test -scheme Refresher -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.0'
32 changes: 22 additions & 10 deletions PullToRefresh.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,21 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Josip Cavar";
TargetAttributes = {
C7AC6CCB19A7FE6D007107DF = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
C7AC6CD519A7FE6D007107DF = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
TestTargetID = C7D1CF8E199BB3C8009FD485;
};
C7D1CF8E199BB3C8009FD485 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -451,7 +451,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -473,7 +473,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "JCA.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -494,7 +494,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "JCA.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PullToRefreshDemo.app/PullToRefreshDemo";
};
name = Debug;
Expand All @@ -510,7 +510,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "JCA.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PullToRefreshDemo.app/PullToRefreshDemo";
};
name = Release;
Expand All @@ -523,14 +523,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -570,14 +576,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -612,7 +624,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "JCA.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -626,7 +638,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "JCA.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion PullToRefreshDemo/PacmanAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PacmanAnimator: UIView, PullToRefreshViewDelegate {
superview.layer.addSublayer(layerLoader)
}
let center = CGPoint(x: 30, y: superview.frame.size.height / 2)
let bezierPathLoader = UIBezierPath(arcCenter: center, radius: CGFloat(10), startAngle: CGFloat(0), endAngle: CGFloat(2 * M_PI), clockwise: true)
let bezierPathLoader = UIBezierPath(arcCenter: center, radius: CGFloat(10), startAngle: CGFloat(0), endAngle: CGFloat(2 * Double.pi), clockwise: true)
let bezierPathSeparator = UIBezierPath()
bezierPathSeparator.move(to: CGPoint(x: 0, y: superview.frame.height - 1))
bezierPathSeparator.addLine(to: CGPoint(x: superview.frame.width, y: superview.frame.height - 1))
Expand Down
4 changes: 2 additions & 2 deletions PullToRefreshDemo/PullToRefreshViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class PullToRefreshViewController: UIViewController {
// Dispose of any resources that can be recreated.
}

func tableView(_ tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
@objc func tableView(_ tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return 50
}

func tableView(_ tableView: UITableView!, cellForRowAtIndexPath indexPath: IndexPath!) -> UITableViewCell! {
@objc func tableView(_ tableView: UITableView!, cellForRowAtIndexPath indexPath: IndexPath!) -> UITableViewCell! {
let cell = UITableViewCell(style: .default, reuseIdentifier: "Cell")
cell.textLabel?.text = "Row " + String(indexPath.row + 1)
return cell
Expand Down
2 changes: 1 addition & 1 deletion Refresher.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'Refresher'
s.version = '0.6.1'
s.version = '0.7.0'
s.summary = 'Pull to refresh in Swift'

s.description = <<-DESC
Expand Down
3 changes: 0 additions & 3 deletions Refresher/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ import QuartzCore
import UIKit

internal class AnimatorView: UIView {

fileprivate let titleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

fileprivate let activityIndicatorView: UIActivityIndicatorView = {
let activity = UIActivityIndicatorView(activityIndicatorStyle: .gray)
activity.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -60,7 +58,6 @@ internal class AnimatorView: UIView {
}

class Animator: PullToRefreshViewDelegate {

internal let animatorView: AnimatorView

init(frame: CGRect) {
Expand Down
6 changes: 3 additions & 3 deletions Refresher/PullToRefreshExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ extension UIScrollView {
}

// If you want to add pull to refresh functionality to your UIScrollView just call this method and pass action closure you want to execute while pull to refresh is animating. If you want to stop pull to refresh you must do that manually calling stopPullToRefreshView methods on your scroll view
public func addPullToRefreshWithAction(_ action:@escaping (() -> ())) {
public func addPullToRefreshWithAction(_ action: @escaping (() -> ())) {
let pullToRefreshView = PullToRefreshView(action: action, frame: CGRect(x: 0, y: -pullToRefreshDefaultHeight, width: self.frame.size.width, height: pullToRefreshDefaultHeight))
pullToRefreshView.tag = pullToRefreshTag
addSubview(pullToRefreshView)
}

// If you want to use your custom animation and custom subview when pull to refresh is animating, you should call this method and pass your animator and view objects.
public func addPullToRefreshWithAction(_ action:@escaping (() -> ()), withAnimator animator: PullToRefreshViewDelegate, withSubview subview: UIView) {
public func addPullToRefreshWithAction(_ action: @escaping (() -> ()), withAnimator animator: PullToRefreshViewDelegate, withSubview subview: UIView) {
let height = subview.frame.height
let pullToRefreshView = PullToRefreshView(action: action, frame: CGRect(x: 0, y: -height, width: self.frame.size.width, height: height), animator: animator, subview: subview)
pullToRefreshView.tag = pullToRefreshTag
addSubview(pullToRefreshView)
}

//
public func addPullToRefreshWithAction<T: UIView>(_ action:@escaping (() -> ()), withAnimator animator: T) where T: PullToRefreshViewDelegate {
public func addPullToRefreshWithAction<T: UIView>(_ action: @escaping (() -> ()), withAnimator animator: T) where T: PullToRefreshViewDelegate {
let height = animator.frame.height
let pullToRefreshView = PullToRefreshView(action: action, frame: CGRect(x: 0, y: -height, width: self.frame.size.width, height: height), animator: animator, subview: animator)
pullToRefreshView.tag = pullToRefreshTag
Expand Down

0 comments on commit c0604d3

Please sign in to comment.