Skip to content

Commit

Permalink
Merge pull request #20 from cowboyrushforth/master
Browse files Browse the repository at this point in the history
fix swift3 issues
  • Loading branch information
suzuki-0000 committed Oct 6, 2017
2 parents cb75204 + d5b63ee commit 0627907
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 91 deletions.
2 changes: 1 addition & 1 deletion CountdownLabel.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |s|
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "suzuki_keishi" => "keishi.1983@gmail.com" }
s.source = { :git => "https://github.com/suzuki-0000/CountdownLabel.git", :tag => s.version }
s.platform = :ios, "9.0"
s.platform = :ios, "8.2"
s.source_files = 'CountdownLabel/*.swift'
s.source_files = 'CountdownLabel/**/*.swift'
s.requires_arc = true
Expand Down
15 changes: 11 additions & 4 deletions CountdownLabel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = suzuki_keishi;
TargetAttributes = {
892106CF1C3CF4140007CDEC = {
Expand All @@ -230,7 +230,7 @@
};
8999B51A1C4F2F7200C46F10 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0830;
};
};
};
Expand Down Expand Up @@ -344,8 +344,10 @@
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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -392,8 +394,10 @@
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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -413,6 +417,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -424,6 +429,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -449,6 +455,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -476,7 +483,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabelTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -487,7 +494,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabelTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.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 = "0720"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "0720"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 9 additions & 9 deletions CountdownLabel/CountdownLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit
@objc optional func countdownPaused()
@objc optional func countdownFinished()
@objc optional func countdownCancelled()
@objc optional func countingAt(timeCounted timeCounted: TimeInterval, timeRemaining: TimeInterval)
@objc optional func countingAt(timeCounted: TimeInterval, timeRemaining: TimeInterval)

}
extension TimeInterval {
Expand All @@ -22,7 +22,7 @@ extension TimeInterval {
}
}

