fix merge conflict
This commit is contained in:
parent
269898f566
commit
1bbad6ca15
@ -155,6 +155,4 @@ extension CaretView: MVMCoreUIViewConstrainingProtocol {
|
|||||||
open func alignment() -> UIStackView.Alignment {
|
open func alignment() -> UIStackView.Alignment {
|
||||||
return UIStackView.Alignment.leading;
|
return UIStackView.Alignment.leading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -259,47 +259,46 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
if let attributes = labelModel.attributes, let labelText = text {
|
if let attributes = labelModel.attributes, let labelText = text {
|
||||||
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor])
|
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor])
|
||||||
/*for attribute in attributes {
|
for attribute in attributes {
|
||||||
guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue }
|
let range = NSRange(location: attribute.location, length: attribute.length)
|
||||||
let range = NSRange(location: location, length: length)
|
switch attribute {
|
||||||
switch attributeStyle {
|
case let underLineAtt as LabelAttributeUnderlineModel:
|
||||||
case .underline:
|
|
||||||
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
|
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
|
||||||
case .strikethrough:
|
case let strikeAtt as LabelAttributeStrikeThroughModel:
|
||||||
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
|
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
|
||||||
attributedString.addAttribute(.baselineOffset, value: 0, range: range)
|
attributedString.addAttribute(.baselineOffset, value: 0, range: range)
|
||||||
case .color:
|
case let colorAtt as LabelAttributeColorModel:
|
||||||
if let colorHex = attribute.textColor, !colorHex.isEmpty {
|
if let colorHex = colorAtt.textColor, !colorHex.isEmpty {
|
||||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||||
attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range)
|
attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range)
|
||||||
}
|
}
|
||||||
case .image:
|
case let imageAtt as LabelAttributeImageModel:
|
||||||
var fontSize = font.pointSize
|
var fontSize = font.pointSize
|
||||||
if let attributeSize = attribute.size {
|
if let attributeSize = imageAtt.size {
|
||||||
fontSize = attributeSize
|
fontSize = attributeSize
|
||||||
}
|
}
|
||||||
let imageName = attribute.name ?? "externalLink"
|
let imageName = imageAtt.name ?? "externalLink"
|
||||||
let imageAttachment: NSTextAttachment
|
let imageAttachment: NSTextAttachment
|
||||||
|
|
||||||
if let url = attribute.URL {
|
if let url = imageAtt.URL {
|
||||||
imageAttachment = Label.getTextAttachmentFrom(url: url, dimension: fontSize, label: self)
|
imageAttachment = Label.getTextAttachmentFrom(url: url, dimension: fontSize, label: self)
|
||||||
} else {
|
} else {
|
||||||
imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize)
|
imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize)
|
||||||
}
|
}
|
||||||
let mutableString = NSMutableAttributedString()
|
let mutableString = NSMutableAttributedString()
|
||||||
mutableString.append(NSAttributedString(attachment: imageAttachment))
|
mutableString.append(NSAttributedString(attachment: imageAttachment))
|
||||||
attributedString.insert(mutableString, at: location)
|
attributedString.insert(mutableString, at: imageAtt.location)
|
||||||
case .font:
|
case let fontAtt as LabelAttributeFontModel:
|
||||||
if let fontStyle = attribute.style {
|
if let fontStyle = fontAtt.style {
|
||||||
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
|
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
|
||||||
attributedString.removeAttribute(.font, range: range)
|
attributedString.removeAttribute(.font, range: range)
|
||||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||||
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
|
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
|
||||||
} else {
|
} else {
|
||||||
let fontSize = attribute.size
|
let fontSize = fontAtt.size
|
||||||
var font: UIFont?
|
var font: UIFont?
|
||||||
|
|
||||||
if let fontName = attribute.name {
|
if let fontName = fontAtt.name {
|
||||||
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize)
|
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize)
|
||||||
} else if let fontSize = fontSize {
|
} else if let fontSize = fontSize {
|
||||||
font = self.font.withSize(fontSize)
|
font = self.font.withSize(fontSize)
|
||||||
@ -309,20 +308,17 @@ public typealias ActionBlock = () -> ()
|
|||||||
attributedString.addAttribute(.font, value: font, range: range)
|
attributedString.addAttribute(.font, value: font, range: range)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .action:
|
case let actionAtt as LabelAttributeActionModel:
|
||||||
addActionAttributes(range: range, string: attributedString)
|
addActionAttributes(range: range, string: attributedString)
|
||||||
// if let actionBlock = createActionBlockFor(actionMap: attribute, additionalData: additionalData, delegateObject: delegateObject) {
|
|
||||||
// appendActionableClause(range: range, actionBlock: actionBlock)
|
|
||||||
// }
|
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
originalAttributedString = attributedText
|
originalAttributedString = attributedText
|
||||||
hero = labelModel.hero
|
hero = labelModel.hero
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
|
||||||
|
|||||||
@ -60,21 +60,6 @@ import Foundation
|
|||||||
self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
||||||
self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
||||||
self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
||||||
/*if let atts = self.attributes {
|
|
||||||
for attribute in atts {
|
|
||||||
switch attribute.type {
|
|
||||||
case "font":
|
|
||||||
let afont = attribute as? LabelAttributeFontModel
|
|
||||||
print("font length\(afont!.length), \(String(describing: afont?.name))")
|
|
||||||
case "color":
|
|
||||||
let afont = attribute as? LabelAttributeColorModel
|
|
||||||
print("font length\(afont!.length), \(String(describing: afont?.textColor))")
|
|
||||||
default:
|
|
||||||
print("attribute")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -88,10 +73,10 @@ import Foundation
|
|||||||
try container.encodeIfPresent(fontName, forKey: .fontName)
|
try container.encodeIfPresent(fontName, forKey: .fontName)
|
||||||
try container.encodeIfPresent(fontSize, forKey: .fontSize)
|
try container.encodeIfPresent(fontSize, forKey: .fontSize)
|
||||||
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
|
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
|
||||||
// var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
|
var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
|
||||||
// try attributes?.forEach({ (attributeModel) in
|
try attributes?.forEach({ (attributeModel) in
|
||||||
// try attributeContainer.encode(attributeModel)
|
try attributeContainer.encode(attributeModel)
|
||||||
// })
|
})
|
||||||
try container.encodeIfPresent(html, forKey: .html)
|
try container.encodeIfPresent(html, forKey: .html)
|
||||||
try container.encodeIfPresent(hero, forKey: .hero)
|
try container.encodeIfPresent(hero, forKey: .hero)
|
||||||
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user