Adding the padding fix between TileContainer/Tilelet
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2775799a50
commit
963e31acd3
@ -99,6 +99,8 @@
|
||||
EAA5EEF128F5C909003B3210 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; };
|
||||
EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; };
|
||||
EAA7456C2AB23E2000C1841F /* TooltipModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA7456B2AB23E2000C1841F /* TooltipModel.swift */; };
|
||||
EAACB8982B92706F006A3869 /* EnumValuing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAACB8972B92706F006A3869 /* EnumValuing.swift */; };
|
||||
EAACB89A2B927108006A3869 /* Valuing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAACB8992B927108006A3869 /* Valuing.swift */; };
|
||||
EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; };
|
||||
EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; };
|
||||
EAB1D2CF28ABEF2B00DAE764 /* Typography+Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography+Base.swift */; };
|
||||
@ -268,6 +270,8 @@
|
||||
EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = "<group>"; };
|
||||
EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = "<group>"; };
|
||||
EAA7456B2AB23E2000C1841F /* TooltipModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipModel.swift; sourceTree = "<group>"; };
|
||||
EAACB8972B92706F006A3869 /* EnumValuing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnumValuing.swift; sourceTree = "<group>"; };
|
||||
EAACB8992B927108006A3869 /* Valuing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Valuing.swift; sourceTree = "<group>"; };
|
||||
EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CC28ABE76000DAE764 /* Withable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Withable.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CE28ABEF2B00DAE764 /* Typography+Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+Base.swift"; sourceTree = "<group>"; };
|
||||
@ -552,6 +556,7 @@
|
||||
EA3361A9288B25E40071C351 /* Disabling.swift */,
|
||||
EAF978202A99035B00C2FEA9 /* Enabling.swift */,
|
||||
EA5E305929510F8B0082B959 /* EnumSubset.swift */,
|
||||
EAACB8972B92706F006A3869 /* EnumValuing.swift */,
|
||||
EAF7F0A1289AFB3900B287F5 /* Errorable.swift */,
|
||||
EA3361AE288B26310071C351 /* FormFieldable.swift */,
|
||||
EA33624628931B050071C351 /* Initable.swift */,
|
||||
@ -562,6 +567,7 @@
|
||||
EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */,
|
||||
EAB1D2CC28ABE76000DAE764 /* Withable.swift */,
|
||||
5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */,
|
||||
EAACB8992B927108006A3869 /* Valuing.swift */,
|
||||
71BFA7092B7F70E6000DCE33 /* Dropshadowable.swift */,
|
||||
);
|
||||
path = Protocols;
|
||||
@ -1001,6 +1007,7 @@
|
||||
EAC9258C2911C9DE00091998 /* InputField.swift in Sources */,
|
||||
EA3362402892EF6C0071C351 /* Label.swift in Sources */,
|
||||
EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */,
|
||||
EAACB8982B92706F006A3869 /* EnumValuing.swift in Sources */,
|
||||
EAB2376A29E9E59100AABE9A /* TooltipLaunchable.swift in Sources */,
|
||||
EAB2375D29E8789100AABE9A /* Tooltip.swift in Sources */,
|
||||
71BFA70A2B7F70E6000DCE33 /* Dropshadowable.swift in Sources */,
|
||||
@ -1016,6 +1023,7 @@
|
||||
EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */,
|
||||
EA0D1C412A6AD61C00E5C127 /* Typography+Additional.swift in Sources */,
|
||||
EAC925842911C63100091998 /* Colorable.swift in Sources */,
|
||||
EAACB89A2B927108006A3869 /* Valuing.swift in Sources */,
|
||||
EAB5FEF5292D371F00998C17 /* ButtonBase.swift in Sources */,
|
||||
EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */,
|
||||
EAC71A1F2A2E173D00E47A9F /* RadioButton.swift in Sources */,
|
||||
|
||||
@ -11,7 +11,39 @@ import VDSFormControlsTokens
|
||||
import UIKit
|
||||
|
||||
@objc(VDSTileContainer)
|
||||
open class TileContainer: Control {
|
||||
open class TileContainer: TileContainerBase<TileContainer.Padding> {
|
||||
|
||||
/// Enum used to describe the padding choices used for this component.
|
||||
public enum Padding: EnumValuing {
|
||||
case padding2X
|
||||
case padding4X
|
||||
case padding6X
|
||||
case padding8X
|
||||
case padding12X
|
||||
case custom(CGFloat)
|
||||
|
||||
public static var defaultValue: Self { .padding4X }
|
||||
|
||||
public var value: CGFloat {
|
||||
switch self {
|
||||
case .padding2X:
|
||||
return VDSLayout.Spacing.space2X.value
|
||||
case .padding4X:
|
||||
return VDSLayout.Spacing.space4X.value
|
||||
case .padding6X:
|
||||
return VDSLayout.Spacing.space6X.value
|
||||
case .padding8X:
|
||||
return VDSLayout.Spacing.space8X.value
|
||||
case .padding12X:
|
||||
return VDSLayout.Spacing.space12X.value
|
||||
case .custom(let padding):
|
||||
return padding
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class TileContainerBase<PaddingType: EnumValuing>: Control where PaddingType.ValueType == CGFloat {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -53,33 +85,6 @@ open class TileContainer: Control {
|
||||
case gradient(String, String)
|
||||
case none
|
||||
}
|
||||
|
||||
/// Enum used to describe the padding choices used for this component.
|
||||
public enum Padding {
|
||||
case padding2X
|
||||
case padding4X
|
||||
case padding6X
|
||||
case padding8X
|
||||
case padding12X
|
||||
case custom(CGFloat)
|
||||
|
||||
public var value: CGFloat {
|
||||
switch self {
|
||||
case .padding2X:
|
||||
return VDSLayout.Spacing.space2X.value
|
||||
case .padding4X:
|
||||
return VDSLayout.Spacing.space4X.value
|
||||
case .padding6X:
|
||||
return VDSLayout.Spacing.space6X.value
|
||||
case .padding8X:
|
||||
return VDSLayout.Spacing.space8X.value
|
||||
case .padding12X:
|
||||
return VDSLayout.Spacing.space12X.value
|
||||
case .custom(let padding):
|
||||
return padding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Enum used to describe the aspect ratios used for this component.
|
||||
public enum AspectRatio: String, CaseIterable {
|
||||
@ -130,7 +135,7 @@ open class TileContainer: Control {
|
||||
open var backgroundEffect: BackgroundEffect = .none { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Sets the inside padding for the component
|
||||
open var padding: Padding = .padding4X { didSet { setNeedsUpdate() } }
|
||||
open var padding: PaddingType = PaddingType.defaultValue { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Applies a background color if backgroundImage prop fails or has trouble loading.
|
||||
open var imageFallbackColor: Surface = .light { didSet { setNeedsUpdate() } }
|
||||
@ -253,7 +258,6 @@ open class TileContainer: Control {
|
||||
super.reset()
|
||||
shouldUpdateView = false
|
||||
color = .white
|
||||
padding = .padding4X
|
||||
aspectRatio = .ratio1x1
|
||||
imageFallbackColor = .light
|
||||
width = nil
|
||||
@ -395,7 +399,7 @@ open class TileContainer: Control {
|
||||
|
||||
}
|
||||
|
||||
extension TileContainer {
|
||||
extension TileContainerBase {
|
||||
|
||||
struct DropshadowConfiguration: Dropshadowable {
|
||||
var shadowColorConfiguration: AnyColorable = SurfaceColorConfiguration().with {
|
||||
@ -408,7 +412,7 @@ extension TileContainer {
|
||||
|
||||
final class BackgroundColorConfiguration: ObjectColorable {
|
||||
|
||||
typealias ObjectType = TileContainer
|
||||
typealias ObjectType = TileContainerBase
|
||||
|
||||
let primaryColorConfig = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark)
|
||||
let secondaryColorConfig = SurfaceColorConfiguration(VDSColor.backgroundSecondaryLight, VDSColor.backgroundSecondaryDark)
|
||||
@ -418,7 +422,7 @@ extension TileContainer {
|
||||
|
||||
required init() { }
|
||||
|
||||
func getColor(_ object: TileContainer) -> UIColor {
|
||||
func getColor(_ object: ObjectType) -> UIColor {
|
||||
switch object.color {
|
||||
case .primary:
|
||||
primaryColorConfig.getColor(object.surface)
|
||||
|
||||
@ -16,7 +16,38 @@ import Combine
|
||||
/// while it can include an arrow CTA, it does not require one in order to
|
||||
/// function.
|
||||
@objc(VDSTilelet)
|
||||
open class Tilelet: TileContainer {
|
||||
open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
||||
|
||||
/// Enum used to describe the padding choices used for this component.
|
||||
public enum Padding: String, EnumValuing, CaseIterable {
|
||||
case small
|
||||
case large
|
||||
|
||||
public static var defaultValue: Self { .large }
|
||||
|
||||
public var value: CGFloat {
|
||||
switch self {
|
||||
case .small:
|
||||
return UIDevice.isIPad ? VDSLayout.Spacing.space3X.value : VDSLayout.Spacing.space4X.value
|
||||
case .large:
|
||||
return UIDevice.isIPad ? VDSLayout.Spacing.space4X.value : VDSLayout.Spacing.space6X.value
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate var titleLockupBottomSpacing: CGFloat {
|
||||
switch self.value {
|
||||
case VDSLayout.Spacing.space3X.value:
|
||||
return VDSLayout.Spacing.space4X.value
|
||||
case VDSLayout.Spacing.space4X.value:
|
||||
return VDSLayout.Spacing.space6X.value
|
||||
case VDSLayout.Spacing.space4X.value:
|
||||
return VDSLayout.Spacing.space8X.value
|
||||
default:
|
||||
return VDSLayout.Spacing.space4X.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -303,7 +334,6 @@ open class Tilelet: TileContainer {
|
||||
.pinTop()
|
||||
.pinBottom()
|
||||
|
||||
padding = .custom( UIDevice.isIPad ? VDSLayout.Spacing.space6X.value : VDSLayout.Spacing.space4X.value)
|
||||
//If a Tilelet has Badge, Title and Subtitle, then Subtitle will be truncated first and Badge will be truncated second. Title will be truncated last (lowest priority).
|
||||
var labelPriority = UILayoutPriority.defaultHigh.rawValue
|
||||
titleLockup.titleLabel.setContentCompressionResistancePriority(UILayoutPriority(labelPriority), for: .vertical)
|
||||
@ -456,7 +486,7 @@ open class Tilelet: TileContainer {
|
||||
view = titleLockupContainerView
|
||||
}
|
||||
if let view {
|
||||
stackView.setCustomSpacing(padding.tiletSpacing, after: view)
|
||||
stackView.setCustomSpacing(padding.titleLockupBottomSpacing, after: view)
|
||||
}
|
||||
if iconContainerView.superview == nil {
|
||||
stackView.addArrangedSubview(iconContainerView)
|
||||
@ -505,21 +535,3 @@ extension TitleLockup {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension TileContainer.Padding {
|
||||
|
||||
fileprivate var tiletSpacing: CGFloat {
|
||||
switch self {
|
||||
case .padding4X:
|
||||
return 24
|
||||
case .padding6X:
|
||||
return 32
|
||||
case .custom(let padding):
|
||||
if padding == VDSLayout.Spacing.space3X.value {
|
||||
return 16
|
||||
} else { fallthrough }
|
||||
default:
|
||||
return 16
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,9 @@ import Foundation
|
||||
/// Represents constants used that deal with layout.
|
||||
public struct VDSLayout {
|
||||
/// Enum used to describe the spacing constants.
|
||||
public enum Spacing: String, CaseIterable {
|
||||
public enum Spacing: String, CaseIterable, EnumValuing {
|
||||
public static var defaultValue: VDSLayout.Spacing = .space2X
|
||||
|
||||
case space1X
|
||||
case space2X
|
||||
case space3X
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol EnumSubset<T>: RawRepresentable, CaseIterable {
|
||||
public protocol EnumSubset<T>: RawRepresentable, CaseIterable, Valuing {
|
||||
associatedtype T:RawRepresentable
|
||||
var defaultValue: T { get }
|
||||
}
|
||||
|
||||
12
VDS/Protocols/EnumValuing.swift
Normal file
12
VDS/Protocols/EnumValuing.swift
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// EnumValuing.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 3/1/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol EnumValuing: Valuing {
|
||||
static var defaultValue: Self { get }
|
||||
}
|
||||
13
VDS/Protocols/Valuing.swift
Normal file
13
VDS/Protocols/Valuing.swift
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// Valuing.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 3/1/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol Valuing {
|
||||
associatedtype ValueType
|
||||
var value: ValueType { get }
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user