Skip to content

Commit 94e2c52

Browse files
add shadow helper method for UIKit
1 parent a185afb commit 94e2c52

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Sources/ComponentsKit/Components/Card/UKCard.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ extension UKCard {
141141
view.layer.cornerRadius = model.cornerRadius.value
142142
view.layer.borderWidth = 1
143143
view.layer.borderColor = UniversalColor.divider.cgColor
144-
view.layer.shadowRadius = model.shadow.radius
145-
view.layer.shadowOffset = model.shadow.offset
146-
view.layer.shadowColor = model.shadow.color.cgColor
147-
view.layer.shadowOpacity = 1
144+
view.shadow(model.shadow)
148145
}
149146

150147
static func contentView(_ view: UIView, model: Model) {

Sources/ComponentsKit/Shared/Types/Shadow.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Foundation
1+
import UIKit
22

33
/// Defines shadow options for components.
44
public enum Shadow: Hashable {
@@ -50,3 +50,14 @@ extension Shadow {
5050
}
5151
}
5252
}
53+
54+
// MARK: - UIKit + Shadow
55+
56+
extension UIView {
57+
func shadow(_ shadow: Shadow) {
58+
self.layer.shadowRadius = shadow.radius
59+
self.layer.shadowOffset = shadow.offset
60+
self.layer.shadowColor = shadow.color.cgColor
61+
self.layer.shadowOpacity = 1
62+
}
63+
}

0 commit comments

Comments
 (0)