summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-03-20 12:47:37 +0300
committerGravatar Vitaly Takmazov2021-03-20 12:47:37 +0300
commitae2b92c2876e3c0c8c8266187ad0eb4ae29fe5a8 (patch)
tree5cfd54aafeecf84d7bd846ab1302a0abd799d06b /Juick/ViewControllers
parent4a892ab5db316d4e90d580d0192c55cd11e452c1 (diff)
First part of the new chat view keyboard avoiding
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/ChatViewController.h1
-rw-r--r--Juick/ViewControllers/ChatViewController.m9
2 files changed, 8 insertions, 2 deletions
diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h
index f21eb10..f23ecc8 100644
--- a/Juick/ViewControllers/ChatViewController.h
+++ b/Juick/ViewControllers/ChatViewController.h
@@ -14,6 +14,7 @@
@property(nonatomic, strong) NSMutableArray *messages;
@property(nonatomic, strong) NSString *uname;
@property (weak, nonatomic) IBOutlet UIStackView *stack;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *stackBottomConstraint;
@property (strong, nonatomic) IBOutlet UITableView *tableView;
-(void) reloadChat;
diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m
index 9493155..cfecc48 100644
--- a/Juick/ViewControllers/ChatViewController.m
+++ b/Juick/ViewControllers/ChatViewController.m
@@ -11,6 +11,8 @@
#import "MessageInputView.h"
+#define kMessageInputInitialHeight 50
+
@interface ChatViewController ()
@property (nonatomic, readwrite, retain) MessageInputView *accessoryView;
@@ -37,6 +39,8 @@
[self addObserver:self forKeyPath:@"uname" options:0 context:nil];
#if TARGET_OS_MACCATALYST
[self.stack addArrangedSubview:[self inputAccessoryView]];
+#else
+ self.stackBottomConstraint.constant = kMessageInputInitialHeight;
#endif
}
@@ -102,11 +106,12 @@
if (userInfo) {
CGRect beginFrame = [userInfo [UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGFloat delta = endFrame.origin.y - beginFrame.origin.y;
+ CGFloat keyboardHeight = endFrame.origin.y - beginFrame.origin.y;
CGFloat duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
UIViewAnimationCurve animationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
+
[UIView animateWithDuration:duration delay:0 options:(animationCurve << 16) animations:^{
- self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - delta);
+ self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - keyboardHeight);
} completion:nil];
}
}