Skip to content

Commit 0485d32

Browse files
author
fmoyarivas
committed
Documentation
Refactoring variable names and addinga proper README and CHANGELOG
1 parent 1d647aa commit 0485d32

39 files changed

+574
-1634
lines changed

CHANGELOG.md

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
11
Change Log
22
==========
3-
Version 1.1.0
3+
Version 1.0.1
44
---
5-
* Migration to Swift 4.2
5+
* Refactoring names, adding a README and CHANGELOG.
66

77
Version 1.0.0
88
---
9-
* Releasing first version of the framework
10-
11-
Version 0.0.7-beta.2
12-
---
13-
* Fixing target on navbar and tabbar for iOS 9 and 10
14-
15-
Version 0.0.7-beta.1
16-
---
17-
* Fixing issues with rotation
18-
19-
Version 0.0.6
20-
---
21-
* Adding Carthage support
22-
23-
Version 0.0.5
24-
---
25-
* Fix Build settings
26-
27-
Version 0.0.4
28-
---
29-
* Fix Build settings
30-
31-
Version 0.0.3
32-
---
33-
* Fix Build settings
34-
35-
Version 0.0.2
36-
---
37-
* Supporting Cocoapods
38-
39-
Version 0.0.1
40-
---
41-
* Initial release
9+
* First version of the framework
4210

