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
|
||||
//--------------------------------------------------
|
||||
@Proxy(\.model.surface)
|
||||
open var surface: Surface
|
||||
|
||||
@Proxy(\.model.disabled)
|
||||
open var disabled: Bool
|
||||
|
||||
@Proxy(\.model.attributes)
|
||||
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 {
|
||||
updateTypography()
|
||||
}
|
||||
@ -182,16 +182,16 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
|
||||
//fontWeight: regular, bold
|
||||
private func updateTypography() {
|
||||
if fontSize == .small {
|
||||
if fontWeight == .regular {
|
||||
model.typograpicalStyle = .BodySmall
|
||||
} else {
|
||||
if isBold {
|
||||
model.typograpicalStyle = .BoldBodySmall
|
||||
} else {
|
||||
model.typograpicalStyle = .BodySmall
|
||||
}
|
||||
} else {
|
||||
if fontWeight == .regular {
|
||||
model.typograpicalStyle = .BodyLarge
|
||||
} else {
|
||||
if isBold {
|
||||
model.typograpicalStyle = .BoldBodyLarge
|
||||
} else {
|
||||
model.typograpicalStyle = .BodyLarge
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,64 +62,47 @@ public enum TypographicalStyle: String, Codable, CaseIterable {
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: FontSize
|
||||
//MARK: FontCategory
|
||||
extension TypographicalStyle {
|
||||
public enum FontSize: String, Codable, CaseIterable {
|
||||
case xxlarge
|
||||
case xlarge
|
||||
case large
|
||||
case medium
|
||||
case small
|
||||
case xsmall
|
||||
public enum FontCategory: String, Codable, CaseIterable {
|
||||
case feature = "Feature"
|
||||
case title = "Title"
|
||||
case body = "Body"
|
||||
case micro = "Micro"
|
||||
|
||||
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 {
|
||||
public enum FontWeight: String, Codable, CaseIterable {
|
||||
case light
|
||||
case regular
|
||||
case bold
|
||||
public enum FontSize: String, Codable, CaseIterable {
|
||||
case xxlarge = "2XLarge"
|
||||
case xlarge = "XLarge"
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user