@@ -43,7 +43,6 @@ @interface QMChatViewController ()
4343
4444// Keyboard observing
4545@property (strong , nonatomic ) QMKVOView *systemInputToolbar;
46- @property (weak , nonatomic ) QMKVOView *inputAccessoryView;
4746
4847@end
4948
@@ -98,24 +97,25 @@ - (void)viewDidLoad {
9897 self.systemInputToolbar .hostViewFrameChangeBlock = ^(UIView *view, BOOL animated) {
9998
10099 CGFloat pos = view.superview .frame .size .height - view.frame .origin .y ;
101- if (view.superview .frame .origin .y > 0 && pos == 0 ) {
102- return ;
103- }
104100
105- if (!weakSelf.inputToolbar .contentView .textView .isFirstResponder && pos == 0 ) {
106- [weakSelf setToolbarBottomConstraintValue: [weakSelf inputToolBarStartPos ]
107- animated: animated];
108- return ;
101+ if (weakSelf.inputToolbar .contentView .textView .isFirstResponder ) {
102+
103+ if (view.superview .frame .origin .y > 0 && pos == 0 ) {
104+ return ;
105+ }
109106 }
110-
107+
111108 const CGFloat v = [weakSelf inputToolBarStartPos ];
109+
112110 if (pos < v ) {
113111 pos = v;
114112 }
115113
116114 [weakSelf setToolbarBottomConstraintValue: pos animated: animated];
117115 };
118116
117+ self.inputToolbar .contentView .textView .inputAccessoryView = self.systemInputToolbar ;
118+
119119 self.edgesForExtendedLayout = UIRectEdgeNone;
120120}
121121
@@ -204,20 +204,8 @@ - (void)registerCells {
204204 [QMChatIncomingLinkPreviewCell registerForReuseInView: self .collectionView];
205205 // Register link preview outgoing cell
206206 [QMChatOutgoingLinkPreviewCell registerForReuseInView: self .collectionView];
207- UINib *locIncomingNib = [QMChatLocationIncomingCell nib ];
208- NSString *locIncomingIdentifier = [QMChatLocationIncomingCell cellReuseIdentifier ];
209- [self .collectionView registerNib: locIncomingNib forCellWithReuseIdentifier: locIncomingIdentifier];
210207}
211208
212- #pragma mark - UI Responder
213-
214- - (UIView *)inputAccessoryView {
215- return self.systemInputToolbar ;
216- }
217-
218- - (BOOL )canBecomeFirstResponder {
219- return YES ;
220- }
221209
222210#pragma mark - Getters
223211
@@ -250,18 +238,18 @@ - (void)changeDataSource:(QMChatDataSource *)dataSource
250238 }
251239
252240 switch (updateType) {
253-
241+
254242 case QMDataSourceActionTypeAdd:
255- [self .collectionView insertItemsAtIndexPaths: indexPaths];
256- break ;
257-
243+ [self .collectionView insertItemsAtIndexPaths: indexPaths];
244+ break ;
245+
258246 case QMDataSourceActionTypeUpdate:
259- [self .collectionView reloadItemsAtIndexPaths: indexPaths];
260- break ;
261-
247+ [self .collectionView reloadItemsAtIndexPaths: indexPaths];
248+ break ;
249+
262250 case QMDataSourceActionTypeRemove:
263- [self .collectionView deleteItemsAtIndexPaths: indexPaths];
264- break ;
251+ [self .collectionView deleteItemsAtIndexPaths: indexPaths];
252+ break ;
265253 }
266254 };
267255
@@ -523,7 +511,9 @@ - (UICollectionViewCell *)collectionView:(QMChatCollectionView *)collectionView
523511 return cell;
524512}
525513
526- - (void )collectionView : (QMChatCollectionView *)collectionView configureCell : (UICollectionViewCell *)cell forIndexPath : (NSIndexPath *)indexPath {
514+ - (void )collectionView : (QMChatCollectionView *)collectionView
515+ configureCell : (UICollectionViewCell *)cell
516+ forIndexPath : (NSIndexPath *)indexPath {
527517
528518 if ([cell isKindOfClass: [QMChatContactRequestCell class ]]) {
529519
@@ -544,8 +534,8 @@ - (void)collectionView:(QMChatCollectionView *)collectionView configureCell:(UIC
544534 QMChatCell *chatCell = (QMChatCell *)cell;
545535
546536 if ([cell isKindOfClass: [QMChatIncomingCell class ]]
547- || [cell isKindOfClass: [QMChatOutgoingCell class ]] ||
548- [cell isKindOfClass: [QMChatBaseLinkPreviewCell class ]]) {
537+ || [cell isKindOfClass: [QMChatOutgoingCell class ]]
538+ || [cell isKindOfClass: [QMChatBaseLinkPreviewCell class ]]) {
549539
550540 chatCell.textView .enabledTextCheckingTypes = self.enableTextCheckingTypes ;
551541 }
@@ -622,8 +612,7 @@ - (QMChatCellLayoutModel)collectionView:(QMChatCollectionView *)collectionView
622612
623613#pragma mark - Input toolbar delegate
624614
625- - (void )messagesInputToolbar : (QMInputToolbar *)toolbar
626- didPressLeftBarButton : (UIButton *)sender {
615+ - (void )messagesInputToolbar : (QMInputToolbar *)toolbar didPressLeftBarButton : (UIButton *)sender {
627616
628617 if (toolbar.sendButtonOnRight ) {
629618
@@ -635,8 +624,7 @@ - (void)messagesInputToolbar:(QMInputToolbar *)toolbar
635624 }
636625}
637626
638- - (void )messagesInputToolbar : (QMInputToolbar *)toolbar
639- didPressRightBarButton : (UIButton *)sender {
627+ - (void )messagesInputToolbar : (QMInputToolbar *)toolbar didPressRightBarButton : (UIButton *)sender {
640628
641629 if (toolbar.sendButtonOnRight ) {
642630
@@ -794,7 +782,7 @@ - (void)setToolbarBottomConstraintValue:(CGFloat)constraintValue animated:(BOOL)
794782 self.toolbarBottomLayoutGuide .constant = constraintValue;
795783
796784 if (animated) {
797-
785+
798786 self.navigationController .interactivePopGestureRecognizer .enabled = NO ;
799787 dispatch_after (dispatch_time (DISPATCH_TIME_NOW , (int64_t )(0.5 * NSEC_PER_SEC )), dispatch_get_main_queue (), ^{
800788
@@ -951,10 +939,10 @@ - (void)checkAuthorizationStatusWithCompletion:(void (^)(BOOL granted))completio
951939 switch (status)
952940 {
953941 case PHAuthorizationStatusAuthorized:
954- if (completion) {
955- completion (YES );
956- }
957- break ;
942+ if (completion) {
943+ completion (YES );
944+ }
945+ break ;
958946 case PHAuthorizationStatusNotDetermined:
959947 {
960948 [PHPhotoLibrary requestAuthorization: ^(PHAuthorizationStatus authorizationStatus)
@@ -968,10 +956,10 @@ - (void)checkAuthorizationStatusWithCompletion:(void (^)(BOOL granted))completio
968956 break ;
969957 }
970958 default :
971- if (completion) {
972- completion (NO );
973- }
974- break ;
959+ if (completion) {
960+ completion (NO );
961+ }
962+ break ;
975963 }
976964 }
977965}
@@ -1004,8 +992,8 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
1004992
1005993 [coordinator animateAlongsideTransition: nil
1006994 completion: ^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
1007- [self updateCollectionViewInsets ];
1008- }];
995+ [self updateCollectionViewInsets ];
996+ }];
1009997
1010998 if (self.inputToolbar .contentView .textView .isFirstResponder && self.splitViewController ) {
1011999 if (!self.splitViewController .isCollapsed ) {
0 commit comments