Merge branch 'develop' into feature/delegate_object
This commit is contained in:
commit
2821f7ea09
@ -10,7 +10,7 @@
|
||||
import MVMCore
|
||||
|
||||
public typealias ActionBlock = () -> Void
|
||||
private typealias ActionIndiciesTuple = (startIndex: String.Index?, endIndex: String.Index?, revisedText: String?)
|
||||
private typealias ActionableStringTuple = (front: String?, middle: String?, end: String?)
|
||||
public typealias ActionObjectDelegate = (NSObjectProtocol & MVMCoreActionDelegateProtocol)
|
||||
public typealias ButtonObjectDelegate = (NSObjectProtocol & ButtonDelegateProtocol)
|
||||
public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProtocol & MVMCoreLoadDelegateProtocol & MVMCorePresentationDelegateProtocol & NSObjectProtocol
|
||||
@ -381,37 +381,40 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
||||
|
||||
private func setText(_ text: String?, startTag: String?, endTag: String?) {
|
||||
|
||||
let actionRange: ActionIndiciesTuple = rangeOfText(text, startTag: startTag, endTag: endTag)
|
||||
let actionableTuple: ActionableStringTuple = rangeOfText(text, startTag: startTag, endTag: endTag)
|
||||
|
||||
if let revisedText = actionRange.revisedText, let startBraceIndex = actionRange.startIndex, let endBraceIndex = actionRange.endIndex {
|
||||
|
||||
frontText = String(revisedText[revisedText.startIndex..<startBraceIndex]).trimmingCharacters(in: .whitespaces)
|
||||
actionText = String(revisedText[startBraceIndex..<endBraceIndex]).trimmingCharacters(in: .whitespaces)
|
||||
backText = String(revisedText[endBraceIndex...]).trimmingCharacters(in: .whitespaces)
|
||||
if let front = actionableTuple.front, let middle = actionableTuple.middle, let end = actionableTuple.end {
|
||||
frontText = front.trimmingCharacters(in: .whitespaces)
|
||||
actionText = middle.trimmingCharacters(in: .whitespaces)
|
||||
backText = end.trimmingCharacters(in: .whitespaces)
|
||||
self.text = getTextFromStringComponents()
|
||||
} else {
|
||||
frontText = actionRange.revisedText
|
||||
self.text = actionRange.revisedText
|
||||
frontText = text
|
||||
self.text = text
|
||||
}
|
||||
|
||||
setup()
|
||||
}
|
||||
|
||||
private func rangeOfText(_ text: String?, startTag: String?, endTag: String?) -> ActionIndiciesTuple {
|
||||
private func rangeOfText(_ text: String?, startTag: String?, endTag: String?) -> ActionableStringTuple {
|
||||
|
||||
var fullText = text ?? ""
|
||||
var actionRange: ActionIndiciesTuple = (startIndex: nil, endIndex: nil, revisedText: nil)
|
||||
var actionableTuple: ActionableStringTuple = (front: nil, middle: nil, end: nil)
|
||||
|
||||
if let leftBrace = startTag, let rightBrace = endTag, fullText.contains(Character(leftBrace)) && fullText.contains(Character(rightBrace)) {
|
||||
actionRange.startIndex = fullText.firstIndex(of: Character(leftBrace))
|
||||
fullText = fullText.replacingOccurrences(of: leftBrace, with: "")
|
||||
guard let text = text else { return actionableTuple }
|
||||
|
||||
if let leftTag = startTag, text.contains(leftTag) {
|
||||
|
||||
actionRange.endIndex = fullText.firstIndex(of: Character(rightBrace))
|
||||
fullText = fullText.replacingOccurrences(of: rightBrace, with: "")
|
||||
let firstHalf = text.components(separatedBy: leftTag)
|
||||
actionableTuple.front = firstHalf.first
|
||||
|
||||
if let rightTag = endTag, text.contains(rightTag) {
|
||||
let secondHalf = firstHalf[1].components(separatedBy: rightTag)
|
||||
actionableTuple.middle = secondHalf[0]
|
||||
actionableTuple.end = secondHalf[1]
|
||||
}
|
||||
}
|
||||
|
||||
actionRange.revisedText = fullText
|
||||
return actionRange
|
||||
|
||||
return actionableTuple
|
||||
}
|
||||
|
||||
@objc public func setActionMap(_ actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate delegate: ActionObjectDelegate?) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user