Skip to content

Commit

Permalink
adding list support && bump
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpanitz committed Jan 29, 2019
1 parent 5c00502 commit a6a176e
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- Nimble (7.3.0)
- Quick (1.3.1)
- Shimmeraiser (1.0.0)
- Shimmeraiser (1.0.2)

DEPENDENCIES:
- Nimble (= 7.3.0)
Expand All @@ -20,7 +20,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Nimble: c8d6a1f463701921c46de965c673e13cafa09196
Quick: d17304d58d0d169dd0bd1c6e5c28e3318de32a1a
Shimmeraiser: c9980322dc2d530580210b5f94032933a68d4f88
Shimmeraiser: 6c031fca646cd5fe16818304c1cda455a7fa282b

PODFILE CHECKSUM: 6dffaf991b6462b85ef2e8d008580b163ba89734

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/Shimmeraiser.podspec.json

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

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

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

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

23 changes: 10 additions & 13 deletions Example/Shimmeraiser/MyCustomShimmer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ final class MyCustomShimmer: Shimmerable {
CGRect(x: 38, y: 90, width: 337, height: 130)
)

(0..<5).forEach { i in
let factor = CGFloat(i)*190
let yValue: CGFloat = 250

builder.appendOvalPath(from:
CGRect(x: 35, y: yValue + factor + 21, width: 40, height: 40)
)
builder.appendRectPath(cornerRadius: 3, from:
CGRect(x: 92, y: yValue + factor, width: 280, height: 90),
CGRect(x: 92, y: yValue + factor + 100, width: 280, height: 18),
CGRect(x: 92, y: yValue + factor + 128, width: 122, height: 18)
)
}
builder.appendList(
itensCount: 5,
xOffset: 0,
yOffset: 190,
shapes:
.oval(frame: CGRect(x: 35, y: 271, width: 40, height: 40)),
.rect(cornerRadius: 2, rect: CGRect(x: 92, y: 250, width: 280, height: 90)),
.rect(cornerRadius: 2, rect: CGRect(x: 92, y: 350, width: 280, height: 18)),
.rect(cornerRadius: 2, rect: CGRect(x: 92, y: 378, width: 122, height: 18))
)

return builder.makeMaskPath()
}
Expand Down
30 changes: 15 additions & 15 deletions Example/Shimmeraiser_ExampleTests/ShimmeraiserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ShimmerTests: QuickSpec {
}

it("então o sublayer de shimmerView.layer deverá ter o backgroundColor igual ao parâmetro startColor") {
expect(shimmerView.layer.sublayers!.first!.backgroundColor) == #colorLiteral(red: 0.9764705882, green: 0.9764705882, blue: 0.9764705882, alpha: 1).cgColor
expect(shimmerView.layer.sublayers!.first!.backgroundColor) == #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1).cgColor
}

it("então deverá adicionar um gradientLayer ao sublayer da shimmerView.layer") {
Expand All @@ -62,20 +62,20 @@ class ShimmerTests: QuickSpec {
let gradientLayer = (shimmerView.layer.sublayers!.first!.sublayers!.first! as! CAGradientLayer)

expect(gradientLayer.colors!.count) == 14
expect((gradientLayer.colors![0] as! CGColor)) == #colorLiteral(red: 0.9764705882, green: 0.9764705882, blue: 0.9764705882, alpha: 1).withAlphaComponent(0.7).cgColor
expect((gradientLayer.colors![1] as! CGColor)) == #colorLiteral(red: 0.9764705882, green: 0.9764705882, blue: 0.9764705882, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![2] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![3] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.4).cgColor
expect((gradientLayer.colors![4] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.6).cgColor
expect((gradientLayer.colors![5] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.8).cgColor
expect((gradientLayer.colors![6] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(1.0).cgColor
expect((gradientLayer.colors![7] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(1.0).cgColor
expect((gradientLayer.colors![8] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.8).cgColor
expect((gradientLayer.colors![9] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.6).cgColor
expect((gradientLayer.colors![10] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.4).cgColor
expect((gradientLayer.colors![11] as! CGColor)) == #colorLiteral(red: 0.9137254902, green: 0.9137254902, blue: 0.9137254902, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![12] as! CGColor)) == #colorLiteral(red: 0.9764705882, green: 0.9764705882, blue: 0.9764705882, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![13] as! CGColor)) == #colorLiteral(red: 0.9764705882, green: 0.9764705882, blue: 0.9764705882, alpha: 1).withAlphaComponent(0.7).cgColor
expect((gradientLayer.colors![0] as! CGColor)) == #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1).withAlphaComponent(0.7).cgColor
expect((gradientLayer.colors![1] as! CGColor)) == #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![2] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![3] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.4).cgColor
expect((gradientLayer.colors![4] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.6).cgColor
expect((gradientLayer.colors![5] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.8).cgColor
expect((gradientLayer.colors![6] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(1.0).cgColor
expect((gradientLayer.colors![7] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(1.0).cgColor
expect((gradientLayer.colors![8] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.8).cgColor
expect((gradientLayer.colors![9] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.6).cgColor
expect((gradientLayer.colors![10] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.4).cgColor
expect((gradientLayer.colors![11] as! CGColor)) == #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![12] as! CGColor)) == #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1).withAlphaComponent(0.2).cgColor
expect((gradientLayer.colors![13] as! CGColor)) == #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1).withAlphaComponent(0.7).cgColor
}
}

Expand Down
2 changes: 1 addition & 1 deletion Shimmeraiser.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Shimmeraiser'
s.version = '1.0.2'
s.version = '1.0.3'
s.summary = 'Shimmeraiser implements a Shimmer enabling your to configure colors, animation duration, sizes and much more.'

s.homepage = 'https://github.com/victorpanitz/Shimmeraiser'
Expand Down
40 changes: 40 additions & 0 deletions Shimmeraiser/Classes/ShimmerPathBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class ShimmerPathBuilder {

internal lazy var path = UIBezierPath()

public enum Shape {
case oval(frame: CGRect)
case rect(cornerRadius: CGFloat, rect: CGRect)
}

public func appendRectPath(
cornerRadius: CGFloat = 0,
from frames: CGRect...) {
Expand All @@ -27,6 +32,41 @@ public class ShimmerPathBuilder {
.forEach (path.append(_:))
}

public func appendList(itensCount: Int = 1, xOffset: CGFloat = 0, yOffset: CGFloat = 0, shapes: Shape...) {

(0..<max(1, itensCount)).forEach {

let xSeparator = CGFloat($0) * xOffset
let ySeparator = CGFloat($0) * yOffset

shapes.map {
switch $0 {
case .oval(let rect):
return UIBezierPath(
ovalIn: CGRect(
x: rect.origin.x + xSeparator,
y: rect.origin.y + ySeparator,
width: rect.width,
height: rect.height
)
)

case .rect(let cornerRadius, let rect):
return UIBezierPath(
roundedRect: CGRect(
x: rect.origin.x + xSeparator,
y: rect.origin.y + ySeparator,
width: rect.width,
height: rect.height
),
cornerRadius: cornerRadius
)
}
}.forEach (path.append(_:))

}
}

public func makeMaskPath() -> CGPath {
return path.cgPath
}
Expand Down

0 comments on commit a6a176e

Please sign in to comment.