blob: 06cbf9a5c94236bf35b8459530dded571e3929b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
//
// ThreadViewController.m
// Juick
//
// Created by Vitaly Takmazov on 24/09/2017.
// Copyright © 2017 com.juick. All rights reserved.
//
#import "ThreadViewController.h"
#import "ColorScheme.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;
}
- (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;
}
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
|