Skip to content

Commit

Permalink
fix: specify public scope
Browse files Browse the repository at this point in the history
  • Loading branch information
joonchrislee committed Sep 21, 2022
1 parent 1ea9222 commit 6beab30
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Sources/TokenTextView/Token.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions Sources/TokenTextView/TokenTextView.swift
Original file line number Diff line number Diff line change
@@ -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.")
Expand All @@ -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 = "}}",
Expand Down Expand Up @@ -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)

Expand Down
22 changes: 15 additions & 7 deletions Sources/TokenTextView/TokenTextViewAttributes.swift
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
}
}

0 comments on commit 6beab30

Please sign in to comment.