class CountdownLabel: LTMorphingLabel {
public class CountdownLabel: LTMorphingLabel {

public typealias CountdownCompletion = () -> ()?
public typealias CountdownExecution = () -> ()
Expand Down Expand Up @@ -191,7 +191,7 @@ class CountdownLabel: LTMorphingLabel {

// MARK: - Public
extension CountdownLabel {
func start(completion: ( () -> () )? = nil) {
public func start(completion: ( () -> () )? = nil) {
if !isPaused {
// current date should be setted at the time of the counter's starting, or the time will be wrong (just a few seconds) after the first time of pausing.
currentDate = NSDate()
Expand All @@ -213,7 +213,7 @@ extension CountdownLabel {
countdownDelegate?.countdownStarted?()
}

func pause(completion: (() -> ())? = nil) {
public func pause(completion: (() -> ())? = nil) {
if paused {
return
}
Expand All @@ -235,7 +235,7 @@ extension CountdownLabel {
countdownDelegate?.countdownPaused?()
}

func cancel(completion: (() -> ())? = nil) {
public func cancel(completion: (() -> ())? = nil) {
text = dateFormatter.string(from: date1970.addingTimeInterval(0) as Date)
dispose()

Expand All @@ -246,14 +246,14 @@ extension CountdownLabel {
countdownDelegate?.countdownCancelled?()
}

func addTime(time: TimeInterval) {
public func addTime(time: TimeInterval) {
currentTime = time + currentTime
diffDate = date1970.addingTimeInterval(currentTime)

updateLabel()
}

func then(targetTime: TimeInterval, completion: @escaping () -> ()) -> Self {
public func then(targetTime: TimeInterval, completion: @escaping () -> ()) -> Self {
let t = targetTime - (targetTime - targetTime)
guard t > 0 else {
return self
Expand Down Expand Up @@ -339,7 +339,7 @@ extension CountdownLabel {
}
}

enum CountdownEffect {
public enum CountdownEffect {
case Anvil
case Burn
case Evaporate
Expand All @@ -363,7 +363,7 @@ enum CountdownEffect {
}
}

class CountdownAttributedText: NSObject {
public class CountdownAttributedText: NSObject {
internal let text: String
internal let replacement: String
internal let attributes: [String: AnyObject]?
Expand Down
4 changes: 2 additions & 2 deletions CountdownLabel/LTMorphingLabel/LTEmitterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public struct LTEmitter {
cell.velocityRange = -80.0
cell.lifetime = 0.16
cell.lifetimeRange = 0.1
cell.emissionLongitude = CGFloat(M_PI_2 * 2.0)
cell.emissionRange = CGFloat(M_PI_2 * 2.0)
cell.emissionLongitude = CGFloat(Double.pi / 2 * 2.0)
cell.emissionRange = CGFloat(Double.pi / 2 * 2.0)
cell.scale = 0.1
cell.yAcceleration = 100
cell.scaleSpeed = -0.06
Expand Down
42 changes: 21 additions & 21 deletions CountdownLabel/LTMorphingLabel/LTMorphingLabel+Anvil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension LTMorphingLabel {

let centerRect = self.newRects[Int(self.newRects.count / 2)]

self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "leftSmoke",
particleName: "Smoke",
duration: 0.6
Expand All @@ -49,22 +49,22 @@ extension LTMorphingLabel {
x: centerRect.origin.x,
y: centerRect.origin.y + centerRect.size.height / 1.3)
layer.renderMode = kCAEmitterLayerSurface
cell.emissionLongitude = CGFloat(M_PI / 2.0)
cell.emissionLongitude = CGFloat(Double.pi / 2.0)
cell.scale = self.font.pointSize / 90.0
cell.scaleSpeed = self.font.pointSize / 130
cell.birthRate = 60
cell.velocity = CGFloat(80 + Int(arc4random_uniform(60)))
cell.velocityRange = 100
cell.yAcceleration = -40
cell.xAcceleration = 70
cell.emissionLongitude = CGFloat(-M_PI_2)
cell.emissionRange = CGFloat(M_PI_4) / 5.0
cell.emissionLongitude = CGFloat(-(Double.pi / 2))
cell.emissionRange = CGFloat(Double.pi / 4) / 5.0
cell.lifetime = self.morphingDuration * 2.0
cell.spin = 10
cell.alphaSpeed = -0.5 / self.morphingDuration
}

self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "rightSmoke",
particleName: "Smoke",
duration: 0.6
Expand All @@ -74,22 +74,22 @@ extension LTMorphingLabel {
x: centerRect.origin.x,
y: centerRect.origin.y + centerRect.size.height / 1.3)
layer.renderMode = kCAEmitterLayerSurface
cell.emissionLongitude = CGFloat(M_PI / 2.0)
cell.emissionLongitude = CGFloat(Double.pi / 2.0)
cell.scale = self.font.pointSize / 90.0
cell.scaleSpeed = self.font.pointSize / 130
cell.birthRate = 60
cell.velocity = CGFloat(80 + Int(arc4random_uniform(60)))
cell.velocityRange = 100
cell.yAcceleration = -40
cell.xAcceleration = -70
cell.emissionLongitude = CGFloat(M_PI_2)
cell.emissionRange = CGFloat(-M_PI_4) / 5.0
cell.emissionLongitude = CGFloat(Double.pi / 2)
cell.emissionRange = CGFloat(-(Double.pi / 4)) / 5.0
cell.lifetime = self.morphingDuration * 2.0
cell.spin = -10
cell.alphaSpeed = -0.5 / self.morphingDuration
}

self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "leftFragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -109,13 +109,13 @@ extension LTMorphingLabel {
cell.velocity = 350
cell.yAcceleration = 0
cell.xAcceleration = CGFloat(10 * Int(arc4random_uniform(10)))
cell.emissionLongitude = CGFloat(-M_PI_2)
cell.emissionRange = CGFloat(M_PI_4) / 5.0
cell.emissionLongitude = CGFloat(-(Double.pi / 2))
cell.emissionRange = CGFloat(Double.pi / 4) / 5.0
cell.alphaSpeed = -2
cell.lifetime = self.morphingDuration
}

self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "rightFragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -134,13 +134,13 @@ extension LTMorphingLabel {
cell.velocity = 350
cell.yAcceleration = 0
cell.xAcceleration = CGFloat(-10 * Int(arc4random_uniform(10)))
cell.emissionLongitude = CGFloat(M_PI_2)
cell.emissionRange = CGFloat(-M_PI_4) / 5.0
cell.emissionLongitude = CGFloat(Double.pi / 2)
cell.emissionRange = CGFloat(-(Double.pi / 4)) / 5.0
cell.alphaSpeed = -2
cell.lifetime = self.morphingDuration
}

self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "fragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -160,7 +160,7 @@ extension LTMorphingLabel {
cell.velocityRange = CGFloat(Int(arc4random_uniform(20)) + 30)
cell.yAcceleration = 500
cell.emissionLongitude = 0
cell.emissionRange = CGFloat(M_PI_2)
cell.emissionRange = CGFloat(Double.pi / 2)
cell.alphaSpeed = -1
cell.lifetime = self.morphingDuration
}
Expand Down Expand Up @@ -201,7 +201,7 @@ extension LTMorphingLabel {

if progress > self.morphingDuration * 0.5 {
let end = self.morphingDuration * 0.55
self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "fragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -211,7 +211,7 @@ extension LTMorphingLabel {
layer.birthRate = 0
}
}.play()
self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "leftFragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -221,7 +221,7 @@ extension LTMorphingLabel {
layer.birthRate = 0
}
}.play()
self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "rightFragments",
particleName: "Fragment",
duration: 0.6
Expand All @@ -235,7 +235,7 @@ extension LTMorphingLabel {

if progress > self.morphingDuration * 0.63 {
let end = self.morphingDuration * 0.7
self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "leftSmoke",
particleName: "Smoke",
duration: 0.6
Expand All @@ -245,7 +245,7 @@ extension LTMorphingLabel {
layer.birthRate = 0
}
}.play()
self.emitterView.createEmitter(
let _ = self.emitterView.createEmitter(
name: "rightSmoke",
particleName: "Smoke",
duration: 0.6
Expand Down
8 changes: 4 additions & 4 deletions CountdownLabel/LTMorphingLabel/LTMorphingLabel+Burn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ extension LTMorphingLabel {
)
layer.renderMode = kCAEmitterLayerAdditive
layer.emitterMode = kCAEmitterLayerOutline
cell.emissionLongitude = CGFloat(M_PI / 2.0)
cell.emissionLongitude = CGFloat(Double.pi / 2.0)
cell.scale = self.font.pointSize / 160.0
cell.scaleSpeed = self.font.pointSize / 100.0
cell.birthRate = Float(self.font.pointSize)
cell.emissionLongitude = CGFloat(arc4random_uniform(30))
cell.emissionRange = CGFloat(M_PI_4)
cell.emissionRange = CGFloat(Double.pi / 4)
cell.alphaSpeed = self.morphingDuration * -3.0
cell.yAcceleration = 10
cell.velocity = CGFloat(10 + Int(arc4random_uniform(3)))
Expand All @@ -145,14 +145,14 @@ extension LTMorphingLabel {
)
layer.renderMode = kCAEmitterLayerAdditive
layer.emitterMode = kCAEmitterLayerVolume
cell.emissionLongitude = CGFloat(M_PI / 2.0)
cell.emissionLongitude = CGFloat(Double.pi / 2.0)
cell.scale = self.font.pointSize / 40.0
cell.scaleSpeed = self.font.pointSize / 100.0
cell.birthRate =
Float(self.font.pointSize)
/ Float(arc4random_uniform(10) + 10)
cell.emissionLongitude = 0
cell.emissionRange = CGFloat(M_PI_4)
cell.emissionRange = CGFloat(Double.pi / 4)
cell.alphaSpeed = self.morphingDuration * -3
cell.yAcceleration = -5
cell.velocity = CGFloat(20 + Int(arc4random_uniform(15)))
Expand Down
4 changes: 2 additions & 2 deletions CountdownLabel/LTMorphingLabel/LTMorphingLabel+Fall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ extension LTMorphingLabel {
1.0
) * angle
)
context!.rotate(by: rotation * CGFloat(M_PI) / 180.0)
context!.rotate(by: rotation * CGFloat(Double.pi) / 180.0)
let s = String(limbo.char)
s.draw(in: charRect, withAttributes: [
NSFontAttributeName: self.font.withSize(limbo.size),
NSForegroundColorAttributeName: charColor
NSForegroundColorAttributeName: charColor ?? UIColor.black
])
context!.restoreGState()

Expand Down
Loading

0 comments on commit 0627907

Please sign in to comment.