diff options
author | Vitaly Takmazov | 2017-12-04 00:20:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-04 00:20:02 +0300 |
commit | 3c680cfe8c1e6cfbce16f787fbf01fdb3f7c40ae (patch) | |
tree | 51c90370eae5c622ab305bc4bd7eb0a34fd96f2a /Juick/ViewControllers/ThreadViewController.m | |
parent | ccf06c2af74f63e5276e15f3e10acf74bf4174f7 (diff) |
WIP
Diffstat (limited to 'Juick/ViewControllers/ThreadViewController.m')
-rw-r--r-- | Juick/ViewControllers/ThreadViewController.m | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index 4de0cab..2b0d3c4 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -9,13 +9,15 @@ #import "ThreadViewController.h" #import "ColorScheme.h" #import "MessageCell.h" -@import PHFComposeBarView; +#import "MessageInputView.h" +#import "APIClient.h" @interface ThreadViewController () @property (nonatomic, readwrite, retain) UIView *inputAccessoryView; -(void) updateQuoteText:(Message *)message; +@property NSNumber *replyTo; @end @@ -23,6 +25,9 @@ - (void)viewDidLoad { [super viewDidLoad]; + self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; + + _replyTo = @(0); } @@ -32,26 +37,36 @@ - (UIView *)inputAccessoryView { if (!_inputAccessoryView) { - CGRect viewBounds = self.view.bounds; - CGRect frame = CGRectMake(0, viewBounds.size.height - PHFComposeBarViewInitialHeight - self.view.safeAreaInsets.top + self.view.safeAreaInsets.bottom, viewBounds.size.width, PHFComposeBarViewInitialHeight); - PHFComposeBarView *inputView = [[PHFComposeBarView alloc] initWithFrame:frame]; - inputView.backgroundColor = [UIColor whiteColor]; + 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.delegate = self;*/ + inputView.autoresizingMask = UIViewAutoresizingFlexibleHeight; + [inputView.sendButton addTarget:self action:@selector(sendReply) forControlEvents:UIControlEventTouchUpInside]; _inputAccessoryView = inputView; } return _inputAccessoryView; } -(void) updateQuoteText:(Message *)message { - /*MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; - inputView.quoteText.text = message.text;*/ + MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; + inputView.quoteText.text = message.text; + [inputView.contentView setNeedsUpdateConstraints]; + [inputView.contentView updateConstraintsIfNeeded]; + [inputView.contentView setNeedsLayout]; + [inputView.contentView layoutIfNeeded]; +} +-(void) sendReply { + MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; + Message *msg = [self.messages firstObject]; + [[APIClient sharedClient] postReplyToThread:msg.mid inReplyTo:self.replyTo text:inputView.textContent.text]; } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Message * selectedMessage = [self.messages objectAtIndex:indexPath.row]; + _replyTo = selectedMessage.rid; [self updateQuoteText:selectedMessage]; } |