added public to all dropshadow and fixed bug in not setting layer background color

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-19 09:35:20 -05:00
parent 5c857738f1
commit c00a849b11
3 changed files with 16 additions and 14 deletions

View File

@ -11,7 +11,7 @@ import UIKit
/**
DropShadowable protocol helps with the configuration values for adding drop shadows for light & dark surfaces.
*/
protocol DropShadowable {
public protocol DropShadowable {
///Shadow Color configuration for light and dark surfaces
var shadowColorConfiguration: AnyColorable { get set }
///Shadow Opacity configuration for light and dark surfaces
@ -25,7 +25,7 @@ protocol DropShadowable {
/**
DropShadowableConfiguration protocol helps with multiple drop shadows configurations can be added to a view.
*/
protocol DropShadowableConfiguration {
public protocol DropShadowableConfiguration {
///Configurations are the DropShadowable list, these are applied on the view
var configurations: [DropShadowable] { get }
@ -34,7 +34,7 @@ protocol DropShadowableConfiguration {
/**
Extension on ViewProtocol for adding drop shadows & gradient layer on view.
*/
extension ViewProtocol where Self: UIView {
public extension ViewProtocol where Self: UIView {
func addDropShadow(_ config: DropShadowable) {
addDropShadows([config])
@ -47,6 +47,7 @@ extension ViewProtocol where Self: UIView {
for config in configs {
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius)
let shadowLayer = CALayer()
shadowLayer.backgroundColor = backgroundColor?.cgColor
shadowLayer.shadowPath = shadowPath.cgPath
shadowLayer.frame = bounds
shadowLayer.position = .init(x: bounds.midX, y: bounds.midY)

View File

@ -6,25 +6,26 @@
//
import Foundation
import CoreGraphics
/**
DropShadowConfiguration confirms to DropShadowable where it has configurable properties required for drop shadow
*/
final class DropShadowConfiguration: DropShadowable, ObjectWithable {
final public class DropShadowConfiguration: DropShadowable, ObjectWithable {
typealias CGFloatConfigurationValue = SurfaceConfigurationValue<CGFloat>
typealias CGSizeConfigurationValue = SurfaceConfigurationValue<CGSize>
public typealias CGFloatConfigurationValue = SurfaceConfigurationValue<CGFloat>
public typealias CGSizeConfigurationValue = SurfaceConfigurationValue<CGSize>
///Shadow Color configuration for light and dark surfaces
var shadowColorConfiguration: AnyColorable
public var shadowColorConfiguration: AnyColorable
///Shadow Opacity configuration for light and dark surfaces
var shadowOpacityConfiguration: CGFloatConfigurationValue
public var shadowOpacityConfiguration: CGFloatConfigurationValue
///Shadow Offset configuration for light and dark surfaces
var shadowOffsetConfiguration: CGSizeConfigurationValue
public var shadowOffsetConfiguration: CGSizeConfigurationValue
///Shadow Radius configuration for light and dark surfaces
var shadowRadiusConfiguration: CGFloatConfigurationValue
public var shadowRadiusConfiguration: CGFloatConfigurationValue
init(shadowColorConfiguration: AnyColorable = SurfaceColorConfiguration().eraseToAnyColorable(), shadowOpacity: CGFloatConfigurationValue = CGFloatConfigurationValue(1.0, 1.0), shadowOffset: CGSizeConfigurationValue = CGSizeConfigurationValue(.zero, .zero), shadowRadius: CGFloatConfigurationValue = CGFloatConfigurationValue(1.0, 1.0)) {
public init(shadowColorConfiguration: AnyColorable = SurfaceColorConfiguration().eraseToAnyColorable(), shadowOpacity: CGFloatConfigurationValue = .init(1.0, 1.0), shadowOffset: CGSizeConfigurationValue = .init(.zero, .zero), shadowRadius: CGFloatConfigurationValue = .init(1.0, 1.0)) {
self.shadowColorConfiguration = shadowColorConfiguration
self.shadowOpacityConfiguration = shadowOpacity
self.shadowOffsetConfiguration = shadowOffset

View File

@ -10,10 +10,10 @@ import Foundation
/**
SurfaceConfiguration is a type that holds the generic datatype for light surface & dark surface and returns the value based on the surface.
*/
struct SurfaceConfigurationValue<ValueType> {
public struct SurfaceConfigurationValue<ValueType> {
var lightValue: ValueType
var darkValue: ValueType
public var lightValue: ValueType
public var darkValue: ValueType
public init(_ lightValue: ValueType, _ darkValue: ValueType) {
self.lightValue = lightValue