|
@@ -28,11 +28,8 @@
|
|
|
|
|
|
#import "SDTimeLineTableViewController.h"
|
|
#import "SDTimeLineTableViewController.h"
|
|
|
|
|
|
-#import "SDRefresh.h"
|
|
|
|
-
|
|
|
|
#import "SDTimeLineTableHeaderView.h"
|
|
#import "SDTimeLineTableHeaderView.h"
|
|
#import "SDTimeLineRefreshHeader.h"
|
|
#import "SDTimeLineRefreshHeader.h"
|
|
-#import "SDTimeLineRefreshFooter.h"
|
|
|
|
#import "SDTimeLineCell.h"
|
|
#import "SDTimeLineCell.h"
|
|
#import "SDTimeLineCellModel.h"
|
|
#import "SDTimeLineCellModel.h"
|
|
|
|
|
|
@@ -55,13 +52,17 @@ static CGFloat textFieldH = 56;
|
|
@property (nonatomic, copy) NSString *commentToUser;
|
|
@property (nonatomic, copy) NSString *commentToUser;
|
|
|
|
|
|
@property (nonatomic, strong) SLMoentsChatView *moentsChatView;
|
|
@property (nonatomic, strong) SLMoentsChatView *moentsChatView;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, strong) SDTimeLineCellCommentItemModel *currentCommentItemModel;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, assign) NSInteger currentPageIndex;
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation SDTimeLineTableViewController
|
|
@implementation SDTimeLineTableViewController
|
|
|
|
|
|
{
|
|
{
|
|
- SDTimeLineRefreshFooter *_refreshFooter;
|
|
|
|
- SDTimeLineRefreshHeader *_refreshHeader;
|
|
|
|
|
|
+// SDTimeLineRefreshFooter *_refreshFooter;
|
|
|
|
+// SDTimeLineRefreshHeader *_refreshHeader;
|
|
CGFloat _lastScrollViewOffsetY;
|
|
CGFloat _lastScrollViewOffsetY;
|
|
CGFloat _totalKeybordHeight;
|
|
CGFloat _totalKeybordHeight;
|
|
}
|
|
}
|
|
@@ -74,16 +75,6 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"日间" style:UIBarButtonItemStyleDone target:self action:@selector(rightBarButtonItemAction:)];
|
|
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"日间" style:UIBarButtonItemStyleDone target:self action:@selector(rightBarButtonItemAction:)];
|
|
|
|
|
|
- rightBarButtonItem.lee_theme
|
|
|
|
- .LeeAddCustomConfig(DAY , ^(UIBarButtonItem *item){
|
|
|
|
-
|
|
|
|
- item.title = @"夜间";
|
|
|
|
-
|
|
|
|
- }).LeeAddCustomConfig(NIGHT , ^(UIBarButtonItem *item){
|
|
|
|
-
|
|
|
|
- item.title = @"日间";
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
//为self.view 添加背景颜色设置
|
|
//为self.view 添加背景颜色设置
|
|
|
|
|
|
self.view.lee_theme
|
|
self.view.lee_theme
|
|
@@ -92,33 +83,15 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = rightBarButtonItem;
|
|
self.navigationItem.rightBarButtonItem = rightBarButtonItem;
|
|
|
|
|
|
- self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
|
-
|
|
|
|
|
|
+ if (@available(iOS 11.0, *)) {
|
|
|
|
+ self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
|
+ } else {
|
|
|
|
+ self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
|
+ }
|
|
self.edgesForExtendedLayout = UIRectEdgeTop;
|
|
self.edgesForExtendedLayout = UIRectEdgeTop;
|
|
|
|
|
|
|
|
|
|
- __weak typeof(self) weakSelf = self;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 上拉加载
|
|
|
|
- _refreshFooter = [SDTimeLineRefreshFooter refreshFooterWithRefreshingText:@"正在加载数据..."];
|
|
|
|
- __weak typeof(_refreshFooter) weakRefreshFooter = _refreshFooter;
|
|
|
|
- [_refreshFooter addToScrollView:self.tableView refreshOpration:^{
|
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
- [weakSelf creatModelsWithCount:10];
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- [weakSelf.tableView reloadDataWithExistedHeightCache]
|
|
|
|
- 作用等同于
|
|
|
|
- [weakSelf.tableView reloadData]
|
|
|
|
- 只是“reloadDataWithExistedHeightCache”刷新tableView但不清空之前已经计算好的高度缓存,用于直接将新数据拼接在旧数据之后的tableView刷新
|
|
|
|
- */
|
|
|
|
- [weakSelf.tableView reloadDataWithExistedHeightCache];
|
|
|
|
-
|
|
|
|
- [weakRefreshFooter endRefreshing];
|
|
|
|
- });
|
|
|
|
- }];
|
|
|
|
-
|
|
|
|
|
|
+ self.currentPageIndex = 1;
|
|
SDTimeLineTableHeaderView *headerView = [SDTimeLineTableHeaderView new];
|
|
SDTimeLineTableHeaderView *headerView = [SDTimeLineTableHeaderView new];
|
|
headerView.frame = CGRectMake(0, 0, 0, 260);
|
|
headerView.frame = CGRectMake(0, 0, 0, 260);
|
|
self.tableView.tableHeaderView = headerView;
|
|
self.tableView.tableHeaderView = headerView;
|
|
@@ -127,34 +100,17 @@ static CGFloat textFieldH = 56;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
|
[self.tableView registerClass:[SDTimeLineCell class] forCellReuseIdentifier:kTimeLineTableViewCellId];
|
|
[self.tableView registerClass:[SDTimeLineCell class] forCellReuseIdentifier:kTimeLineTableViewCellId];
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
|
|
|
+ [self creatModelsWithCount:self.currentPageIndex];
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
{
|
|
{
|
|
[super viewDidAppear:animated];
|
|
[super viewDidAppear:animated];
|
|
[self setupTextField];
|
|
[self setupTextField];
|
|
- if (!_refreshHeader.superview) {
|
|
|
|
-
|
|
|
|
- _refreshHeader = [SDTimeLineRefreshHeader refreshHeaderWithCenter:CGPointMake(40, 45)];
|
|
|
|
- _refreshHeader.scrollView = self.tableView;
|
|
|
|
- __weak typeof(_refreshHeader) weakHeader = _refreshHeader;
|
|
|
|
- __weak typeof(self) weakSelf = self;
|
|
|
|
- [_refreshHeader setRefreshingBlock:^{
|
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
- [weakSelf.dataArray removeAllObjects];
|
|
|
|
- [weakSelf creatModelsWithCount:10];
|
|
|
|
- [weakHeader endRefreshing];
|
|
|
|
- });
|
|
|
|
- }];
|
|
|
|
- [self.tableView.superview addSubview:_refreshHeader];
|
|
|
|
- } else {
|
|
|
|
- [self.tableView.superview bringSubviewToFront:_refreshHeader];
|
|
|
|
- }
|
|
|
|
- [_refreshHeader setRefreshState:SDWXRefreshViewStateRefreshing];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
@@ -169,9 +125,6 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
- (void)dealloc
|
|
- (void)dealloc
|
|
{
|
|
{
|
|
- [_refreshHeader removeFromSuperview];
|
|
|
|
- [_refreshFooter removeFromSuperview];
|
|
|
|
-
|
|
|
|
[_textField removeFromSuperview];
|
|
[_textField removeFromSuperview];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
}
|
|
}
|
|
@@ -199,27 +152,24 @@ static CGFloat textFieldH = 56;
|
|
@"content" : text ?: @"",
|
|
@"content" : text ?: @"",
|
|
@"level" : @"0",
|
|
@"level" : @"0",
|
|
};
|
|
};
|
|
|
|
+ if (weakSelf.isReplayingComment) {
|
|
|
|
+ parameter = @{@"commendId" : weakSelf.currentCommentItemModel.commendId ?: @"",
|
|
|
|
+ @"friendId" : weakSelf.currentCommentItemModel.friendId ?: @"",
|
|
|
|
+ @"replyUserId" : weakSelf.currentCommentItemModel.userId ?: @"",
|
|
|
|
+ @"content" : text ?: @"",
|
|
|
|
+ @"level" : @"0",
|
|
|
|
+ };
|
|
|
|
+ weakSelf.isReplayingComment = NO;
|
|
|
|
+ }
|
|
[[SLHttpCenter SharedInstance] postWithUrl:@"/api/Friend/InsertComment" parameter:parameter success:^(id responseObject) {
|
|
[[SLHttpCenter SharedInstance] postWithUrl:@"/api/Friend/InsertComment" parameter:parameter success:^(id responseObject) {
|
|
SDTimeLineCellCommentItemModel *commentItemModel = [SDTimeLineCellCommentItemModel new];
|
|
SDTimeLineCellCommentItemModel *commentItemModel = [SDTimeLineCellCommentItemModel new];
|
|
SLLoginInfo *targetModel = [SLGlobalInfo SharedInstance].loginInfo;
|
|
SLLoginInfo *targetModel = [SLGlobalInfo SharedInstance].loginInfo;
|
|
-// if (weakSelf.isReplayingComment) {
|
|
|
|
-// commentItemModel.firstUserName = @"GSD_iOS";
|
|
|
|
-// commentItemModel.firstUserId = @"GSD_iOS";
|
|
|
|
-// commentItemModel.secondUserName = weakSelf.commentToUser;
|
|
|
|
-// commentItemModel.secondUserId = weakSelf.commentToUser;
|
|
|
|
-// commentItemModel.commentString = text;
|
|
|
|
-//
|
|
|
|
-// weakSelf.isReplayingComment = NO;
|
|
|
|
-// } else {
|
|
|
|
-// commentItemModel.firstUserName = targetModel.user.name;
|
|
|
|
-// commentItemModel.commentString = text;
|
|
|
|
-// commentItemModel.firstUserId = targetModel.user.userId;
|
|
|
|
-// }
|
|
|
|
commentItemModel.userName = targetModel.user.name;
|
|
commentItemModel.userName = targetModel.user.name;
|
|
commentItemModel.userId = targetModel.user.userId;
|
|
commentItemModel.userId = targetModel.user.userId;
|
|
- commentItemModel.replyUserName = model.userName;
|
|
|
|
|
|
+ commentItemModel.replyUserName = weakSelf.currentCommentItemModel.userName;
|
|
commentItemModel.content = text;
|
|
commentItemModel.content = text;
|
|
commentItemModel.friendId = model.friendId;
|
|
commentItemModel.friendId = model.friendId;
|
|
|
|
+ commentItemModel.level = [parameter objectForKey:@"level"];
|
|
[temp addObject:commentItemModel];
|
|
[temp addObject:commentItemModel];
|
|
model.list = [temp copy];
|
|
model.list = [temp copy];
|
|
[weakSelf.tableView reloadRowsAtIndexPaths:@[weakSelf.currentEditingIndexthPath] withRowAnimation:UITableViewRowAnimationNone];
|
|
[weakSelf.tableView reloadRowsAtIndexPaths:@[weakSelf.currentEditingIndexthPath] withRowAnimation:UITableViewRowAnimationNone];
|
|
@@ -246,49 +196,49 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
- (void)creatModelsWithCount:(NSInteger)count
|
|
- (void)creatModelsWithCount:(NSInteger)count
|
|
{
|
|
{
|
|
-
|
|
|
|
- NSDictionary *parameter = @{@"PageIndex": @"0",
|
|
|
|
- @"PageSize": @"10",
|
|
|
|
- @"type" : @"0",
|
|
|
|
- @"Keyword" : @"",
|
|
|
|
- @"DateBegin" : @"",
|
|
|
|
- @"DateEnd" : @"",
|
|
|
|
- @"SkipCount" : @"",
|
|
|
|
- };
|
|
|
|
- parameter = @{};
|
|
|
|
- WS(weakSelf);
|
|
|
|
- [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/GetFriendList" parameter:parameter success:^(id responseObject) {
|
|
|
|
- NSDictionary *data = [responseObject objectForKey:@"data"];
|
|
|
|
- NSArray *items = [data objectForKey:@"items"];
|
|
|
|
- if (items.count) {
|
|
|
|
- NSMutableArray *marr = [SDTimeLineCellModel mj_objectArrayWithKeyValuesArray:items];
|
|
|
|
- [marr enumerateObjectsUsingBlock:^(SDTimeLineCellModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
- obj.likeItemsArray = [NSMutableArray new];
|
|
|
|
- [obj.likeStr enumerateObjectsUsingBlock:^(id _Nonnull obj1, NSUInteger idx1, BOOL * _Nonnull stop) {
|
|
|
|
- SDTimeLineCellLikeItemModel *model = [[SDTimeLineCellLikeItemModel alloc] init];
|
|
|
|
- model.userName = obj1;
|
|
|
|
- model.userId = @"1111";
|
|
|
|
- [obj.likeItemsArray addObject:model];
|
|
|
|
- }];
|
|
|
|
- }];
|
|
|
|
- [self.dataArray addObjectsFromArray:marr];
|
|
|
|
-
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
- [self.tableView reloadData];
|
|
|
|
- });
|
|
|
|
- [self.dataArray enumerateObjectsUsingBlock:^(SDTimeLineCellModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
- if ([obj.friendImgUrl componentsSeparatedByString:@","].count == 1) {
|
|
|
|
-
|
|
|
|
- [weakSelf.KVOController observe:obj keyPath:@"imageSize" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSKeyValueChangeKey,id> * _Nonnull change) {
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
- [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:idx inSection:0], nil] withRowAnimation:UITableViewRowAnimationAutomatic];
|
|
|
|
- });
|
|
|
|
|
|
+ WEAKSELF;
|
|
|
|
+ [self.tableView tableviewRefresh:self.dataArray TableViewRefresh:^(NSInteger pageNo, TableListCount listCount) {
|
|
|
|
+
|
|
|
|
+ NSDictionary *parameter = @{@"PageIndex": @(pageNo),
|
|
|
|
+ @"PageSize": @(SLPageSize),
|
|
|
|
+ @"type" : @"0",
|
|
|
|
+ };
|
|
|
|
+ WS(weakSelf);
|
|
|
|
+ [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/GetFriendList" parameter:parameter success:^(id responseObject) {
|
|
|
|
+ NSDictionary *data = [responseObject objectForKey:@"data"];
|
|
|
|
+ NSArray *items = [data objectForKey:@"items"];
|
|
|
|
+ if (items.count) {
|
|
|
|
+ NSMutableArray *marr = [SDTimeLineCellModel mj_objectArrayWithKeyValuesArray:items];
|
|
|
|
+ [marr enumerateObjectsUsingBlock:^(SDTimeLineCellModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+
|
|
|
|
+ obj.likeItemsArray = [NSMutableArray new];
|
|
|
|
+ [obj.likeStr enumerateObjectsUsingBlock:^(id _Nonnull obj1, NSUInteger idx1, BOOL * _Nonnull stop) {
|
|
|
|
+ SDTimeLineCellLikeItemModel *model = [[SDTimeLineCellLikeItemModel alloc] init];
|
|
|
|
+ model.userName = obj1;
|
|
|
|
+ model.userId = @"1111";
|
|
|
|
+ [obj.likeItemsArray addObject:model];
|
|
}];
|
|
}];
|
|
- }
|
|
|
|
- }];
|
|
|
|
- }
|
|
|
|
- } failure:^(SPRequestError *error) {
|
|
|
|
-
|
|
|
|
|
|
+ }];
|
|
|
|
+ [self.dataArray addObjectsFromArray:marr];
|
|
|
|
+
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [self.tableView reloadData];
|
|
|
|
+ });
|
|
|
|
+ [self.dataArray enumerateObjectsUsingBlock:^(SDTimeLineCellModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ if ([obj.friendImgUrl componentsSeparatedByString:@","].count == 1) {
|
|
|
|
+
|
|
|
|
+ [weakSelf.KVOController observe:obj keyPath:@"imageSize" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSKeyValueChangeKey,id> * _Nonnull change) {
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:idx inSection:0], nil] withRowAnimation:UITableViewRowAnimationAutomatic];
|
|
|
|
+ });
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ listCount([items count]);
|
|
|
|
+ } failure:^(SPRequestError *error) {
|
|
|
|
+ listCount(-1);
|
|
|
|
+ }];
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -301,6 +251,9 @@ static CGFloat textFieldH = 56;
|
|
{
|
|
{
|
|
SDTimeLineCell *cell = [tableView dequeueReusableCellWithIdentifier:kTimeLineTableViewCellId];
|
|
SDTimeLineCell *cell = [tableView dequeueReusableCellWithIdentifier:kTimeLineTableViewCellId];
|
|
cell.indexPath = indexPath;
|
|
cell.indexPath = indexPath;
|
|
|
|
+ NSLog(@"----%ld",indexPath.row);
|
|
|
|
+ SDTimeLineCellModel *model = self.dataArray[indexPath.row];
|
|
|
|
+ cell.model = model;
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
if (!cell.moreButtonClickedBlock) {
|
|
if (!cell.moreButtonClickedBlock) {
|
|
[cell setMoreButtonClickedBlock:^(NSIndexPath *indexPath) {
|
|
[cell setMoreButtonClickedBlock:^(NSIndexPath *indexPath) {
|
|
@@ -309,13 +262,17 @@ static CGFloat textFieldH = 56;
|
|
[weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
|
[weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
|
}];
|
|
}];
|
|
|
|
|
|
- [cell setDidClickCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath) {
|
|
|
|
|
|
+ [cell setDidClickCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath1) {
|
|
|
|
+ NSLog(@"===----%ld",indexPath.row);
|
|
|
|
+ NSLog(@"===----%ld",indexPath1.row);
|
|
// weakSelf.textField.placeholder = [NSString stringWithFormat:@" 回复:%@", commentId];
|
|
// weakSelf.textField.placeholder = [NSString stringWithFormat:@" 回复:%@", commentId];
|
|
- weakSelf.currentEditingIndexthPath = indexPath;
|
|
|
|
|
|
+ weakSelf.currentEditingIndexthPath = [NSIndexPath indexPathForRow:indexPath1.row inSection:0];
|
|
|
|
+ SDTimeLineCellModel *model1 = weakSelf.dataArray[indexPath1.row];
|
|
[weakSelf.textField becomeFirstResponder];
|
|
[weakSelf.textField becomeFirstResponder];
|
|
weakSelf.isReplayingComment = YES;
|
|
weakSelf.isReplayingComment = YES;
|
|
|
|
+ weakSelf.currentCommentItemModel = [model1.list objectAtIndex:indexPath1.section];
|
|
weakSelf.commentToUser = commentId;
|
|
weakSelf.commentToUser = commentId;
|
|
- [weakSelf adjustTableViewToFitKeyboardWithRect:rectInWindow];
|
|
|
|
|
|
+ [weakSelf adjustTableViewToFitKeyboard];
|
|
}];
|
|
}];
|
|
|
|
|
|
cell.delegate = self;
|
|
cell.delegate = self;
|
|
@@ -327,7 +284,7 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
- cell.model = self.dataArray[indexPath.row];
|
|
|
|
|
|
+
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
|
|
|