summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/NewPostViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-02 11:19:37 +0300
committerGravatar Vitaly Takmazov2019-10-02 11:19:37 +0300
commit60ccb1ddfd3cd93147f7427ecc1274bf561be35b (patch)
treef097c436c493281b0dfa1c16502d9adae4f9fa67 /Juick/ViewControllers/NewPostViewController.m
parent0d0fa77e02a22bd7b70069c34f8b9f7308c03efd (diff)
Disable send button on empty text
Diffstat (limited to 'Juick/ViewControllers/NewPostViewController.m')
-rw-r--r--Juick/ViewControllers/NewPostViewController.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m
index afa14a9..b992ed8 100644
--- a/Juick/ViewControllers/NewPostViewController.m
+++ b/Juick/ViewControllers/NewPostViewController.m
@@ -40,13 +40,14 @@ NSString * const ReplyPostedNotificationName = @"ReplyPosted";
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
+ self.textView.delegate = self;
[self.textView becomeFirstResponder];
}
- (IBAction)sendAction:(id)sender {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
+ self.navigationItem.rightBarButtonItem.enabled = NO;
if (_replyTo == nil) {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
+ self.navigationItem.rightBarButtonItem.enabled = YES;
[[APIClient sharedClient] postMessage:self.textView.text result:^(Message *msg, NSError *err) {
if (!err) {
[self dismissViewControllerAnimated:YES completion:^{
@@ -58,14 +59,14 @@ NSString * const ReplyPostedNotificationName = @"ReplyPosted";
}
}];
} else {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
+ self.navigationItem.rightBarButtonItem.enabled = NO;
[[APIClient sharedClient] postReplyToThread:_replyTo.mid inReplyTo:_replyTo.rid text:self.textView.text result:^(Message *msg, NSError *err) {
if (!err) {
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:ReplyPostedNotificationName object:msg];
}];
} else {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
+ self.navigationItem.rightBarButtonItem.enabled = YES;
// TODO: display error
}
}];
@@ -96,4 +97,8 @@ NSString * const ReplyPostedNotificationName = @"ReplyPosted";
return _inputAccessoryView;
}
+- (void)textViewDidChange:(UITextView *)textView {
+ self.navigationItem.rightBarButtonItem.enabled = [textView.text length];
+}
+
@end