summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/Main.storyboard2
-rw-r--r--Juick/ViewControllers/NewPostViewController.h2
-rw-r--r--Juick/ViewControllers/NewPostViewController.m13
3 files changed, 11 insertions, 6 deletions
diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard
index 81266dd..00ee720 100644
--- a/Juick/Main.storyboard
+++ b/Juick/Main.storyboard
@@ -302,7 +302,7 @@
<viewLayoutGuide key="safeArea" id="UJz-7C-l1q"/>
</view>
<navigationItem key="navigationItem" id="Yd6-Yh-gtd">
- <barButtonItem key="rightBarButtonItem" title="Send" id="GOm-zk-CTO">
+ <barButtonItem key="rightBarButtonItem" enabled="NO" title="Send" id="GOm-zk-CTO">
<connections>
<action selector="sendAction:" destination="rr1-jx-MLx" id="Nd3-Zm-2GK"/>
</connections>
diff --git a/Juick/ViewControllers/NewPostViewController.h b/Juick/ViewControllers/NewPostViewController.h
index 05e3c73..9d1297c 100644
--- a/Juick/ViewControllers/NewPostViewController.h
+++ b/Juick/ViewControllers/NewPostViewController.h
@@ -12,7 +12,7 @@
extern NSString * const NewMessageNotificationName;
extern NSString * const ReplyPostedNotificationName;
-@interface NewPostViewController : UIViewController
+@interface NewPostViewController : UIViewController<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
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