refactored enums
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
7e589328fd
commit
ac6e0d5566
@ -31,14 +31,14 @@ open class TileContainer: Control {
|
|||||||
initialSetup()
|
initialSetup()
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ContainerBackgroundColor: String, Codable, CaseIterable {
|
public enum BackgroundColor: String, Codable, CaseIterable {
|
||||||
case white
|
case white
|
||||||
case black
|
case black
|
||||||
case gray
|
case gray
|
||||||
case transparent
|
case transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ContainerPadding: String, Codable {
|
public enum Padding: String, Codable {
|
||||||
case padding2X
|
case padding2X
|
||||||
case padding4X
|
case padding4X
|
||||||
case padding6X
|
case padding6X
|
||||||
@ -61,7 +61,7 @@ open class TileContainer: Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ContainerScalingType: String, Codable, CaseIterable {
|
public enum AspectRatio: String, Codable, CaseIterable {
|
||||||
case ratio1x1 = "1:1"
|
case ratio1x1 = "1:1"
|
||||||
case ratio3x4 = "3:4"
|
case ratio3x4 = "3:4"
|
||||||
case ratio4x3 = "4:3"
|
case ratio4x3 = "4:3"
|
||||||
@ -83,11 +83,11 @@ open class TileContainer: Control {
|
|||||||
|
|
||||||
public var highlightView = View()
|
public var highlightView = View()
|
||||||
|
|
||||||
public var containerBackgroundColor: ContainerBackgroundColor = .white { didSet{ didChange() } }
|
public var color: BackgroundColor = .white { didSet{ didChange() } }
|
||||||
|
|
||||||
public var containerPadding: ContainerPadding = .padding4X { didSet{ didChange() } }
|
public var padding: Padding = .padding4X { didSet{ didChange() } }
|
||||||
|
|
||||||
public var containerAspectRatio: ContainerScalingType = .ratio1x1 { didSet{ didChange() } }
|
public var aspectRatio: AspectRatio = .ratio1x1 { didSet{ didChange() } }
|
||||||
|
|
||||||
public var imageFallbackColor: Surface = .light { didSet{ didChange() } }
|
public var imageFallbackColor: Surface = .light { didSet{ didChange() } }
|
||||||
|
|
||||||
@ -166,13 +166,13 @@ open class TileContainer: Control {
|
|||||||
containerView.isUserInteractionEnabled = false
|
containerView.isUserInteractionEnabled = false
|
||||||
containerView.backgroundColor = .clear
|
containerView.backgroundColor = .clear
|
||||||
|
|
||||||
containerTopConstraint = containerView.topAnchor.constraint(equalTo: topAnchor, constant: containerPadding.value)
|
containerTopConstraint = containerView.topAnchor.constraint(equalTo: topAnchor, constant: padding.value)
|
||||||
containerTopConstraint?.isActive = true
|
containerTopConstraint?.isActive = true
|
||||||
containerBottomConstraint = containerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: containerPadding.value)
|
containerBottomConstraint = containerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: padding.value)
|
||||||
containerBottomConstraint?.isActive = true
|
containerBottomConstraint?.isActive = true
|
||||||
containerLeadingConstraint = containerView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: containerPadding.value)
|
containerLeadingConstraint = containerView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding.value)
|
||||||
containerLeadingConstraint?.isActive = true
|
containerLeadingConstraint?.isActive = true
|
||||||
containerTrailingConstraint = containerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: containerPadding.value)
|
containerTrailingConstraint = containerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding.value)
|
||||||
containerTrailingConstraint?.isActive = true
|
containerTrailingConstraint?.isActive = true
|
||||||
|
|
||||||
highlightView.pinToSuperView()
|
highlightView.pinToSuperView()
|
||||||
@ -220,7 +220,7 @@ open class TileContainer: Control {
|
|||||||
private func ratioSize(for width: CGFloat) -> CGSize {
|
private func ratioSize(for width: CGFloat) -> CGSize {
|
||||||
var height: CGFloat = width
|
var height: CGFloat = width
|
||||||
|
|
||||||
switch containerAspectRatio {
|
switch aspectRatio {
|
||||||
case .ratio1x1:
|
case .ratio1x1:
|
||||||
break;
|
break;
|
||||||
case .ratio3x4:
|
case .ratio3x4:
|
||||||
@ -265,12 +265,12 @@ open class TileContainer: Control {
|
|||||||
layer.borderColor = borderColorConfig.getColor(self).cgColor
|
layer.borderColor = borderColorConfig.getColor(self).cgColor
|
||||||
layer.borderWidth = showBorder ? VDSFormControls.widthBorder : 0
|
layer.borderWidth = showBorder ? VDSFormControls.widthBorder : 0
|
||||||
|
|
||||||
containerTopConstraint?.constant = containerPadding.value
|
containerTopConstraint?.constant = padding.value
|
||||||
containerLeadingConstraint?.constant = containerPadding.value
|
containerLeadingConstraint?.constant = padding.value
|
||||||
containerBottomConstraint?.constant = -containerPadding.value
|
containerBottomConstraint?.constant = -padding.value
|
||||||
containerTrailingConstraint?.constant = -containerPadding.value
|
containerTrailingConstraint?.constant = -padding.value
|
||||||
|
|
||||||
if let width, containerAspectRatio == .none && height == nil{
|
if let width, aspectRatio == .none && height == nil{
|
||||||
widthConstraint?.constant = width
|
widthConstraint?.constant = width
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
@ -307,7 +307,7 @@ open class TileContainer: Control {
|
|||||||
required init() { }
|
required init() { }
|
||||||
|
|
||||||
func getColor(_ object: TileContainer) -> UIColor {
|
func getColor(_ object: TileContainer) -> UIColor {
|
||||||
switch object.containerBackgroundColor {
|
switch object.color {
|
||||||
|
|
||||||
case .white:
|
case .white:
|
||||||
return VDSColor.backgroundPrimaryLight
|
return VDSColor.backgroundPrimaryLight
|
||||||
|
|||||||
@ -209,8 +209,8 @@ open class Tilet: TileContainer {
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
width = 100
|
width = 100
|
||||||
containerAspectRatio = .none
|
aspectRatio = .none
|
||||||
containerBackgroundColor = .black
|
color = .black
|
||||||
let view = UIView().with {
|
let view = UIView().with {
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
}
|
}
|
||||||
@ -254,9 +254,9 @@ open class Tilet: TileContainer {
|
|||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
containerAspectRatio = .none
|
aspectRatio = .none
|
||||||
surface = .light
|
surface = .light
|
||||||
containerBackgroundColor = .black
|
color = .black
|
||||||
|
|
||||||
//models
|
//models
|
||||||
badgeModel = nil
|
badgeModel = nil
|
||||||
@ -298,7 +298,7 @@ open class Tilet: TileContainer {
|
|||||||
|
|
||||||
if showTitleLockup {
|
if showTitleLockup {
|
||||||
//flip the surface for the titleLockup
|
//flip the surface for the titleLockup
|
||||||
titleLockup.surface = containerBackgroundColor == .black ? .dark : .light
|
titleLockup.surface = color == .black ? .dark : .light
|
||||||
|
|
||||||
//titleLockup
|
//titleLockup
|
||||||
if let textWidth {
|
if let textWidth {
|
||||||
@ -370,7 +370,7 @@ open class Tilet: TileContainer {
|
|||||||
view = titleLockupContainerView
|
view = titleLockupContainerView
|
||||||
}
|
}
|
||||||
if let view {
|
if let view {
|
||||||
stackView.setCustomSpacing(containerPadding.tiletSpacing, after: view)
|
stackView.setCustomSpacing(padding.tiletSpacing, after: view)
|
||||||
}
|
}
|
||||||
if iconContainerView.superview == nil {
|
if iconContainerView.superview == nil {
|
||||||
stackView.addArrangedSubview(iconContainerView)
|
stackView.addArrangedSubview(iconContainerView)
|
||||||
@ -390,7 +390,7 @@ open class Tilet: TileContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TileContainer.ContainerPadding {
|
extension TileContainer.Padding {
|
||||||
fileprivate var tiletSpacing: CGFloat {
|
fileprivate var tiletSpacing: CGFloat {
|
||||||
switch self {
|
switch self {
|
||||||
case .padding2X:
|
case .padding2X:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user