refactored into new spacing
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3beacb2a5e
commit
6252bcb2c3
@ -64,6 +64,7 @@
|
||||
EA985C1D296CD13600F2FF2E /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C1C296CD13600F2FF2E /* BundleManager.swift */; };
|
||||
EA985C23296E033A00F2FF2E /* TextArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C22296E033A00F2FF2E /* TextArea.swift */; };
|
||||
EA985C2D296F03FE00F2FF2E /* TiletIconModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C2C296F03FE00F2FF2E /* TiletIconModels.swift */; };
|
||||
EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C662970C21600F2FF2E /* VDSLayout.swift */; };
|
||||
EAA5EEB528ECBFB4003B3210 /* ImageLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */; };
|
||||
EAA5EEB728ECC03A003B3210 /* ToolTipLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */; };
|
||||
EAA5EEB928ECD24B003B3210 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEB828ECD24B003B3210 /* Icons.xcassets */; };
|
||||
@ -177,6 +178,7 @@
|
||||
EA985C1C296CD13600F2FF2E /* BundleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleManager.swift; sourceTree = "<group>"; };
|
||||
EA985C22296E033A00F2FF2E /* TextArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextArea.swift; sourceTree = "<group>"; };
|
||||
EA985C2C296F03FE00F2FF2E /* TiletIconModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TiletIconModels.swift; sourceTree = "<group>"; };
|
||||
EA985C662970C21600F2FF2E /* VDSLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSLayout.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLabelAttribute.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolTipLabelAttribute.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB828ECD24B003B3210 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = "<group>"; };
|
||||
@ -378,6 +380,7 @@
|
||||
EAB5FED329267EB300998C17 /* UIView.swift */,
|
||||
EAB5FF0029424ACB00998C17 /* UIControl.swift */,
|
||||
EA5E304D294CC7F00082B959 /* VDSColor.swift */,
|
||||
EA985C662970C21600F2FF2E /* VDSLayout.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
@ -821,6 +824,7 @@
|
||||
EAB5FED429267EB300998C17 /* UIView.swift in Sources */,
|
||||
EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */,
|
||||
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
||||
EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */,
|
||||
EA3362302891EB4A0071C351 /* Fonts.swift in Sources */,
|
||||
EAF7F0AD289B142900B287F5 /* StrikeThroughLabelAttribute.swift in Sources */,
|
||||
EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */,
|
||||
|
||||
@ -38,14 +38,16 @@ open class TileContainer: Control {
|
||||
case transparent
|
||||
}
|
||||
|
||||
public enum ContainerPadding: String, CaseIterable {
|
||||
case twelve = "12"
|
||||
case sixteen = "16"
|
||||
case twentyFour = "24"
|
||||
case thirtyTwo = "32"
|
||||
case fourtyEight = "48"
|
||||
public enum ContainerPadding: String, EnumSubset {
|
||||
case spacing2X
|
||||
case spacing4X
|
||||
case spacing6X
|
||||
case spacing8X
|
||||
case spacing12X
|
||||
|
||||
public var defaultValue: VDSLayout.Spacing { .space4X }
|
||||
}
|
||||
|
||||
|
||||
public enum ContainerScalingType: String, CaseIterable {
|
||||
case ratio1x1 = "1:1"
|
||||
case ratio3x4 = "3:4"
|
||||
@ -70,7 +72,7 @@ open class TileContainer: Control {
|
||||
|
||||
public var containerBackgroundColor: ContainerBackgroundColor = .white { didSet{ didChange() } }
|
||||
|
||||
public var containerPadding: ContainerPadding = .sixteen { didSet{ didChange() } }
|
||||
public var containerPadding: ContainerPadding = .spacing4X { didSet{ didChange() } }
|
||||
|
||||
public var aspectRatio: ContainerScalingType = .ratio1x1 { didSet{ didChange() } }
|
||||
|
||||
@ -115,21 +117,6 @@ open class TileContainer: Control {
|
||||
$0.clipsToBounds = true
|
||||
}
|
||||
|
||||
internal var padding: CGFloat {
|
||||
switch containerPadding {
|
||||
case .twelve:
|
||||
return 12.0
|
||||
case .sixteen:
|
||||
return 16.0
|
||||
case .twentyFour:
|
||||
return 24.0
|
||||
case .thirtyTwo:
|
||||
return 32.0
|
||||
case .fourtyEight:
|
||||
return 48.0
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
@ -166,13 +153,13 @@ open class TileContainer: Control {
|
||||
containerView.isUserInteractionEnabled = false
|
||||
containerView.backgroundColor = .clear
|
||||
|
||||
containerTopConstraint = containerView.topAnchor.constraint(equalTo: topAnchor, constant: padding)
|
||||
containerTopConstraint = containerView.topAnchor.constraint(equalTo: topAnchor, constant: containerPadding.value.doubleValue)
|
||||
containerTopConstraint?.isActive = true
|
||||
containerBottomConstraint = containerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: padding)
|
||||
containerBottomConstraint = containerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: containerPadding.value.doubleValue)
|
||||
containerBottomConstraint?.isActive = true
|
||||
containerLeadingConstraint = containerView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding)
|
||||
containerLeadingConstraint = containerView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: containerPadding.value.doubleValue)
|
||||
containerLeadingConstraint?.isActive = true
|
||||
containerTrailingConstraint = containerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: padding)
|
||||
containerTrailingConstraint = containerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: containerPadding.value.doubleValue)
|
||||
containerTrailingConstraint?.isActive = true
|
||||
|
||||
highlightView.pinToSuperView()
|
||||
@ -265,10 +252,10 @@ open class TileContainer: Control {
|
||||
layer.borderColor = borderColorConfig.getColor(self).cgColor
|
||||
layer.borderWidth = showBorder ? VDSFormControls.widthBorder : 0
|
||||
|
||||
containerTopConstraint?.constant = padding
|
||||
containerLeadingConstraint?.constant = padding
|
||||
containerBottomConstraint?.constant = -padding
|
||||
containerTrailingConstraint?.constant = -padding
|
||||
containerTopConstraint?.constant = containerPadding.value.doubleValue
|
||||
containerLeadingConstraint?.constant = containerPadding.value.doubleValue
|
||||
containerBottomConstraint?.constant = -containerPadding.value.doubleValue
|
||||
containerTrailingConstraint?.constant = -containerPadding.value.doubleValue
|
||||
|
||||
if let width, aspectRatio == .none && height == nil{
|
||||
widthConstraint?.constant = width
|
||||
|
||||
@ -393,15 +393,15 @@ open class Tilet: TileContainer {
|
||||
extension TileContainer.ContainerPadding {
|
||||
fileprivate var tiletSpacing: CGFloat {
|
||||
switch self {
|
||||
case .twelve:
|
||||
case .spacing2X:
|
||||
return 16
|
||||
case .sixteen:
|
||||
case .spacing4X:
|
||||
return 24
|
||||
case .twentyFour:
|
||||
case .spacing6X:
|
||||
return 32
|
||||
case .thirtyTwo:
|
||||
case .spacing8X:
|
||||
return 48
|
||||
case .fourtyEight:
|
||||
default:
|
||||
return 16
|
||||
}
|
||||
}
|
||||
|
||||
51
VDS/Extensions/VDSLayout.swift
Normal file
51
VDS/Extensions/VDSLayout.swift
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// VDSLayout.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 1/12/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct VDSLayout {
|
||||
public enum Spacing: String, Codable, CaseIterable {
|
||||
case space1X
|
||||
case space2X
|
||||
case space3X
|
||||
case space4X
|
||||
case space5X
|
||||
case space6X
|
||||
case space8X
|
||||
case space12X
|
||||
case space16X
|
||||
case space24X
|
||||
case space32X
|
||||
|
||||
public var doubleValue: Double {
|
||||
switch self {
|
||||
case .space1X:
|
||||
return 4
|
||||
case .space2X:
|
||||
return 8
|
||||
case .space3X:
|
||||
return 12
|
||||
case .space4X:
|
||||
return 16
|
||||
case .space5X:
|
||||
return 20
|
||||
case .space6X:
|
||||
return 24
|
||||
case .space8X:
|
||||
return 32
|
||||
case .space12X:
|
||||
return 48
|
||||
case .space16X:
|
||||
return 64
|
||||
case .space24X:
|
||||
return 96
|
||||
case .space32X:
|
||||
return 128
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user