Skip to content

Commit cc703c9

Browse files
committed
move Elevation to production side
1 parent 11e7b44 commit cc703c9

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

Sources/YCoreUI/Components/Elevation.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@
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+
}

Tests/YCoreUITests/Components/ElevationTests.swift

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,6 @@
99
import 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-
4412
final class ElevationTests: XCTestCase {
4513
func test_init_deliversGivenValues() {
4614
let sut = makeSUT()

0 commit comments

Comments
 (0)