|
@@ -38,7 +38,10 @@
|
|
|
#import "UIView+SDAutoLayout.h"
|
|
|
#import "LEETheme.h"
|
|
|
#import "GlobalDefines.h"
|
|
|
+
|
|
|
#import "SLMoentsChatView.h"
|
|
|
+#import "SLMomentsCommentVc.h"
|
|
|
+#import "SLMomentDetailTableVc.h"
|
|
|
|
|
|
#define kTimeLineTableViewCellId @"SDTimeLineCell"
|
|
|
|
|
@@ -67,7 +70,6 @@ static CGFloat textFieldH = 56;
|
|
|
- (void)viewDidLoad
|
|
|
{
|
|
|
[super viewDidLoad];
|
|
|
-
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
} else {
|
|
@@ -89,6 +91,9 @@ static CGFloat textFieldH = 56;
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(momentsUpdate:) name:@"SLMomentsUpdate" object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(momentsCommentUpdate:) name:@"SLMomentsCommentUpdate" object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(momentsDetail:) name:@"SLMomentsDetail" object:nil];
|
|
|
+
|
|
|
[self creatModelsWithCount:0];
|
|
|
|
|
|
}
|
|
@@ -116,8 +121,92 @@ static CGFloat textFieldH = 56;
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
}
|
|
|
|
|
|
-- (void)momentsUpdate:(NSNotificationCenter *)conter {
|
|
|
- [self creatModelsWithCount:0];
|
|
|
+- (void)momentsDetail:(NSNotification *)notification {
|
|
|
+ NSDictionary *dict = notification.userInfo;
|
|
|
+ SDTimeLineCellModel *model = [SDTimeLineCellModel mj_objectWithKeyValues:dict];
|
|
|
+ __block NSInteger i = 0;
|
|
|
+ __block SDTimeLineCellModel *cModel;
|
|
|
+ [self.dataArray enumerateObjectsUsingBlock:^(SDTimeLineCellModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ if ([obj.friendId isEqualToString:model.friendId]) {
|
|
|
+ i = idx;
|
|
|
+ cModel = obj;
|
|
|
+ *stop = YES;
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ SLMomentDetailTableVc *vc = [[SLMomentDetailTableVc alloc] init];
|
|
|
+ vc.dataArray = [NSMutableArray arrayWithObject:cModel];
|
|
|
+ [vc.tableView reloadData];
|
|
|
+ [self.rdv_tabBarController.navigationController pushViewController:vc animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)momentsUpdate:(NSNotification *)notification {
|
|
|
+ NSDictionary *dict = notification.userInfo;
|
|
|
+ SDTimeLineCellModel *model = [SDTimeLineCellModel mj_objectWithKeyValues:dict];
|
|
|
+ __block NSInteger i = 0;
|
|
|
+ __block SDTimeLineCellModel *cModel;
|
|
|
+ [self.dataArray enumerateObjectsUsingBlock:^(SDTimeLineCellModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ if ([obj.friendId isEqualToString:model.friendId]) {
|
|
|
+ i = idx;
|
|
|
+ cModel = obj;
|
|
|
+ *stop = YES;
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ [self updateCellLike:cModel index:[NSIndexPath indexPathForRow:i inSection:0]];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)momentsCommentUpdate:(NSNotification *)notification {
|
|
|
+ NSDictionary *dict = notification.userInfo;
|
|
|
+ SDTimeLineCellModel *model = [SDTimeLineCellModel mj_objectWithKeyValues:dict];
|
|
|
+ __block NSInteger i = 0;
|
|
|
+ __block SDTimeLineCellModel *cModel;
|
|
|
+ [self.dataArray enumerateObjectsUsingBlock:^(SDTimeLineCellModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ if ([obj.friendId isEqualToString:model.friendId]) {
|
|
|
+ i = idx;
|
|
|
+ cModel = obj;
|
|
|
+ *stop = YES;
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ SLMomentsCommentVc *vc = [SLMomentsCommentVc loadViewControllewWithNib];
|
|
|
+ WS(weakSelf);
|
|
|
+ vc.momentsCommentBlock = ^(NSString * _Nonnull text) {
|
|
|
+ [self updateCommentWithModel:cModel index:[NSIndexPath indexPathForRow:i inSection:0] text:text];
|
|
|
+ };
|
|
|
+ [self.rdv_tabBarController.navigationController pushViewController:vc animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateCommentWithModel:(SDTimeLineCellModel *)model index:(NSIndexPath *)index text:(NSString *)text {
|
|
|
+ NSMutableArray *temp = [NSMutableArray new];
|
|
|
+ [temp addObjectsFromArray:model.list];
|
|
|
+ NSDictionary *parameter = @{@"commendId" : @"",
|
|
|
+ @"friendId" : model.friendId,
|
|
|
+ @"replyUserId" : @"",
|
|
|
+ @"content" : text ?: @"",
|
|
|
+ @"level" : @"0",
|
|
|
+ };
|
|
|
+ if (self.isReplayingComment) {
|
|
|
+ parameter = @{@"commendId" : self.currentCommentItemModel.commendId ?: @"",
|
|
|
+ @"friendId" : self.currentCommentItemModel.friendId ?: @"",
|
|
|
+ @"replyUserId" : self.currentCommentItemModel.userId ?: @"",
|
|
|
+ @"content" : text ?: @"",
|
|
|
+ @"level" : @"0",
|
|
|
+ };
|
|
|
+ self.isReplayingComment = NO;
|
|
|
+ }
|
|
|
+ [[SLHttpCenter SharedInstance] postWithUrl:@"/api/Friend/InsertComment" parameter:parameter success:^(id responseObject) {
|
|
|
+ SDTimeLineCellCommentItemModel *commentItemModel = [SDTimeLineCellCommentItemModel new];
|
|
|
+ SLLoginInfo *targetModel = [SLGlobalInfo SharedInstance].loginInfo;
|
|
|
+ commentItemModel.userName = targetModel.user.name;
|
|
|
+ commentItemModel.userId = targetModel.user.userId;
|
|
|
+ commentItemModel.replyUserName = self.currentCommentItemModel.userName;
|
|
|
+ commentItemModel.content = text;
|
|
|
+ commentItemModel.friendId = model.friendId;
|
|
|
+ commentItemModel.level = [parameter objectForKey:@"level"];
|
|
|
+ [temp addObject:commentItemModel];
|
|
|
+ model.list = [temp copy];
|
|
|
+ [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
|
|
|
+ } failure:^(SPRequestError *error) {
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
- (void)setupTextField
|
|
@@ -135,39 +224,7 @@ static CGFloat textFieldH = 56;
|
|
|
[weakSelf.textField resignFirstResponder];
|
|
|
[weakSelf.view endEditing:YES];
|
|
|
SDTimeLineCellModel *model = weakSelf.dataArray[weakSelf.currentEditingIndexthPath.row];
|
|
|
- NSMutableArray *temp = [NSMutableArray new];
|
|
|
- [temp addObjectsFromArray:model.list];
|
|
|
- NSDictionary *parameter = @{@"commendId" : @"",
|
|
|
- @"friendId" : model.friendId,
|
|
|
- @"replyUserId" : @"",
|
|
|
- @"content" : text ?: @"",
|
|
|
- @"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) {
|
|
|
- SDTimeLineCellCommentItemModel *commentItemModel = [SDTimeLineCellCommentItemModel new];
|
|
|
- SLLoginInfo *targetModel = [SLGlobalInfo SharedInstance].loginInfo;
|
|
|
- commentItemModel.userName = targetModel.user.name;
|
|
|
- commentItemModel.userId = targetModel.user.userId;
|
|
|
- commentItemModel.replyUserName = weakSelf.currentCommentItemModel.userName;
|
|
|
- commentItemModel.content = text;
|
|
|
- commentItemModel.friendId = model.friendId;
|
|
|
- commentItemModel.level = [parameter objectForKey:@"level"];
|
|
|
- [temp addObject:commentItemModel];
|
|
|
- model.list = [temp copy];
|
|
|
- [weakSelf.tableView reloadRowsAtIndexPaths:@[weakSelf.currentEditingIndexthPath] withRowAnimation:UITableViewRowAnimationNone];
|
|
|
-
|
|
|
- } failure:^(SPRequestError *error) {
|
|
|
-
|
|
|
- }];
|
|
|
+ [weakSelf updateCommentWithModel:model index:weakSelf.currentEditingIndexthPath text:text];
|
|
|
weakSelf.textField.text = @"";
|
|
|
};
|
|
|
}
|
|
@@ -242,9 +299,6 @@ static CGFloat textFieldH = 56;
|
|
|
}];
|
|
|
|
|
|
[cell setDidClickCommentLabelBlock:^(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath1) {
|
|
|
- NSLog(@"===----%ld",indexPath.row);
|
|
|
- NSLog(@"===----%ld",indexPath1.row);
|
|
|
-// weakSelf.textField.placeholder = [NSString stringWithFormat:@" 回复:%@", commentId];
|
|
|
weakSelf.currentEditingIndexthPath = [NSIndexPath indexPathForRow:indexPath1.row inSection:0];
|
|
|
SDTimeLineCellModel *model1 = weakSelf.dataArray[indexPath1.row];
|
|
|
[weakSelf.textField becomeFirstResponder];
|
|
@@ -285,11 +339,8 @@ static CGFloat textFieldH = 56;
|
|
|
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
|
|
{
|
|
|
[_textField resignFirstResponder];
|
|
|
-// _textField.placeholder = nil;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- (CGFloat)cellContentViewWith
|
|
|
{
|
|
|
CGFloat width = [UIScreen mainScreen].bounds.size.width;
|
|
@@ -317,8 +368,11 @@ static CGFloat textFieldH = 56;
|
|
|
{
|
|
|
NSIndexPath *index = [self.tableView indexPathForCell:cell];
|
|
|
SDTimeLineCellModel *model = self.dataArray[index.row];
|
|
|
+ [self updateCellLike:model index:index];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateCellLike:(SDTimeLineCellModel *)model index:(NSIndexPath *)index {
|
|
|
NSMutableArray *temp = [NSMutableArray arrayWithArray:model.likeItemsArray];
|
|
|
-
|
|
|
[[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/LikeHe" parameter:@{@"friendId":model.friendId} success:^(id responseObject) {
|
|
|
|
|
|
} failure:^(SPRequestError *error) {
|