fix merge conflict

This commit is contained in:
panxi 2019-11-26 14:14:53 -05:00
parent 269898f566
commit 1bbad6ca15
3 changed files with 22 additions and 43 deletions

View File

@ -155,6 +155,4 @@ extension CaretView: MVMCoreUIViewConstrainingProtocol {
open func alignment() -> UIStackView.Alignment {
return UIStackView.Alignment.leading;
}
}

View File

@ -259,47 +259,46 @@ public typealias ActionBlock = () -> ()
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])
/*for attribute in attributes {
guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue }
let range = NSRange(location: location, length: length)
switch attributeStyle {
case .underline:
for attribute in attributes {
let range = NSRange(location: attribute.location, length: attribute.length)
switch attribute {
case let underLineAtt as LabelAttributeUnderlineModel:
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(.baselineOffset, value: 0, range: range)
case .color:
if let colorHex = attribute.textColor, !colorHex.isEmpty {
case let colorAtt as LabelAttributeColorModel:
if let colorHex = colorAtt.textColor, !colorHex.isEmpty {
attributedString.removeAttribute(.foregroundColor, range: range)
attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range)
}
case .image:
case let imageAtt as LabelAttributeImageModel:
var fontSize = font.pointSize
if let attributeSize = attribute.size {
if let attributeSize = imageAtt.size {
fontSize = attributeSize
}
let imageName = attribute.name ?? "externalLink"
let imageName = imageAtt.name ?? "externalLink"
let imageAttachment: NSTextAttachment
if let url = attribute.URL {
if let url = imageAtt.URL {
imageAttachment = Label.getTextAttachmentFrom(url: url, dimension: fontSize, label: self)
} else {
imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize)
}
let mutableString = NSMutableAttributedString()
mutableString.append(NSAttributedString(attachment: imageAttachment))
attributedString.insert(mutableString, at: location)
case .font:
if let fontStyle = attribute.style {
attributedString.insert(mutableString, at: imageAtt.location)
case let fontAtt as LabelAttributeFontModel:
if let fontStyle = fontAtt.style {
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
attributedString.removeAttribute(.font, range: range)
attributedString.removeAttribute(.foregroundColor, range: range)
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
} else {
let fontSize = attribute.size
let fontSize = fontAtt.size
var font: UIFont?
if let fontName = attribute.name {
if let fontName = fontAtt.name {
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize)
} else if let fontSize = fontSize {
font = self.font.withSize(fontSize)
@ -309,20 +308,17 @@ public typealias ActionBlock = () -> ()
attributedString.addAttribute(.font, value: font, range: range)
}
}
case .action:
case let actionAtt as LabelAttributeActionModel:
addActionAttributes(range: range, string: attributedString)
// if let actionBlock = createActionBlockFor(actionMap: attribute, additionalData: additionalData, delegateObject: delegateObject) {
// appendActionableClause(range: range, actionBlock: actionBlock)
// }
default:
continue
}
}*/
}
originalAttributedString = attributedText
hero = labelModel.hero
}
}
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {

View File

@ -60,21 +60,6 @@ import Foundation
self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
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 {
@ -88,10 +73,10 @@ import Foundation
try container.encodeIfPresent(fontName, forKey: .fontName)
try container.encodeIfPresent(fontSize, forKey: .fontSize)
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
// var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
// try attributes?.forEach({ (attributeModel) in
// try attributeContainer.encode(attributeModel)
// })
var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
try attributes?.forEach({ (attributeModel) in
try attributeContainer.encode(attributeModel)
})
try container.encodeIfPresent(html, forKey: .html)
try container.encodeIfPresent(hero, forKey: .hero)
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)