From 6beab303e854a90421746a3fcd58860eb70b4045 Mon Sep 17 00:00:00 2001 From: Chris Lee <86325581+joonchrislee@users.noreply.github.com> Date: Tue, 20 Sep 2022 03:12:47 -0400 Subject: [PATCH] fix: specify public scope --- Sources/TokenTextView/Token.swift | 6 ++--- Sources/TokenTextView/TokenTextView.swift | 14 ++++++------ .../TokenTextViewAttributes.swift | 22 +++++++++++++------ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Sources/TokenTextView/Token.swift b/Sources/TokenTextView/Token.swift index feb835d..eb4c0fd 100644 --- a/Sources/TokenTextView/Token.swift +++ b/Sources/TokenTextView/Token.swift @@ -1,8 +1,8 @@ import Foundation -struct Token: Codable { - let name: String - let identifier: String +public struct Token: Codable { + public let name: String + public let identifier: String } class TokenInstance: NSCopying, Codable { diff --git a/Sources/TokenTextView/TokenTextView.swift b/Sources/TokenTextView/TokenTextView.swift index 860492a..443f58d 100644 --- a/Sources/TokenTextView/TokenTextView.swift +++ b/Sources/TokenTextView/TokenTextView.swift @@ -1,19 +1,19 @@ import UIKit -final class TokenTextView: UITextView { +public class TokenTextView: UITextView { // MARK: Public properties - var tokenAttributes: TokenTextViewAttributes - var textAttributes: TokenTextViewAttributes + public var tokenAttributes: TokenTextViewAttributes + public var textAttributes: TokenTextViewAttributes - var tokenList: [Token] = [Token]() { + public var tokenList: [Token] = [Token]() { didSet { tokenizeText() } } - var templatedText: String { + public var templatedText: String { // Ensure all tokens ranges have been updated guard tokenInstances.first(where: {$0.range.upperBound - 1 >= text.count}) == nil else { print("TokenTextView: Failed to create templated text.") @@ -35,7 +35,7 @@ final class TokenTextView: UITextView { // MARK: Setup - init(text: String? = nil, + public init(text: String? = nil, tokenList: [Token] = [], tokenOpen: String = "{{", tokenClose: String = "}}", @@ -69,7 +69,7 @@ final class TokenTextView: UITextView { // MARK: Public methods - func insertToken(_ token: Token, at insertRange: NSRange? = nil) { + public func insertToken(_ token: Token, at insertRange: NSRange? = nil) { let location = insertRange != nil ? (insertRange?.location)! : selectedRange.location let tokenRange = NSRange(location: location, length: token.name.count) diff --git a/Sources/TokenTextView/TokenTextViewAttributes.swift b/Sources/TokenTextView/TokenTextViewAttributes.swift index 12971a2..3329521 100644 --- a/Sources/TokenTextView/TokenTextViewAttributes.swift +++ b/Sources/TokenTextView/TokenTextViewAttributes.swift @@ -1,13 +1,13 @@ import UIKit -struct TokenTextViewAttributes { - var backgroundColor: UIColor - var foregroundColor: UIColor - var font: UIFont - var kern: Int? - var paragraphStyle: NSMutableParagraphStyle? +public struct TokenTextViewAttributes { + public var backgroundColor: UIColor + public var foregroundColor: UIColor + public var font: UIFont + public var kern: Int? + public var paragraphStyle: NSMutableParagraphStyle? - var dictionary: [NSAttributedString.Key: Any] { + public var dictionary: [NSAttributedString.Key: Any] { var dictionary = [NSAttributedString.Key.backgroundColor: backgroundColor, NSAttributedString.Key.foregroundColor: foregroundColor, NSAttributedString.Key.font: font, @@ -19,4 +19,12 @@ struct TokenTextViewAttributes { return dictionary } + + public init(backgroundColor: UIColor, foregroundColor: UIColor, font: UIFont, kern: Int? = nil, paragraphStyle: NSMutableParagraphStyle? = nil) { + self.backgroundColor = backgroundColor + self.foregroundColor = foregroundColor + self.font = font + self.kern = kern + self.paragraphStyle = paragraphStyle + } }