Crash fixes in Label
update molecule name from progressBar to progressbar as per oneconfluence mapping name and Android mapping name.
This commit is contained in:
parent
cd40ebfccd
commit
c1adbe2f2e
@ -252,7 +252,7 @@ public typealias ActionBlock = () -> ()
|
||||
let length = attribute["length"] as? Int
|
||||
else { continue }
|
||||
|
||||
let range = NSRange(location: location, length: length)
|
||||
var range = NSRange(location: location, length: length)
|
||||
|
||||
switch attributeType {
|
||||
case "underline":
|
||||
@ -264,7 +264,17 @@ public typealias ActionBlock = () -> ()
|
||||
|
||||
case "color":
|
||||
if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty {
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
// crash fix: removing attribute, even though it does not exists
|
||||
let foregroundColorAttributesArray = attributedString.attributes(at: location, effectiveRange: &range).filter { (attribute) -> Bool in
|
||||
if attribute.key == .foregroundColor {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if foregroundColorAttributesArray.isEmpty == false {
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
}
|
||||
attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range)
|
||||
}
|
||||
case "image":
|
||||
@ -286,8 +296,28 @@ public typealias ActionBlock = () -> ()
|
||||
case "font":
|
||||
if let fontStyle = attribute.optionalStringForKey("style") {
|
||||
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
// crash fix: removing font attribute, even though it does not exists
|
||||
let fontAttributesArray = attributedString.attributes(at: location, effectiveRange: &range).filter { (attribute) -> Bool in
|
||||
if attribute.key == .font {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if fontAttributesArray.isEmpty == false {
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
}
|
||||
// crash fix: removing attribute, even though it does not exists
|
||||
let foregroundColorAttributesArray = attributedString.attributes(at: location, effectiveRange: &range).filter { (attribute) -> Bool in
|
||||
if attribute.key == .foregroundColor {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if foregroundColorAttributesArray.isEmpty == false {
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
}
|
||||
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
|
||||
} else {
|
||||
let fontSize = attribute["size"] as? CGFloat
|
||||
@ -300,7 +330,17 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
|
||||
if let font = font {
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
// crash fix: removing font attribute, even though it does not exists
|
||||
let fontAttributesArray = attributedString.attributes(at: location, effectiveRange: &range).filter { (attribute) -> Bool in
|
||||
if attribute.key == .font {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if fontAttributesArray.isEmpty == false {
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
}
|
||||
attributedString.addAttribute(.font, value: font, range: range)
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
@"checkbox" : Checkbox.class,
|
||||
@"checkboxWithLabelView" : CheckboxWithLabelView.class,
|
||||
@"cornerLabels" : CornerLabels.class,
|
||||
@"progressBar": ProgressBar.class,
|
||||
@"progressbar": ProgressBar.class,
|
||||
@"multiProgressBar": MultiProgress.class,
|
||||
@"listItem": MoleculeTableViewCell.class,
|
||||
@"accordionListItem": AccordionMoleculeTableViewCell.class,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user