first cut of tilet
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
556055c38a
commit
fce5bec18f
123
VDS/Components/Tilet/Tilet.swift
Normal file
123
VDS/Components/Tilet/Tilet.swift
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
//
|
||||||
|
// Tilet.swift
|
||||||
|
// VDS
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 12/19/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Foundation
|
||||||
|
import VDSColorTokens
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
public enum TiletTitleTypographicalStyle: String, Codable, EnumSubset {
|
||||||
|
case TitleXLarge
|
||||||
|
case BoldTitleXLarge
|
||||||
|
case TitleLarge
|
||||||
|
case BoldTitleLarge
|
||||||
|
case TitleMedium
|
||||||
|
case BoldTitleMedium
|
||||||
|
case TitleSmall
|
||||||
|
case BoldTitleSmall
|
||||||
|
|
||||||
|
public var defaultValue: TypographicalStyle { .BoldTitleSmall }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TiletOtherTypographicalStyle: String, Codable, CaseIterable {
|
||||||
|
case BodyLarge
|
||||||
|
case BoldBodyLarge
|
||||||
|
case BodyMedium
|
||||||
|
case BoldBodyMedium
|
||||||
|
case BodySmall
|
||||||
|
case BoldBodySmall
|
||||||
|
|
||||||
|
public var defaultValue: TypographicalStyle { .BodySmall }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@objc(VDSTilet)
|
||||||
|
open class Tilet: TileContainer {
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializers
|
||||||
|
//--------------------------------------------------
|
||||||
|
required public init() {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder: NSCoder) {
|
||||||
|
super.init(coder: coder)
|
||||||
|
initialSetup()
|
||||||
|
}
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Public Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
private var titleLockup = TitleLockup()
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Public Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
//style
|
||||||
|
open var titleTypograpicalStyle: TiletTitleTypographicalStyle = .BoldTitleSmall { didSet { didChange() }}
|
||||||
|
open var otherTypograpicalStyle: TiletOtherTypographicalStyle = .BodySmall { didSet { didChange() }}
|
||||||
|
|
||||||
|
//text
|
||||||
|
open var titleText: String = "" { didSet { didChange() }}
|
||||||
|
open var titleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var subTitleText: String = "" { didSet { didChange() }}
|
||||||
|
open var subTitleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
|
open var subTitleColor: Use = .primary { didSet { didChange() }}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Constraints
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
//functions
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func setup() {
|
||||||
|
super.setup()
|
||||||
|
containerView.addSubview(titleLockup)
|
||||||
|
titleLockup.pinToSuperView()
|
||||||
|
titleLockup.pinTop()
|
||||||
|
titleLockup.pinLeading()
|
||||||
|
titleLockup.trailingAnchor.constraint(lessThanOrEqualTo: containerView.trailingAnchor).isActive = true
|
||||||
|
titleLockup.bottomAnchor.constraint(lessThanOrEqualTo: containerView.bottomAnchor).isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func reset() {
|
||||||
|
super.reset()
|
||||||
|
titleLockup.reset()
|
||||||
|
|
||||||
|
titleText = ""
|
||||||
|
titleTextAttributes = nil
|
||||||
|
subTitleText = ""
|
||||||
|
subTitleTextAttributes = nil
|
||||||
|
subTitleColor = .primary
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - State
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func updateView() {
|
||||||
|
super.updateView()
|
||||||
|
|
||||||
|
titleLockup.titleText = titleText
|
||||||
|
titleLockup.titleTextAttributes = titleTextAttributes
|
||||||
|
|
||||||
|
titleLockup.subTitleText = titleText
|
||||||
|
titleLockup.subTitleTextAttributes = titleTextAttributes
|
||||||
|
titleLockup.subTitleColor = subTitleColor
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user