diff options
author | Vitaly Takmazov | 2017-12-09 23:47:30 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-09 23:47:30 +0300 |
commit | a38541e14ecfea8e37c80755fb3b2ef25cd81272 (patch) | |
tree | 3b26f5e4f86a4eb103193535abf7f9b15e0e67e6 /Juick/ViewControllers/ThreadViewController.m | |
parent | e2ac87809468e9487389e5d22ab9766996898478 (diff) |
working post/reply
Diffstat (limited to 'Juick/ViewControllers/ThreadViewController.m')
-rw-r--r-- | Juick/ViewControllers/ThreadViewController.m | 63 |
1 files changed, 10 insertions, 53 deletions
diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index 06cbf9a..8cb2cb5 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -7,70 +7,27 @@ // #import "ThreadViewController.h" -#import "ColorScheme.h" +#import "NewPostViewController.h" #import "MessageCell.h" -#import "MessageInputView.h" -#import "APIClient.h" @interface ThreadViewController () -@property (nonatomic, readwrite, retain) UIView *inputAccessoryView; - --(void) updateQuoteText:(Message *)message; -@property NSNumber *replyTo; - @end @implementation ThreadViewController -- (void)viewDidLoad { - [super viewDidLoad]; - self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; - - _replyTo = @(0); -} - - -- (BOOL) canBecomeFirstResponder { - return YES; +-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + NSString * cellIdentifier = @"messageCell"; + MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; + [self performSegueWithIdentifier:@"replySegue" sender:cell]; } -- (UIView *)inputAccessoryView { - if (!_inputAccessoryView) { - MessageInputView *inputView = (MessageInputView *)[[[NSBundle mainBundle] loadNibNamed:@"MessageInputView" owner:self options:nil] firstObject]; - /*inputView.backgroundColor = [UIColor whiteColor]; - inputView.buttonTintColor = [ColorScheme linkColor]; - inputView.maxLinesCount = 4; - inputView.utilityButtonImage = [UIImage imageNamed:@"Camera"]; - inputView.delegate = self;*/ - inputView.autoresizingMask = UIViewAutoresizingFlexibleHeight; - [inputView.sendButton addTarget:self action:@selector(sendReply) forControlEvents:UIControlEventTouchUpInside]; - _inputAccessoryView = inputView; +-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + if ([segue.identifier isEqual: @"replySegue"]) { + Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; + NewPostViewController *postVC = (NewPostViewController *)segue.destinationViewController; + [postVC setReplyTo:msg]; } - return _inputAccessoryView; -} - --(void) updateQuoteText:(Message *)message { - MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; - inputView.quoteText.text = message.text; - [inputView.textContent becomeFirstResponder]; -} --(void) sendReply { - MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; - Message *msg = [self.messages firstObject]; - [[APIClient sharedClient] postReplyToThread:msg.mid inReplyTo:self.replyTo text:inputView.textContent.text result:^(Message *msg, NSError *err) { - MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; - inputView.quoteText.text = @""; - inputView.textContent.text = @""; - [inputView.textContent endEditing:YES]; - [self refreshData]; - }]; -} - --(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - Message * selectedMessage = [self.messages objectAtIndex:indexPath.row]; - _replyTo = selectedMessage.rid; - [self updateQuoteText:selectedMessage]; } @end |