README.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
11
# SpinKit
2-
Beautiful spinners based on [tobiasahlin's CSS SpinKit](https://github.com/tobiasahlin/SpinKit). Demystifying iOS Animations
2+
[![Download](https://img.shields.io/cocoapods/v/SpinKitFramework.svg)](https://cocoapods.org/pods/SpinKitFramework)
3+
[![CocoaPods platforms](https://img.shields.io/cocoapods/p/SpinKitFramework.svg)](https://cocoapods.org/pods/SpinKitFramework)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
6+
Based on [tobiasahlin's CSS SpinKit](https://github.com/tobiasahlin/SpinKit), SpinKit is a friendly framework that provides with a set of spinners or loaders. They're perfect to use when your App faces a heavy load task or to help with a transition between scenes.
7+
8+
## Usage
9+
Every `Spinner` is a view that implements the `SpinnerType` interface and exposes four properties to customize it. To start a spinner, simply call its `startLoading` method. Here's some sample code:
10+
11+
```swift
12+
let spinner = WaveSpinner(primaryColor: selectedColor,
13+
frame: CGRect(origin: .zero,
14+
size: CGSize(width: 50,
15+
height: 50)))
16+
17+
spinner.startLoading()
18+
```
19+
<img src="/resources/wave_spiner.gif" width="100" title="Wave Spinner">
20+
21+
## Customization
22+
You can change its color, speed of the animation and modify its content insets:
23+
```swift
24+
spinner.primaryColor = UIColor.green
25+
spinner.contentInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
26+
spinner.animationSpeed = 3 // Speeds up the animation by 3
27+
```
28+
29+
**Note:** Don't change these properties once the spinner has started the animation. Some of them are used as part of the animation and it might not have the expected result.
30+
31+
You can also set the `isTranslucent` property to false (default is true). This makes the view take the `primaryColor` and show the spinner in a white tint.
32+
33+
* Translucent spinner
34+
<img src="/resources/double_bounce.gif" width="100" title="Wave Spinner">
35+
36+
* Opaque spinner
37+
<img src="/resources/double_bounce_translucent.gif" width="100" title="Wave Spinner">
38+
39+
## Available Spinners
40+
Choose the one you like the most ;)
41+
#### Rotating plane
42+
<img src="/resources/rotating_plane.gif" width="100" title="Rotating plane spinner">
43+
44+
#### Double bounce
45+
<img src="/resources/double_bounce_red.gif" width="100" title="Double bounce spinner">
46+
47+
#### Wave
48+
<img src="/resources/wave_red.gif" width="100" title="Wave spinner">
49+
50+
#### Wandering cubes
51+
<img src="/resources/wandering_cubes.gif" width="100" title="Wandering cubes spinner">
52+
53+
#### Pulse
54+
<img src="/resources/pulse.gif" width="100" title="Pulse spinner">
55+
56+
#### Chasing dots
57+
<img src="/resources/chasing_dots.gif" width="100" title="Chasing dots spinner">
58+
59+
#### Three bounce
60+
<img src="/resources/three_bounce.gif" width="100" title="Three bounce spinner">
61+
62+
#### Circle
63+
<img src="/resources/circle.gif" width="100" title="Circle spinner">
64+
65+
#### Cube grid
66+
<img src="/resources/cube_grid.gif" width="100" title="Cube grid spinner">
67+
68+
#### Fading circle
69+
<img src="/resources/fading_circle.gif" width="100" title="Fading circle spinner">
70+
71+
#### Folding cube
72+
<img src="/resources/folding_cube_spinner_red.gif" width="100" title="Folding cube spinner">

SpinKit/ChasingDotsSpinner.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public class ChasingDotsSpinner: Spinner {
4646
override public func startLoading() {
4747
super.startLoading()
4848

49-
let scaleAnimation = CABasicAnimation(keyPath: "transform")
50-
scaleAnimation.fromValue = CATransform3DScale(CATransform3DIdentity, 0, 0, 1)
51-
scaleAnimation.toValue = CATransform3DIdentity
49+
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
50+
scaleAnimation.fromValue = 0
51+
scaleAnimation.toValue = 1
5252
scaleAnimation.repeatCount = .infinity
5353
scaleAnimation.duration = 1.1 / animationSpeed
5454
scaleAnimation.fillMode = .backwards

SpinKit/CubeGridSpinner.swift

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,57 @@ import UIKit
1414
@IBDesignable
1515
public class CubeGridSpinner: Spinner {
1616

17-
private var squareLayer = CAShapeLayer()
18-
private var rowReplicatorLayer = CAReplicatorLayer()
19-
private var replicatorLayer = CAReplicatorLayer()
17+
private var cubeLayer = CAShapeLayer()
18+
private var cubeRowReplicatorLayer = CAReplicatorLayer()
19+
private var gridReplicatorLayer = CAReplicatorLayer()
2020

21-
private var squareRect: CGRect {
21+
private var cubeRect: CGRect {
2222
return contentBounds.applying(CGAffineTransform(scaleX: 1 / 3, y: 1 / 3))
2323
}
2424

2525
override public func didMoveToWindow() {
2626
super.didMoveToWindow()
2727

28-
rowReplicatorLayer.instanceCount = 3
29-
replicatorLayer.instanceCount = 3
28+
cubeRowReplicatorLayer.instanceCount = 3
29+
gridReplicatorLayer.instanceCount = 3
3030

31-
rowReplicatorLayer.addSublayer(squareLayer)
32-
replicatorLayer.addSublayer(rowReplicatorLayer)
33-
layer.addSublayer(replicatorLayer)
31+
cubeRowReplicatorLayer.addSublayer(cubeLayer)
32+
gridReplicatorLayer.addSublayer(cubeRowReplicatorLayer)
33+
layer.addSublayer(gridReplicatorLayer)
3434
}
3535

3636
override public func draw(_ rect: CGRect) {
3737
super.draw(rect)
38-
squareLayer.fillColor = isTranslucent ? primaryColor.cgColor : UIColor.white.cgColor
39-
squareLayer.strokeColor = squareLayer.fillColor
38+
cubeLayer.fillColor = isTranslucent ? primaryColor.cgColor : UIColor.white.cgColor
39+
cubeLayer.strokeColor = cubeLayer.fillColor
4040
}
4141

4242
override public func layoutSubviews() {
4343
super.layoutSubviews()
4444

45-
squareLayer.path = UIBezierPath(rect: squareRect).cgPath
46-
rowReplicatorLayer.instanceTransform = CATransform3DTranslate(CATransform3DIdentity, squareRect.width, 0, 0)
47-
replicatorLayer.instanceTransform = CATransform3DTranslate(CATransform3DIdentity, 0, squareRect.height, 0)
48-
replicatorLayer.frame = contentRect
45+
cubeLayer.path = UIBezierPath(rect: cubeRect).cgPath
46+
cubeLayer.frame = cubeRect
47+
cubeRowReplicatorLayer.instanceTransform = CATransform3DTranslate(CATransform3DIdentity, cubeRect.width, 0, 0)
48+
gridReplicatorLayer.instanceTransform = CATransform3DTranslate(CATransform3DIdentity, 0, cubeRect.height, 0)
49+
gridReplicatorLayer.frame = contentRect
4950
}
5051

5152
override public func startLoading() {
5253
super.startLoading()
5354

54-
let transform = NSValue(caTransform3D: CATransform3DConcat(CATransform3DScale(CATransform3DIdentity, 0, 0, 1),
55-
CATransform3DTranslate(CATransform3DIdentity,
56-
squareRect.width / 2,
57-
squareRect.width / 2, 0)))
58-
59-
let scaleAnim = CABasicAnimation(keyPath: "transform")
60-
scaleAnim.fromValue = CATransform3DIdentity
61-
scaleAnim.toValue = transform
55+
let scaleAnim = CABasicAnimation(keyPath: "transform.scale")
56+
scaleAnim.fromValue = 1
57+
scaleAnim.toValue = 0
6258
scaleAnim.repeatCount = .infinity
6359
scaleAnim.autoreverses = true
6460
scaleAnim.fillMode = .backwards
6561
scaleAnim.timingFunction = CAMediaTimingFunction(controlPoints: 0.83, 0, 0.26, 1.05)
6662
scaleAnim.duration = 1 / animationSpeed
6763

68-
rowReplicatorLayer.instanceDelay = scaleAnim.duration / Double(rowReplicatorLayer.instanceCount) / 2
69-
replicatorLayer.instanceDelay = scaleAnim.duration / Double(replicatorLayer.instanceCount) / 2
64+
cubeRowReplicatorLayer.instanceDelay = scaleAnim.duration / Double(cubeRowReplicatorLayer.instanceCount) / 2
65+
gridReplicatorLayer.instanceDelay = scaleAnim.duration / Double(gridReplicatorLayer.instanceCount) / 2
7066

71-
squareLayer.add(scaleAnim, forKey: nil)
67+
cubeLayer.add(scaleAnim, forKey: nil)
7268
}
7369

7470
}

SpinKit/DoubleBounceSpinner.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ import UIKit
1414
@IBDesignable
1515
public class DoubleBounceSpinner: DoubleColorSpinner {
1616

17-
private var outterCircleLayer = CAShapeLayer()
17+
private var outerCircleLayer = CAShapeLayer()
1818
private var innerCircleLayer = CAShapeLayer()
1919

2020
override public func didMoveToWindow() {
2121
super.didMoveToWindow()
2222

23-
layer.addSublayer(outterCircleLayer)
23+
layer.addSublayer(outerCircleLayer)
2424
layer.addSublayer(innerCircleLayer)
2525
}
2626

2727
override public func draw(_ rect: CGRect) {
2828
super.draw(rect)
2929

30-
outterCircleLayer.fillColor = isTranslucent ? primaryColor.cgColor : UIColor.white.cgColor
30+
outerCircleLayer.fillColor = isTranslucent ? primaryColor.cgColor : UIColor.white.cgColor
3131
innerCircleLayer.fillColor = isTranslucent ? secondaryColor.cgColor : UIColor.lightGray.cgColor
3232
}
3333

3434
override public func layoutSubviews() {
3535
super.layoutSubviews()
3636

37-
outterCircleLayer.path = UIBezierPath(ovalIn: contentBounds).cgPath
38-
outterCircleLayer.frame = contentRect
37+
outerCircleLayer.path = UIBezierPath(ovalIn: contentBounds).cgPath
38+
outerCircleLayer.frame = contentRect
3939

4040
innerCircleLayer.path = UIBezierPath(ovalIn: contentBounds.applying(CGAffineTransform(scaleX: 0.5, y: 0.5))).cgPath
4141
innerCircleLayer.frame = CGRect(x: contentSize.width / 4 + contentOrigin.x,
@@ -53,7 +53,7 @@ public class DoubleBounceSpinner: DoubleColorSpinner {
5353
anim.autoreverses = true
5454
anim.repeatCount = .infinity
5555

56-
outterCircleLayer.add(anim, forKey: nil)
56+
outerCircleLayer.add(anim, forKey: nil)
5757

5858
anim.fromValue = 0
5959
anim.toValue = 1

SpinKitExample/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ target 'SpinKitExample' do
77

88
# Pods for SpinKit
99
pod 'ChameleonFramework/Swift'
10-
pod 'SpinKitFramework'
1110

1211
end

SpinKitExample/Podfile.lock

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@ PODS:
22
- ChameleonFramework/Default (2.1.0)
33
- ChameleonFramework/Swift (2.1.0):
44
- ChameleonFramework/Default
5-
- SpinKitFramework (1.0.0)
65

76
DEPENDENCIES:
87
- ChameleonFramework/Swift
9-
- SpinKitFramework
108

119
SPEC REPOS:
1210
https://github.com/cocoapods/specs.git:
1311
- ChameleonFramework
14-
- SpinKitFramework
1512

1613
SPEC CHECKSUMS:
1714
ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64
18-
SpinKitFramework: 201c3d58c26c2d2f4408b19e3522f4ea374b1cc3
1915

20-
PODFILE CHECKSUM: c6827e3014b1b8592f8e6f1761ef9ffdd08bbc76
16+
PODFILE CHECKSUM: 71471df4a8412c3b74f90358c72f8bc00d827838
2117

2218
COCOAPODS: 1.5.3

SpinKitExample/Pods/Manifest.lock

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)