Merge branch 'develop' into feature/star
This commit is contained in:
commit
bf51e4c0ba
@ -322,8 +322,11 @@ public typealias ActionBlock = () -> ()
|
|||||||
for attribute in attributes {
|
for attribute in attributes {
|
||||||
let range = NSRange(location: attribute.location, length: attribute.length)
|
let range = NSRange(location: attribute.location, length: attribute.length)
|
||||||
switch attribute {
|
switch attribute {
|
||||||
case _ as LabelAttributeUnderlineModel:
|
case let underlineAtt as LabelAttributeUnderlineModel:
|
||||||
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
|
attributedString.addAttribute(.underlineStyle, value: underlineAtt.underlineValue.rawValue, range: range)
|
||||||
|
if let underlineColor = underlineAtt.color?.uiColor {
|
||||||
|
attributedString.addAttribute(.underlineColor, value: underlineColor, range: range)
|
||||||
|
}
|
||||||
|
|
||||||
case _ as LabelAttributeStrikeThroughModel:
|
case _ as LabelAttributeStrikeThroughModel:
|
||||||
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
|
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class LabelAttributeUnderlineModel: LabelAttributeModel {
|
@objcMembers public class LabelAttributeUnderlineModel: LabelAttributeModel {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -16,15 +18,104 @@
|
|||||||
return "underline"
|
return "underline"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This returns the NSUnderlineStyle used in NSAttributedValue. If there is a pattern, it will return
|
||||||
|
/// a new NSUnderlineStyle derived from the bitmask of style | pattern.
|
||||||
|
var underlineValue: NSUnderlineStyle {
|
||||||
|
|
||||||
|
if let pattern = pattern?.value() {
|
||||||
|
return NSUnderlineStyle(rawValue: style.value() | pattern)
|
||||||
|
} else {
|
||||||
|
return NSUnderlineStyle(rawValue: style.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var color: Color?
|
||||||
|
var style: UnderlineStyle = .single
|
||||||
|
var pattern: UnderlineStyle.Pattern?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Codec
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case color
|
||||||
|
case style
|
||||||
|
case pattern
|
||||||
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) {
|
||||||
|
self.color = color
|
||||||
|
}
|
||||||
|
|
||||||
|
if let style = try typeContainer.decodeIfPresent(UnderlineStyle.self, forKey: .style) {
|
||||||
|
self.style = style
|
||||||
|
}
|
||||||
|
|
||||||
|
if let pattern = try typeContainer.decodeIfPresent(UnderlineStyle.Pattern.self, forKey: .pattern) {
|
||||||
|
self.pattern = pattern
|
||||||
|
}
|
||||||
|
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(color, forKey: .color)
|
||||||
|
try container.encode(style, forKey: .style)
|
||||||
|
try container.encodeIfPresent(pattern, forKey: .pattern)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UnderlineStyle: String, Codable {
|
||||||
|
case none
|
||||||
|
case single
|
||||||
|
case thick
|
||||||
|
case double
|
||||||
|
|
||||||
|
func value() -> Int {
|
||||||
|
switch self {
|
||||||
|
case .none:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
case .single:
|
||||||
|
return NSUnderlineStyle.single.rawValue
|
||||||
|
|
||||||
|
case .thick:
|
||||||
|
return NSUnderlineStyle.thick.rawValue
|
||||||
|
|
||||||
|
case .double:
|
||||||
|
return NSUnderlineStyle.double.rawValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Pattern: String, Codable {
|
||||||
|
case dot
|
||||||
|
case dash
|
||||||
|
case dashDot
|
||||||
|
case dashDotDot
|
||||||
|
case byWord
|
||||||
|
|
||||||
|
func value() -> Int {
|
||||||
|
switch self {
|
||||||
|
case .dot:
|
||||||
|
return NSUnderlineStyle.patternDot.rawValue
|
||||||
|
|
||||||
|
case .dash:
|
||||||
|
return NSUnderlineStyle.patternDash.rawValue
|
||||||
|
|
||||||
|
case .dashDot:
|
||||||
|
return NSUnderlineStyle.patternDashDot.rawValue
|
||||||
|
|
||||||
|
case .dashDotDot:
|
||||||
|
return NSUnderlineStyle.patternDashDotDot.rawValue
|
||||||
|
|
||||||
|
case .byWord:
|
||||||
|
return NSUnderlineStyle.byWord.rawValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -439,13 +439,17 @@ import UIKit
|
|||||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.showRightPanel(animated: true)
|
MVMCoreUISession.sharedGlobal()?.splitViewController?.showRightPanel(animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Override this method to avoid adding form params.
|
||||||
|
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
||||||
|
formValidator?.addFormParams(requestParameters: requestParameters)
|
||||||
|
}
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreActionDelegateProtocol
|
// MARK: - MVMCoreActionDelegateProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) {
|
open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) {
|
||||||
formValidator?.addFormParams(requestParameters: requestParameters)
|
addFormParams(requestParameters)
|
||||||
requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType")
|
requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType")
|
||||||
MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: delegateObject())
|
MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: delegateObject())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user