Skip to content

Commit

Permalink
Merge pull request #4 from JNDisrupter/development
Browse files Browse the repository at this point in the history
Add Resign First Responder Method
  • Loading branch information
jayelzaghmoutt authored Jul 2, 2019
2 parents 02c68ef + e238149 commit b0b0426
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
40 changes: 20 additions & 20 deletions Example/Pods/Target Support Files/JNMentionTextView/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion JNMentionTextView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "JNMentionTextView"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "JNMentionTextView is a UITextView replacement supporting the mention feature for iOS applications."
s.description = "A UITextView drop-in replacement supporting special characters such as [ #, @ ] and regex patterns, written in Swift."
s.homepage = "https://github.com/JNDisrupter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,24 @@ extension JNMentionTextView {

/**
End Mention Process
- Parameter animated: is animated bool value.
- Parameter completion: completion block.
*/
func endMentionProcess() {
func endMentionProcess(animated: Bool = true, completion: (() -> ())? = nil) {

if let pickerView = self.pickerViewController {
pickerView.dismiss(animated: true, completion: {
if let pickerView = self.pickerViewController, self.isInMentionProcess() {
pickerView.dismiss(animated: animated, completion: {

self.searchString = ""
self.selectedSymbol = ""
self.selectedSymbolLocation = 0
self.selectedSymbolAttributes = [:]

completion?()
})
} else {

completion?()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ extension JNMentionTextView: UITextViewDelegate {
public func textViewDidEndEditing(_ textView: UITextView) {

// end mention process
self.endMentionProcess()
self.mentionDelegate?.textViewDidEndEditing?(textView)
self.endMentionProcess {
self.mentionDelegate?.textViewDidEndEditing?(textView)
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ public class JNMentionTextView: UITextView {

self.initView()
}

/**
Resign First Responder
- Parameter completion: Completion block.
*/
public func resignFirstResponder(completion: (() -> ())? = nil){

// end mention process
self.endMentionProcess(animated: false) {
self.resignFirstResponder()
completion?()
}
}

/**
Init View
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ Consider the String as template that retured from the BackEnd has this format an
```swift
getSmartReplacement(text: String, data: [String: [JNMentionPickable]], normalAttributes: [NSAttributedString.Key: Any], mentionReplacements: [String: [NSAttributedString.Key : Any]]) -> NSAttributedString
```

- **Resign First Responder:**
This method is a wrapper of resignFirstResponder for UITextView, but it handle the dismissal of Picker ViewController

```swift
public func resignFirstResponder(completion: (() -> ())? = nil)
```

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.
Expand Down

0 comments on commit b0b0426

Please sign in to comment.