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