Merge branch 'feature/tilet' into 'develop'
updated for attributes See merge request BPHV_MIPS/vds_ios!36
This commit is contained in:
commit
8cdc77764f
@ -33,7 +33,7 @@ public struct ActionLabelAttribute: ActionLabelAttributeModel {
|
||||
public var shouldUnderline: Bool
|
||||
public var accessibleText: String?
|
||||
public var action = PassthroughSubject<Void, Never>()
|
||||
|
||||
public var subscriber: AnyCancellable?
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
@ -51,7 +51,7 @@ public struct ActionLabelAttribute: ActionLabelAttributeModel {
|
||||
|
||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||
if(shouldUnderline){
|
||||
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range)
|
||||
UnderlineLabelAttribute(location: location, length: length).setAttribute(on: attributedString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,14 +27,14 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
public var location: Int
|
||||
public var length: Int
|
||||
public var textStyle: TextStyle
|
||||
public var textColor: UIColor
|
||||
public var textColor: UIColor?
|
||||
public var textPosition: TextPosition
|
||||
public var lineBreakMode: NSLineBreakMode
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor = .black, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
||||
public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
||||
self.location = location
|
||||
self.length = length
|
||||
self.textStyle = textStyle
|
||||
@ -45,9 +45,11 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
|
||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
attributedString.addAttribute(.font, value: textStyle.font, range: range)
|
||||
attributedString.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||
if let textColor {
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
attributedString.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||
}
|
||||
setStyleAttributes(attributedString)
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import Combine
|
||||
public struct ToolTipLabelAttribute: ActionLabelAttributeModel {
|
||||
public var id = UUID()
|
||||
public var accessibleText: String? = "Tool Tip"
|
||||
public var action = PassthroughSubject<Void, Never>()
|
||||
public var action: PassthroughSubject<Void, Never>
|
||||
public var location: Int
|
||||
public var length: Int
|
||||
public var tintColor: UIColor
|
||||
@ -28,6 +28,14 @@ public struct ToolTipLabelAttribute: ActionLabelAttributeModel {
|
||||
|
||||
}
|
||||
|
||||
public init(action: PassthroughSubject<Void, Never> = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil){
|
||||
self.action = action
|
||||
self.location = location
|
||||
self.length = length
|
||||
self.tintColor = tintColor
|
||||
self.accessibleText = accessibleText
|
||||
}
|
||||
|
||||
public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool {
|
||||
lhs.isEqual(rhs)
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ extension Tilelet {
|
||||
public func toTitleLockupSubTitleModel() -> TitleLockup.SubTitleModel {
|
||||
TitleLockup.SubTitleModel(text: text,
|
||||
textColor: textColor,
|
||||
textAttributes: nil)
|
||||
textAttributes: textAttributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ extension Tilelet {
|
||||
//--------------------------------------------------
|
||||
public func toTitleLockupTitleModel() -> TitleLockup.TitleModel {
|
||||
TitleLockup.TitleModel(text: text,
|
||||
textAttributes: nil,
|
||||
textAttributes: textAttributes,
|
||||
textStyle: textStyle.value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,10 +65,10 @@ public enum TextStyle: String, CaseIterable {
|
||||
//MARK: FontCategory
|
||||
extension TextStyle {
|
||||
public enum FontCategory: String, CaseIterable {
|
||||
case feature = "Feature"
|
||||
case title = "Title"
|
||||
case body = "Body"
|
||||
case micro = "micro"
|
||||
case feature
|
||||
case title
|
||||
case body
|
||||
case micro
|
||||
|
||||
public var sizes: [FontSize] {
|
||||
switch self {
|
||||
@ -84,7 +84,13 @@ extension TextStyle {
|
||||
}
|
||||
|
||||
public func style(for fontSize: FontSize?, isBold: Bool = false) -> TextStyle? {
|
||||
let styleName = "\(isBold ? "Bold" : "")\(self.rawValue)\(fontSize?.rawValue ?? "")"
|
||||
var styleName = ""
|
||||
if isBold {
|
||||
let newRaw = rawValue.prefix(1).description.uppercased() + rawValue.dropFirst()
|
||||
styleName = "\(isBold ? "bold" : "")\(newRaw)\(fontSize?.rawValue ?? "")"
|
||||
} else {
|
||||
styleName = "\(rawValue)\(fontSize?.rawValue ?? "")"
|
||||
}
|
||||
guard let style = TextStyle(rawValue: styleName) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user