From a5c35479e144eef8bea9f80a10dfeb7a860763f1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 3 Oct 2019 15:16:18 +0300 Subject: Drop PHFComposeBarView --- Juick/Supporting Files/Juick-Prefix.pch | 1 - Juick/ViewControllers/ChatViewController.h | 3 ++- Juick/ViewControllers/ChatViewController.m | 27 +++++++++++++++------------ Juick/Views/MessageInputView.h | 9 +++++++++ Juick/Views/MessageInputView.m | 4 ++++ Juick/Views/MessageInputView.xib | 24 ++++++++++++------------ 6 files changed, 42 insertions(+), 26 deletions(-) (limited to 'Juick') diff --git a/Juick/Supporting Files/Juick-Prefix.pch b/Juick/Supporting Files/Juick-Prefix.pch index 3a66330..2e32df2 100644 --- a/Juick/Supporting Files/Juick-Prefix.pch +++ b/Juick/Supporting Files/Juick-Prefix.pch @@ -19,6 +19,5 @@ #import "UIImage+Utils.h" #import - #import #import #endif diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h index 4a5133a..bfd63e7 100644 --- a/Juick/ViewControllers/ChatViewController.h +++ b/Juick/ViewControllers/ChatViewController.h @@ -8,8 +8,9 @@ #import #import "User.h" +#import "MessageInputView.h" -@interface ChatViewController : UITableViewController +@interface ChatViewController : UITableViewController @property(nonatomic, strong) NSMutableArray *messages; @property(nonatomic, strong) NSString *uname; diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 989b531..2612719 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -10,9 +10,11 @@ #import "BubbleMessageCell.h" #import "APIClient.h" +#import "MessageInputView.h" + @interface ChatViewController () -@property (nonatomic, readwrite, retain) UIView *inputAccessoryView; +@property (nonatomic, readwrite, retain) MessageInputView *accessoryView; @property (nonatomic, strong) NSString *me; @end @@ -26,6 +28,7 @@ self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; self.tableView.allowsSelection = NO; + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; self.me = [APIClient sharedClient].credential.user; [self reloadChat]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; @@ -77,15 +80,16 @@ return YES; } +- (BOOL)canResignFirstResponder { + return YES; +} + - (UIView *) inputAccessoryView { - if (!_inputAccessoryView) { - PHFComposeBarView *composeView = [[PHFComposeBarView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - PHFComposeBarViewInitialHeight, self.view.bounds.size.width, PHFComposeBarViewInitialHeight)]; - composeView.delegate = self; - [composeView.bottomAnchor constraintEqualToSystemSpacingBelowAnchor:self.view.safeAreaLayoutGuide.bottomAnchor multiplier:1.0f]; - composeView.maxLinesCount = 4; - _inputAccessoryView = composeView; + if (!_accessoryView) { + _accessoryView = [[[NSBundle mainBundle] loadNibNamed:@"MessageInputView" owner:self options:nil] firstObject]; + _accessoryView.delegate = self; } - return _inputAccessoryView; + return _accessoryView; } -(void) keyboardWillChangeFrame:(NSNotification *)notification { @@ -102,12 +106,11 @@ } } --(void) composeBarViewDidPressButton:(PHFComposeBarView *)composeBarView { - [[APIClient sharedClient] postPMToUser:self.uname text:composeBarView.text result:^(NSError *err) { +-(void) textSent:(NSString *)text { + [[APIClient sharedClient] postPMToUser:self.uname text:text result:^(NSError *err) { if (!err) { NSLog(@"Success!"); - [composeBarView becomeFirstResponder]; - [composeBarView setText:nil animated:NO]; + [self.accessoryView becomeFirstResponder]; [self reloadChat]; } }]; diff --git a/Juick/Views/MessageInputView.h b/Juick/Views/MessageInputView.h index 38ce721..c78f498 100644 --- a/Juick/Views/MessageInputView.h +++ b/Juick/Views/MessageInputView.h @@ -8,8 +8,17 @@ #import +@protocol MessageInputDelegate + +-(void) textSent:(NSString *)text; + +@end + @interface MessageInputView : UIVisualEffectView @property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint; @property (strong, nonatomic) IBOutlet UITextField *textView; +- (IBAction)sendPressed:(id)sender; + +@property (nonatomic, weak) id delegate; @end diff --git a/Juick/Views/MessageInputView.m b/Juick/Views/MessageInputView.m index ab6b3e5..c4d96de 100644 --- a/Juick/Views/MessageInputView.m +++ b/Juick/Views/MessageInputView.m @@ -15,4 +15,8 @@ [self setTintColor:[UIColor colorNamed:@"Title"]]; } +- (IBAction)sendPressed:(id)sender { + [self.delegate textSent:self.textView.text]; + self.textView.text = nil; +} @end diff --git a/Juick/Views/MessageInputView.xib b/Juick/Views/MessageInputView.xib index 240391c..9cb8bd4 100644 --- a/Juick/Views/MessageInputView.xib +++ b/Juick/Views/MessageInputView.xib @@ -1,41 +1,41 @@ - - - - + + - + - + - + - + - - + -- cgit v1.2.3