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:
parent
5c857738f1
commit
c00a849b11
@ -11,7 +11,7 @@ import UIKit
|
|||||||
/**
|
/**
|
||||||
DropShadowable protocol helps with the configuration values for adding drop shadows for light & dark surfaces.
|
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
|
///Shadow Color configuration for light and dark surfaces
|
||||||
var shadowColorConfiguration: AnyColorable { get set }
|
var shadowColorConfiguration: AnyColorable { get set }
|
||||||
///Shadow Opacity configuration for light and dark surfaces
|
///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.
|
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
|
///Configurations are the DropShadowable list, these are applied on the view
|
||||||
var configurations: [DropShadowable] { get }
|
var configurations: [DropShadowable] { get }
|
||||||
@ -34,7 +34,7 @@ protocol DropShadowableConfiguration {
|
|||||||
/**
|
/**
|
||||||
Extension on ViewProtocol for adding drop shadows & gradient layer on view.
|
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) {
|
func addDropShadow(_ config: DropShadowable) {
|
||||||
addDropShadows([config])
|
addDropShadows([config])
|
||||||
@ -47,6 +47,7 @@ extension ViewProtocol where Self: UIView {
|
|||||||
for config in configs {
|
for config in configs {
|
||||||
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius)
|
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius)
|
||||||
let shadowLayer = CALayer()
|
let shadowLayer = CALayer()
|
||||||
|
shadowLayer.backgroundColor = backgroundColor?.cgColor
|
||||||
shadowLayer.shadowPath = shadowPath.cgPath
|
shadowLayer.shadowPath = shadowPath.cgPath
|
||||||
shadowLayer.frame = bounds
|
shadowLayer.frame = bounds
|
||||||
shadowLayer.position = .init(x: bounds.midX, y: bounds.midY)
|
shadowLayer.position = .init(x: bounds.midX, y: bounds.midY)
|
||||||
|
|||||||
@ -6,25 +6,26 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import CoreGraphics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
DropShadowConfiguration confirms to DropShadowable where it has configurable properties required for drop shadow
|
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>
|
public typealias CGFloatConfigurationValue = SurfaceConfigurationValue<CGFloat>
|
||||||
typealias CGSizeConfigurationValue = SurfaceConfigurationValue<CGSize>
|
public typealias CGSizeConfigurationValue = SurfaceConfigurationValue<CGSize>
|
||||||
|
|
||||||
///Shadow Color configuration for light and dark surfaces
|
///Shadow Color configuration for light and dark surfaces
|
||||||
var shadowColorConfiguration: AnyColorable
|
public var shadowColorConfiguration: AnyColorable
|
||||||
///Shadow Opacity configuration for light and dark surfaces
|
///Shadow Opacity configuration for light and dark surfaces
|
||||||
var shadowOpacityConfiguration: CGFloatConfigurationValue
|
public var shadowOpacityConfiguration: CGFloatConfigurationValue
|
||||||
///Shadow Offset configuration for light and dark surfaces
|
///Shadow Offset configuration for light and dark surfaces
|
||||||
var shadowOffsetConfiguration: CGSizeConfigurationValue
|
public var shadowOffsetConfiguration: CGSizeConfigurationValue
|
||||||
///Shadow Radius configuration for light and dark surfaces
|
///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.shadowColorConfiguration = shadowColorConfiguration
|
||||||
self.shadowOpacityConfiguration = shadowOpacity
|
self.shadowOpacityConfiguration = shadowOpacity
|
||||||
self.shadowOffsetConfiguration = shadowOffset
|
self.shadowOffsetConfiguration = shadowOffset
|
||||||
|
|||||||
@ -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.
|
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
|
public var lightValue: ValueType
|
||||||
var darkValue: ValueType
|
public var darkValue: ValueType
|
||||||
|
|
||||||
public init(_ lightValue: ValueType, _ darkValue: ValueType) {
|
public init(_ lightValue: ValueType, _ darkValue: ValueType) {
|
||||||
self.lightValue = lightValue
|
self.lightValue = lightValue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user