func added. formating and commenting

This commit is contained in:
Kevin G Christiano 2020-09-11 14:16:11 -04:00
parent dc8e580f87
commit 4c0d38e398
9 changed files with 74 additions and 23 deletions

View File

@ -257,8 +257,10 @@ public typealias ActionBlock = () -> ()
switch labelModel.textAlignment { switch labelModel.textAlignment {
case .center: case .center:
textAlignment = .center textAlignment = .center
case .right: case .right:
textAlignment = .right textAlignment = .right
default: default:
textAlignment = .left textAlignment = .left
} }
@ -548,6 +550,23 @@ public typealias ActionBlock = () -> ()
setScale(scale) setScale(scale)
} }
/// Will remove the values contained in attributedText.
func clearAttributes() {
guard let labelText = text,
let attributes = attributedText?.attributes(at: 0, longestEffectiveRange: nil, in: NSRange(location: 0, length: labelText.count))
else { return }
let attributedString = NSMutableAttributedString(string: labelText)
for attribute in attributes {
attributedString.removeAttribute(attribute.key, range: NSRange(location: 0, length: labelText.count))
}
attributedText = attributedString
}
@objc public func updateView(_ size: CGFloat) { @objc public func updateView(_ size: CGFloat) {
scaleSize = size as NSNumber scaleSize = size as NSNumber

View File

@ -6,23 +6,39 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import UIKit
open class LabelAttributeActionModel: LabelAttributeModel { open class LabelAttributeActionModel: LabelAttributeModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
override public class var identifier: String { override public class var identifier: String {
return "action" return "action"
} }
var action: ActionModelProtocol var action: ActionModelProtocol
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(_ location: Int, _ length: Int, action: ActionModelProtocol) { public init(_ location: Int, _ length: Int, action: ActionModelProtocol) {
self.action = action self.action = action
super.init(location, length) super.init(location, length)
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case action case action
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
action = try typeContainer.decodeModel(codingKey: .action) action = try typeContainer.decodeModel(codingKey: .action)

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import UIKit
@objcMembers public class LabelAttributeColorModel: LabelAttributeModel { @objcMembers public class LabelAttributeColorModel: LabelAttributeModel {
//-------------------------------------------------- //--------------------------------------------------

View File

@ -6,8 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import UIKit
@objcMembers public class LabelAttributeFontModel: LabelAttributeModel { @objcMembers public class LabelAttributeFontModel: LabelAttributeModel {
//-------------------------------------------------- //--------------------------------------------------

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import UIKit
class LabelAttributeImageModel: LabelAttributeModel { class LabelAttributeImageModel: LabelAttributeModel {
//-------------------------------------------------- //--------------------------------------------------

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import Foundation
@objcMembers open class LabelAttributeModel: ModelProtocol { @objcMembers open class LabelAttributeModel: ModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
@ -32,6 +31,10 @@ import Foundation
var location: Int var location: Int
var length: Int var length: Int
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(_ location: Int, _ length: Int) { public init(_ location: Int, _ length: Int) {
self.location = location self.location = location
self.length = length self.length = length

View File

@ -6,16 +6,28 @@
// Copyright © 2019 Verizon Wireless. All rights reserved. // Copyright © 2019 Verizon Wireless. All rights reserved.
// //
import UIKit
@objcMembers public class LabelAttributeStrikeThroughModel: LabelAttributeModel { @objcMembers public class LabelAttributeStrikeThroughModel: LabelAttributeModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
override public class var identifier: String { override public class var identifier: String {
return "strikethrough" return "strikethrough"
} }
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
try super.init(from: decoder) try super.init(from: decoder)
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)
} }

View File

@ -6,13 +6,20 @@
// 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 {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
override public class var identifier: String { override public class var identifier: String {
return "underline" return "underline"
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
try super.init(from: decoder) try super.init(from: decoder)
} }

View File

@ -7,8 +7,6 @@
// //
import Foundation
@objcMembers public class LabelModel: MoleculeModelProtocol { @objcMembers public class LabelModel: MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties