Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Input field text disappears on focus out #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,41 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega
Implementing textViewShouldBeginEditing in order to set the text indictor at position 0
*/
open func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
textView.text = ""


if(textView.text == inputTextViewPlaceholder){
textView.text = "";
}

if !textView.text.isEmpty {

UIView.animate(withDuration: 0.1, animations: {
self.sendButton.isEnabled = true
});

}else{

DispatchQueue.main.async(execute: {
textView.selectedRange = NSMakeRange(0, 0)
});
}

textView.textColor = UIColor.n1DarkestGreyColor()
UIView.animate(withDuration: 0.1, animations: {
self.sendButton.isEnabled = true
})
DispatchQueue.main.async(execute: {
textView.selectedRange = NSMakeRange(0, 0)
});
return true
}
/**
Implementing textViewShouldEndEditing in order to re-add placeholder and hiding send button when lost focus
*/
open func textViewShouldEndEditing(_ textView: UITextView) -> Bool {

if self.textInputView.text.isEmpty {

self.addInputSelectorPlaceholder()
UIView.animate(withDuration: 0.1, animations: {
self.sendButton.isEnabled = false
})
}
UIView.animate(withDuration: 0.1, animations: {
self.sendButton.isEnabled = false
})

self.textInputView.resignFirstResponder()
return true
}
Expand Down Expand Up @@ -180,7 +195,9 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega

textInputAreaViewHeight.constant = newFrame.size.height+10


if(textView.text.isEmpty){
self.sendButton.isEnabled = false;
}

}

Expand All @@ -206,6 +223,7 @@ open class NMessengerBarView: InputBarView, UITextViewDelegate, CameraViewDelega
_ = self.controller.sendText(self.textInputView.text,isIncomingMessage: false)
self.textInputView.text = ""
}
sendButton.isEnabled = false;
}
/**
Plus button selector
Expand Down