Skip to content

Commit

Permalink
Merge pull request #30 from cruisediary/master
Browse files Browse the repository at this point in the history
Update to Swift3 support
  • Loading branch information
yoavlt committed Apr 7, 2017
2 parents ad506f9 + ce09a21 commit aedb909
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 37 deletions.
12 changes: 6 additions & 6 deletions Example/LiquidLoader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0830;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0830;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand Down Expand Up @@ -496,7 +496,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -510,7 +510,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -531,7 +531,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LiquidLoader_Example.app/LiquidLoader_Example";
};
name = Debug;
Expand All @@ -549,7 +549,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LiquidLoader_Example.app/LiquidLoader_Example";
};
name = Release;
Expand Down
12 changes: 6 additions & 6 deletions Example/LiquidLoader/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
10 changes: 5 additions & 5 deletions Example/LiquidLoader/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ class ViewController: UIViewController {
self.view.backgroundColor = UIColor(red: 9 / 255.0, green: 21 / 255.0, blue: 37 / 255.0, alpha: 1.0)

let lineColor = UIColor(red: 77 / 255.0, green: 255 / 255.0, blue: 182 / 255.0, alpha: 1.0)
let growColor = UIColor.redColor()
let growColor = UIColor.red

let lineFrame = CGRect(x: self.view.frame.width * 0.5 - 100, y: 100, width: 200, height: 100)
let lineLoader = LiquidLoader(frame: lineFrame, effect: .GrowLine(lineColor,7,10.0, growColor))
let lineLoader = LiquidLoader(frame: lineFrame, effect: .growLine(lineColor,7,10.0, growColor))

let circleFrame = CGRect(x: self.view.frame.width * 0.5 - 100, y: 200, width: 200, height: 200)
let circleColor = UIColor(red: 77 / 255.0, green: 182 / 255.0, blue: 255 / 255.0, alpha: 1.0)
let circleLoader = LiquidLoader(frame: circleFrame, effect: .GrowCircle(circleColor,10,1.0, growColor))
let circleLoader = LiquidLoader(frame: circleFrame, effect: .growCircle(circleColor,10,1.0, growColor))

let circleMatColor = UIColor(red: 255 / 255.0, green: 188 / 255.0, blue: 188 / 255.0, alpha: 1.0)
let circleMatFrame = CGRect(x: self.view.frame.width * 0.5 - 25, y: 450, width: 50, height: 50)
let circleMat = LiquidLoader(frame: circleMatFrame, effect: .Circle(circleMatColor,8,5.0, growColor))
let circleMat = LiquidLoader(frame: circleMatFrame, effect: .circle(circleMatColor,8,5.0, growColor))

let lineMatColor = UIColor(red: 255 / 255.0, green: 255 / 255.0, blue: 188 / 255.0, alpha: 1.0)
let lineMatFrame = CGRect(x: self.view.frame.width * 0.5 - 25, y: 500, width: 50, height: 50)
let lineMat = LiquidLoader(frame: lineMatFrame, effect: .Line(lineMatColor,4,1.0, growColor))
let lineMat = LiquidLoader(frame: lineMatFrame, effect: .line(lineMatColor,4,1.0, growColor))

view.addSubview(lineLoader)
view.addSubview(circleLoader)
Expand Down
10 changes: 10 additions & 0 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

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

2 changes: 1 addition & 1 deletion Example/Tests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Tests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down
18 changes: 9 additions & 9 deletions Pod/Classes/LiquidLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import Foundation
import UIKit

public enum Effect {
case Line(UIColor, Int, CGFloat, UIColor?)
case Circle(UIColor, Int, CGFloat, UIColor?)
case GrowLine(UIColor, Int, CGFloat, UIColor?)
case GrowCircle(UIColor, Int, CGFloat, UIColor?)
case line(UIColor, Int, CGFloat, UIColor?)
case circle(UIColor, Int, CGFloat, UIColor?)
case growLine(UIColor, Int, CGFloat, UIColor?)
case growCircle(UIColor, Int, CGFloat, UIColor?)

func setup(loader: LiquidLoader) -> LiquidLoadEffect {
switch self {
case .Line(let color, let count, let duration, let growColor):
case .line(let color, let count, let duration, let growColor):
return LiquidLineEffect(loader: loader, color: color, circleCount: count, duration: duration, growColor: growColor)
case .Circle(let color, let count, let duration, let growColor):
case .circle(let color, let count, let duration, let growColor):
return LiquidCircleEffect(loader: loader, color: color, circleCount: count, duration: duration, growColor: growColor)
case .GrowLine(let color, let count, let duration, let growColor):
case .growLine(let color, let count, let duration, let growColor):
let line = LiquidLineEffect(loader: loader, color: color, circleCount: count, duration: duration, growColor: growColor)
line.isGrow = true
return line
case .GrowCircle(let color,let count, let duration, let growColor):
case .growCircle(let color,let count, let duration, let growColor):
let circle = LiquidCircleEffect(loader: loader, color: color, circleCount: count, duration: duration, growColor: growColor)
circle.isGrow = true
return circle
Expand All @@ -45,7 +45,7 @@ public class LiquidLoader : UIView {
}

public required init?(coder aDecoder: NSCoder) {
self.effect = .Circle(UIColor.white, 5, 3.0, UIColor.red)
self.effect = .circle(UIColor.white, 5, 3.0, UIColor.red)
super.init(coder: aDecoder)
self.effectDelegate = self.effect.setup(loader: self)
}
Expand Down
8 changes: 4 additions & 4 deletions Pod/Classes/ObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ extension LiquidLoader {
var s: Effect

if effect == .line {
s = Effect.Line(color, numberOfCircle, duration, growColor)
s = Effect.line(color, numberOfCircle, duration, growColor)
} else if effect == .circle {
s = Effect.Circle(color, numberOfCircle, duration, growColor)
s = Effect.circle(color, numberOfCircle, duration, growColor)
} else if effect == .growLine {
s = Effect.GrowLine(color, numberOfCircle, duration, growColor)
s = Effect.growLine(color, numberOfCircle, duration, growColor)
} else { //if effect == .GrowCircle {
s = Effect.GrowCircle(color, numberOfCircle, duration, growColor)
s = Effect.growCircle(color, numberOfCircle, duration, growColor)
}

self.init(frame: frame, effect: s)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LiquidLoader is the spinner loader UI components with liquid animation, inspired
## Usage

```swift
let loader = LiquidLoader(frame: loaderFrame, effect: .GrowCircle(circleColor, 10, 1.0, growColor)) //color, number of circles, duration, growColor.
let loader = LiquidLoader(frame: loaderFrame, effect: .growCircle(circleColor, 10, 1.0, growColor)) //color, number of circles, duration, growColor.
view.addSubview(loader)
```

Expand All @@ -33,12 +33,12 @@ loader.hide()

### Effect Type
You can use the following effects.
* .GrowCircle
* .GrowLine
* .Circle
* .Line
* .growCircle
* .growLine
* .circle
* .line

If you want to avoid grow effects, you should use `.Circle` or `.Line`.
If you want to avoid grow effects, you should use `.circle` or `.line`.

## Installation

Expand Down

0 comments on commit aedb909

Please sign in to comment.