added titleLockup config
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
b74954dd25
commit
7a550f4eb5
@ -36,7 +36,7 @@ public enum TiletOtherTypographicalStyle: String, Codable, EnumSubset {
|
|||||||
|
|
||||||
|
|
||||||
@objc(VDSTilet)
|
@objc(VDSTilet)
|
||||||
open class Tilet: View {
|
open class Tilet: TileContainer {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -58,12 +58,68 @@ open class Tilet: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var tileContainer = TileContainer().with {
|
private var titleLockup = TitleLockup().with {
|
||||||
$0.aspectRatio = .none
|
let configs = [
|
||||||
$0.surface = .light
|
TypographicalStyleDeviceSpacingConfig([.TitleSmall, .BoldTitleSmall],
|
||||||
|
neighboring: [
|
||||||
|
.BodySmall, .BoldBodySmall,
|
||||||
|
.BodyMedium, .BoldBodyMedium
|
||||||
|
],
|
||||||
|
spacing: 8.0,
|
||||||
|
deviceType: .iPhone),
|
||||||
|
|
||||||
|
TypographicalStyleDeviceSpacingConfig([.TitleMedium, .BoldTitleMedium,
|
||||||
|
.TitleLarge, .BoldTitleLarge],
|
||||||
|
neighboring: [
|
||||||
|
.BodySmall, .BoldBodySmall,
|
||||||
|
.BodyMedium, .BoldBodyMedium,
|
||||||
|
.BodyLarge, .BoldBodyLarge],
|
||||||
|
spacing: 8.0,
|
||||||
|
deviceType: .iPhone),
|
||||||
|
|
||||||
|
TypographicalStyleDeviceSpacingConfig([.TitleXLarge, .BoldTitleXLarge],
|
||||||
|
neighboring: [
|
||||||
|
.BodySmall, .BoldBodySmall,
|
||||||
|
.BodyMedium, .BoldBodyMedium,
|
||||||
|
.BodyLarge, .BoldBodyLarge,
|
||||||
|
.TitleMedium, .BoldTitleMedium
|
||||||
|
],
|
||||||
|
spacing: 12.0,
|
||||||
|
deviceType: .iPhone),
|
||||||
|
|
||||||
|
TypographicalStyleDeviceSpacingConfig([.TitleSmall, .BoldTitleSmall,
|
||||||
|
.TitleMedium, .BoldTitleMedium],
|
||||||
|
neighboring: [
|
||||||
|
.BodySmall, .BoldBodySmall,
|
||||||
|
.BodyMedium, .BoldBodyMedium,
|
||||||
|
.BodyLarge, .BoldBodyLarge
|
||||||
|
],
|
||||||
|
spacing: 8.0,
|
||||||
|
deviceType: .iPad),
|
||||||
|
|
||||||
|
TypographicalStyleDeviceSpacingConfig([.TitleLarge, .BoldTitleLarge],
|
||||||
|
neighboring: [
|
||||||
|
.BodySmall, .BoldBodySmall,
|
||||||
|
.BodyMedium, .BoldBodyMedium,
|
||||||
|
.BodyLarge, .BoldBodyLarge,
|
||||||
|
.TitleSmall, .BoldTitleSmall
|
||||||
|
],
|
||||||
|
spacing: 12.0,
|
||||||
|
deviceType: .iPad),
|
||||||
|
|
||||||
|
TypographicalStyleDeviceSpacingConfig([.TitleXLarge, .BoldTitleXLarge],
|
||||||
|
neighboring: [
|
||||||
|
.BodyLarge, .BoldBodyLarge,
|
||||||
|
.TitleMedium, .BoldTitleMedium
|
||||||
|
],
|
||||||
|
spacing: 16.0,
|
||||||
|
deviceType: .iPad)
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
$0.bottomTypographicalStyleSpacingConfig = TypographicalStyleSpacingConfig(configs: configs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var titleLockup = TitleLockup()
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
@ -72,8 +128,6 @@ open class Tilet: View {
|
|||||||
open var titleTypograpicalStyle: TiletTitleTypographicalStyle = .BoldTitleSmall { didSet { didChange() }}
|
open var titleTypograpicalStyle: TiletTitleTypographicalStyle = .BoldTitleSmall { didSet { didChange() }}
|
||||||
open var otherTypograpicalStyle: TiletOtherTypographicalStyle = .BodySmall { didSet { didChange() }}
|
open var otherTypograpicalStyle: TiletOtherTypographicalStyle = .BodySmall { didSet { didChange() }}
|
||||||
|
|
||||||
open var width: CGFloat = 100 { didSet { didChange() }}
|
|
||||||
|
|
||||||
private var _textWidth: CGFloat?
|
private var _textWidth: CGFloat?
|
||||||
open var textWidth: CGFloat? {
|
open var textWidth: CGFloat? {
|
||||||
get { _textWidth }
|
get { _textWidth }
|
||||||
@ -107,15 +161,21 @@ open class Tilet: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//badge
|
||||||
|
open var showBadge: Bool = false { didSet { didChange() }}
|
||||||
|
open var badgeText: String = "" { didSet { didChange() }}
|
||||||
|
open var badgeColor: BadgeFillColor = .red { didSet { didChange() }}
|
||||||
|
|
||||||
//text
|
//text
|
||||||
open var titleText: String = "" { didSet { didChange() }}
|
open var titleText: String = "" { didSet { didChange() }}
|
||||||
open var titleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var titleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
open var subTitleText: String = "" { didSet { didChange() }}
|
open var subTitleText: String = "" { didSet { didChange() }}
|
||||||
open var subTitleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
open var subTitleTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||||
|
|
||||||
open var subTitleColor: Use = .primary { didSet { didChange() }}
|
open var subTitleColor: Use = .primary { didSet { didChange() }}
|
||||||
|
|
||||||
|
//icons
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -128,23 +188,25 @@ open class Tilet: View {
|
|||||||
|
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
addSubview(tileContainer)
|
width = 100
|
||||||
tileContainer.pinToSuperView()
|
aspectRatio = .none
|
||||||
tileContainer.addContentView(titleLockup, shouldPin: false)
|
containerBackgroundColor = .black
|
||||||
|
|
||||||
|
addContentView(titleLockup, shouldPin: false)
|
||||||
titleLockup.pinTop()
|
titleLockup.pinTop()
|
||||||
titleLockup.pinLeading()
|
titleLockup.pinLeading()
|
||||||
titleLockup.pinBottom()
|
titleLockup.bottomAnchor.constraint(lessThanOrEqualTo: containerView.bottomAnchor).isActive = true
|
||||||
|
|
||||||
//either you are 100% width of the tileContainer.contentView
|
//either you are 100% width of the tileContainer.contentView
|
||||||
titleLockupTrailingConstraint = titleLockup.trailingAnchor.constraint(equalTo: tileContainer.containerView.trailingAnchor)
|
titleLockupTrailingConstraint = titleLockup.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
|
||||||
titleLockupTrailingConstraint?.isActive = true
|
titleLockupTrailingConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
tileContainer.reset()
|
aspectRatio = .none
|
||||||
tileContainer.aspectRatio = .none
|
surface = .light
|
||||||
tileContainer.surface = .light
|
containerBackgroundColor = .black
|
||||||
|
|
||||||
titleLockup.reset()
|
titleLockup.reset()
|
||||||
|
|
||||||
@ -161,14 +223,9 @@ open class Tilet: View {
|
|||||||
|
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
//flip the color
|
|
||||||
let flippedColor:TileContainer.ContainerBackgroundColor = surface == .dark ? .white : .black
|
|
||||||
tileContainer.containerBackgroundColor = flippedColor
|
|
||||||
tileContainer.width = width
|
|
||||||
|
|
||||||
//flip the surface for the titleLockup
|
//flip the surface for the titleLockup
|
||||||
let flippedSurface: Surface = surface == .dark ? .light : .dark
|
let flippedSurface: Surface = containerBackgroundColor == .black ? .dark : .light
|
||||||
titleLockup.surface = flippedSurface
|
titleLockup.surface = flippedSurface
|
||||||
|
|
||||||
//either use textWidth
|
//either use textWidth
|
||||||
@ -184,7 +241,7 @@ open class Tilet: View {
|
|||||||
titleLockupWidthConstraint = NSLayoutConstraint(item: titleLockup,
|
titleLockupWidthConstraint = NSLayoutConstraint(item: titleLockup,
|
||||||
attribute: .width,
|
attribute: .width,
|
||||||
relatedBy: .equal,
|
relatedBy: .equal,
|
||||||
toItem: tileContainer.containerView,
|
toItem: containerView,
|
||||||
attribute: .width,
|
attribute: .width,
|
||||||
multiplier: textPercentage / 100,
|
multiplier: textPercentage / 100,
|
||||||
constant: 0.0)
|
constant: 0.0)
|
||||||
@ -206,3 +263,5 @@ open class Tilet: View {
|
|||||||
titleLockup.subTitleColor = subTitleColor
|
titleLockup.subTitleColor = subTitleColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user