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