Просмотр исходного кода

会话列表置顶功能+双击tab刷新列表

Steven 1 год назад
Родитель
Сommit
7196737124

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/TabbarAnimation/AnimationHelper.m

@@ -31,7 +31,7 @@
         [lottieAnimationView removeFromSuperview];
         lottieAnimationView = nil;
     }];
-    
+    lottieAnimationView.userInteractionEnabled = NO;
 }
 
 @end

+ 3 - 1
KulexiuForStudent/KulexiuForStudent/Module/Chat/Controller/KSChatListViewController.m

@@ -28,7 +28,9 @@
 @implementation KSChatListViewController
 
 - (void)refreshChatListMessage {
-    
+    if (self.listVC) {
+        [self.listVC refreshChatListMessage];
+    }
 }
 
 

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/Module/Chat/Controller/KSConversationListController.h

@@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface KSConversationListController : TUIConversationListController
 
+- (void)refreshChatListMessage;
 
 @end
 

+ 47 - 0
KulexiuForStudent/KulexiuForStudent/Module/Chat/Controller/KSConversationListController.m

@@ -16,6 +16,53 @@
 
 @implementation KSConversationListController
 
+- (void)refreshChatListMessage {
+    NSArray *visiableIndexArray = self.tableViewForAll.indexPathsForVisibleRows;
+    if (visiableIndexArray.count) {
+        NSIndexPath *firstIndexPath = [visiableIndexArray firstObject];
+
+        NSInteger firstIndex = firstIndexPath.row;
+        if ([self isAtTheBottomOfTableView]) {
+            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+            [self.tableViewForAll scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
+        }
+        else {
+            TUIConversationListBaseDataProvider *dataProvider = self.tableViewForAll.dataProvider;
+            NSMutableArray *conversationList = dataProvider.conversationList;
+            for (NSInteger index = firstIndex+1; index < conversationList.count; index++) {
+                TUIConversationCellData *model = conversationList[index];
+                if (model.isMarkAsUnread) {
+                    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
+                    [self.tableViewForAll scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
+                    break;
+                }
+                
+                if (index == conversationList.count - 1) {
+                    
+                }
+            }
+        }
+    }
+}
+/**
+ *  判断消息是否在collectionView的底部
+ *
+ *  @return 是否在底部
+ */
+- (BOOL)isAtTheBottomOfTableView {
+    if (self.tableViewForAll.contentSize.height <= self.tableViewForAll.frame.size.height) {
+        return YES;
+    }
+    CGFloat height = self.tableViewForAll.frame.size.height;
+    CGFloat contentOffsetY = self.tableViewForAll.contentOffset.y;
+    CGFloat bottomOffset = self.tableViewForAll.contentSize.height - contentOffsetY;
+    if (bottomOffset <= height) {
+        return YES;
+    }else{
+        return NO;
+    }
+}
+
 - (void)viewDidLoad {
     [super viewDidLoad];
     self.view.backgroundColor = [UIColor clearColor];