File tree Expand file tree Collapse file tree 2 files changed +32
-34
lines changed
Sources/YCoreUI/Components
Tests/YCoreUITests/Components Expand file tree Collapse file tree 2 files changed +32
-34
lines changed Original file line number Diff line number Diff line change 66// Copyright © 2021 Y Media Labs. All rights reserved.
77//
88
9- import Foundation
10-
9+ import UIKit
1110
11+ struct Elevation {
12+ let offset : CGSize
13+ let blur : CGFloat
14+ let spread : CGFloat
15+ let color : UIColor
16+ let opacity : CGFloat
17+ let useShadowPath : Bool
18+
19+ init (
20+ offset: CGSize ,
21+ blur: CGFloat ,
22+ spread: CGFloat ,
23+ color: UIColor ,
24+ opacity: CGFloat ,
25+ useShadowPath: Bool = true
26+ ) {
27+ self . offset = offset
28+ self . blur = blur
29+ self . spread = spread
30+ self . color = color
31+ self . opacity = opacity
32+ self . useShadowPath = useShadowPath
33+ }
34+
35+ func apply( layer: CALayer , cornerRadius: CGFloat ) {
36+ guard useShadowPath else { return }
37+
38+ let rect = layer. bounds. insetBy ( dx: - spread, dy: - spread)
39+ layer. shadowPath = UIBezierPath ( roundedRect: rect, cornerRadius: cornerRadius) . cgPath
40+ }
41+ }
Original file line number Diff line number Diff line change 99import XCTest
1010@testable import YCoreUI
1111
12- struct Elevation {
13- let offset : CGSize
14- let blur : CGFloat
15- let spread : CGFloat
16- let color : UIColor
17- let opacity : CGFloat
18- let useShadowPath : Bool
19-
20- init (
21- offset: CGSize ,
22- blur: CGFloat ,
23- spread: CGFloat ,
24- color: UIColor ,
25- opacity: CGFloat ,
26- useShadowPath: Bool = true
27- ) {
28- self . offset = offset
29- self . blur = blur
30- self . spread = spread
31- self . color = color
32- self . opacity = opacity
33- self . useShadowPath = useShadowPath
34- }
35-
36- func apply( layer: CALayer , cornerRadius: CGFloat ) {
37- guard useShadowPath else { return }
38-
39- let rect = layer. bounds. insetBy ( dx: - spread, dy: - spread)
40- layer. shadowPath = UIBezierPath ( roundedRect: rect, cornerRadius: cornerRadius) . cgPath
41- }
42- }
43-
4412final class ElevationTests : XCTestCase {
4513 func test_init_deliversGivenValues( ) {
4614 let sut = makeSUT ( )
You can’t perform that action at this time.
0 commit comments