refactored label
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
aab0cd86ac
commit
cade12b0cd
@ -24,6 +24,12 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
@Proxy(\.model.surface)
|
||||||
|
open var surface: Surface
|
||||||
|
|
||||||
|
@Proxy(\.model.disabled)
|
||||||
|
open var disabled: Bool
|
||||||
|
|
||||||
@Proxy(\.model.attributes)
|
@Proxy(\.model.attributes)
|
||||||
open var attributes: [LabelAttributeModel]?
|
open var attributes: [LabelAttributeModel]?
|
||||||
|
|
||||||
|
|||||||
@ -115,7 +115,7 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var fontWeight: TypographicalStyle.FontWeight = .regular {
|
public var isBold: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
updateTypography()
|
updateTypography()
|
||||||
}
|
}
|
||||||
@ -182,16 +182,16 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
|
|||||||
//fontWeight: regular, bold
|
//fontWeight: regular, bold
|
||||||
private func updateTypography() {
|
private func updateTypography() {
|
||||||
if fontSize == .small {
|
if fontSize == .small {
|
||||||
if fontWeight == .regular {
|
if isBold {
|
||||||
model.typograpicalStyle = .BodySmall
|
|
||||||
} else {
|
|
||||||
model.typograpicalStyle = .BoldBodySmall
|
model.typograpicalStyle = .BoldBodySmall
|
||||||
|
} else {
|
||||||
|
model.typograpicalStyle = .BodySmall
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if fontWeight == .regular {
|
if isBold {
|
||||||
model.typograpicalStyle = .BodyLarge
|
|
||||||
} else {
|
|
||||||
model.typograpicalStyle = .BoldBodyLarge
|
model.typograpicalStyle = .BoldBodyLarge
|
||||||
|
} else {
|
||||||
|
model.typograpicalStyle = .BodyLarge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,64 +62,47 @@ public enum TypographicalStyle: String, Codable, CaseIterable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: FontSize
|
//MARK: FontCategory
|
||||||
extension TypographicalStyle {
|
extension TypographicalStyle {
|
||||||
public enum FontSize: String, Codable, CaseIterable {
|
public enum FontCategory: String, Codable, CaseIterable {
|
||||||
case xxlarge
|
case feature = "Feature"
|
||||||
case xlarge
|
case title = "Title"
|
||||||
case large
|
case body = "Body"
|
||||||
case medium
|
case micro = "Micro"
|
||||||
case small
|
|
||||||
case xsmall
|
public var sizes: [FontSize] {
|
||||||
|
switch self {
|
||||||
|
case .feature:
|
||||||
|
return [.xlarge, .large, .medium, .small, .xsmall]
|
||||||
|
case .title:
|
||||||
|
return [.xxlarge, .xlarge, .large, .medium, .small]
|
||||||
|
case .body:
|
||||||
|
return [.large, .medium, .small]
|
||||||
|
case .micro:
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func style(for fontSize: FontSize, isBold: Bool = false) -> TypographicalStyle? {
|
||||||
|
let styleName = "\(isBold ? "Bold" : "")\(self.rawValue)\(fontSize.rawValue)"
|
||||||
|
guard let style = TypographicalStyle(rawValue: styleName) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return style
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: FontWeight
|
//MARK: FontSize
|
||||||
extension TypographicalStyle {
|
extension TypographicalStyle {
|
||||||
public enum FontWeight: String, Codable, CaseIterable {
|
public enum FontSize: String, Codable, CaseIterable {
|
||||||
case light
|
case xxlarge = "2XLarge"
|
||||||
case regular
|
case xlarge = "XLarge"
|
||||||
case bold
|
case large = "Large"
|
||||||
|
case medium = "Medium"
|
||||||
|
case small = "Small"
|
||||||
|
case xsmall = "XSmall"
|
||||||
}
|
}
|
||||||
|
|
||||||
public var fontWeight: FontWeight {
|
|
||||||
switch self {
|
|
||||||
case .BoldFeatureXLarge,
|
|
||||||
.BoldFeatureLarge,
|
|
||||||
.BoldFeatureMedium,
|
|
||||||
.BoldFeatureSmall,
|
|
||||||
.BoldFeatureXSmall,
|
|
||||||
.BoldTitle2XLarge,
|
|
||||||
.BoldTitleXLarge,
|
|
||||||
.BoldTitleLarge,
|
|
||||||
.BoldTitleMedium,
|
|
||||||
.BoldTitleSmall,
|
|
||||||
.BoldBodyLarge,
|
|
||||||
.BoldBodyMedium,
|
|
||||||
.BoldBodySmall,
|
|
||||||
.BoldMicro:
|
|
||||||
return .bold
|
|
||||||
|
|
||||||
case .FeatureXLarge,
|
|
||||||
.FeatureLarge,
|
|
||||||
.FeatureMedium,
|
|
||||||
.FeatureSmall,
|
|
||||||
.FeatureXSmall,
|
|
||||||
.Title2XLarge,
|
|
||||||
.TitleXLarge,
|
|
||||||
.TitleLarge:
|
|
||||||
return .light
|
|
||||||
|
|
||||||
case .TitleMedium,
|
|
||||||
.TitleSmall,
|
|
||||||
.BodyLarge,
|
|
||||||
.BodyMedium,
|
|
||||||
.BodySmall,
|
|
||||||
.Micro:
|
|
||||||
return .regular
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: PointSize
|
//MARK: PointSize
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user