14
14
#import " ODRefreshControl.h"
15
15
#import " FileCommentCell.h"
16
16
#import " FileActivityCell.h"
17
+ #import " AddCommentCell.h"
17
18
18
19
#import " UIView+PressMenu.h"
19
20
@@ -25,7 +26,7 @@ @interface FileActivitiesViewController ()<UITableViewDataSource, UITableViewDel
25
26
@property (strong , nonatomic ) NSMutableArray *activityList;
26
27
27
28
@property (strong , nonatomic ) UITableView *myTableView;
28
- @property (nonatomic , strong ) EaseToolBar *myToolBar;
29
+ // @property (nonatomic, strong) EaseToolBar *myToolBar;
29
30
@property (nonatomic , strong ) ODRefreshControl *myRefreshControl;
30
31
31
32
@property (assign , nonatomic ) BOOL isLoading;
@@ -52,6 +53,7 @@ - (void)viewDidLoad
52
53
[tableView registerClass: [FileCommentCell class ] forCellReuseIdentifier: kCellIdentifier_FileCommentCell ];
53
54
[tableView registerClass: [FileCommentCell class ] forCellReuseIdentifier: kCellIdentifier_FileCommentCell_Media ];
54
55
[tableView registerClass: [FileActivityCell class ] forCellReuseIdentifier: kCellIdentifier_FileActivityCell ];
56
+ [tableView registerClass: [AddCommentCell class ] forCellReuseIdentifier: kCellIdentifier_AddCommentCell ];
55
57
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
56
58
[self .view addSubview: tableView];
57
59
[tableView mas_makeConstraints: ^(MASConstraintMaker *make) {
@@ -63,27 +65,25 @@ - (void)viewDidLoad
63
65
_myRefreshControl = [[ODRefreshControl alloc ] initInScrollView: self .myTableView];
64
66
[_myRefreshControl addTarget: self action: @selector (refresh ) forControlEvents: UIControlEventValueChanged];
65
67
66
- _myToolBar = ({
67
- EaseToolBarItem *item = [EaseToolBarItem easeToolBarItemWithTitle: @" 发表评论..." image: @" button_file_comment" disableImage: nil ];
68
-
69
- NSDictionary *attributes = @{NSFontAttributeName : [UIFont systemFontOfSize: 15 ],
70
- NSForegroundColorAttributeName : [UIColor colorWithHexString: @" 0xB5B5B5" ]};
71
- [item setAttributes: attributes forUIControlState: UIControlStateNormal];
72
-
73
- EaseToolBar *toolBar = [EaseToolBar easeToolBarWithItems: @[item]];
74
- toolBar.delegate = self;
75
- [self .view addSubview: toolBar];
76
- [toolBar mas_makeConstraints: ^(MASConstraintMaker *make) {
77
- make.bottom .equalTo (self.view .mas_bottom );
78
- make.size .mas_equalTo (toolBar.frame .size );
79
- }];
80
- toolBar;
81
- });
82
-
83
-
84
- UIEdgeInsets contentInsets = UIEdgeInsetsMake (0.0 , 0.0 ,CGRectGetHeight (self.myToolBar .frame ), 0.0 );
85
- self.myTableView .contentInset = contentInsets;
86
- self.myTableView .scrollIndicatorInsets = contentInsets;
68
+ // _myToolBar = ({
69
+ // EaseToolBarItem *item = [EaseToolBarItem easeToolBarItemWithTitle:@" 发表评论..." image:@"button_file_comment" disableImage:nil];
70
+ //
71
+ // NSDictionary *attributes = @{NSFontAttributeName : [UIFont systemFontOfSize:15],
72
+ // NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0xB5B5B5"]};
73
+ // [item setAttributes:attributes forUIControlState:UIControlStateNormal];
74
+ //
75
+ // EaseToolBar *toolBar = [EaseToolBar easeToolBarWithItems:@[item]];
76
+ // toolBar.delegate = self;
77
+ // [self.view addSubview:toolBar];
78
+ // [toolBar mas_makeConstraints:^(MASConstraintMaker *make) {
79
+ // make.bottom.equalTo(self.view.mas_bottom);
80
+ // make.size.mas_equalTo(toolBar.frame.size);
81
+ // }];
82
+ // toolBar;
83
+ // });
84
+ // UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0,CGRectGetHeight(self.myToolBar.frame), 0.0);
85
+ // self.myTableView.contentInset = contentInsets;
86
+ // self.myTableView.scrollIndicatorInsets = contentInsets;
87
87
88
88
[self refresh ];
89
89
}
@@ -117,77 +117,104 @@ - (void)sendRequest{
117
117
}
118
118
119
119
#pragma mark Table M
120
+
121
+ - (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
122
+ return 2 ;
123
+ }
124
+
125
+ - (CGFloat )tableView : (UITableView *)tableView heightForFooterInSection : (NSInteger )section {
126
+ return 20.0 ;
127
+ }
128
+
129
+ - (UIView *)tableView : (UITableView *)tableView viewForFooterInSection : (NSInteger )section {
130
+ UIView *view = [UIView new ];
131
+ view.backgroundColor = kColorTableSectionBg ;
132
+ return view;
133
+ }
134
+
120
135
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
121
- return _activityList.count ;
136
+ return section == 0 ? _activityList.count : 1 ;
122
137
}
123
138
124
139
- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
125
- ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
126
- if ([curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
127
- FileComment *curComment = curActivity.projectFileComment ;
128
- curComment.created_at = curActivity.created_at ;
129
- FileCommentCell *cell;
130
- if (curComment.htmlMedia .imageItems .count > 0 ) {
131
- cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileCommentCell_Media forIndexPath: indexPath];
140
+ if (indexPath.section == 0 ) {
141
+ ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
142
+ if ([curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
143
+ FileComment *curComment = curActivity.projectFileComment ;
144
+ curComment.created_at = curActivity.created_at ;
145
+ FileCommentCell *cell;
146
+ if (curComment.htmlMedia .imageItems .count > 0 ) {
147
+ cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileCommentCell_Media forIndexPath: indexPath];
148
+ }else {
149
+ cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileCommentCell forIndexPath: indexPath];
150
+ }
151
+ cell.curComment = (TaskComment *)curComment;
152
+ cell.contentLabel .delegate = self;
153
+ cell.backgroundColor = kColorTableBG ;
154
+ [cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _activityList.count - 1 )];
155
+ return cell;
132
156
}else {
133
- cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileCommentCell forIndexPath: indexPath];
157
+ FileActivityCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileActivityCell forIndexPath: indexPath];
158
+ cell.curActivity = curActivity;
159
+ cell.backgroundColor = kColorTableBG ;
160
+ [cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _activityList.count - 1 )];
161
+ return cell;
134
162
}
135
- cell.curComment = (TaskComment *)curComment;
136
- cell.contentLabel .delegate = self;
137
- cell.backgroundColor = kColorTableBG ;
138
- [cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _activityList.count - 1 )];
139
- return cell;
140
163
}else {
141
- FileActivityCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_FileActivityCell forIndexPath: indexPath];
142
- cell.curActivity = curActivity;
143
- cell.backgroundColor = kColorTableBG ;
144
- [cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _activityList.count - 1 )];
164
+ AddCommentCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_AddCommentCell forIndexPath: indexPath];
165
+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 50 ];
145
166
return cell;
146
167
}
147
168
}
148
169
149
170
- (CGFloat )tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
150
171
CGFloat cellHeight = 0 ;
151
- ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
152
- if ([curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
153
- cellHeight = [FileCommentCell cellHeightWithObj: curActivity.projectFileComment];
172
+ if (indexPath.section == 0 ) {
173
+ ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
174
+ if ([curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
175
+ cellHeight = [FileCommentCell cellHeightWithObj: curActivity.projectFileComment];
176
+ }else {
177
+ cellHeight = [FileActivityCell cellHeightWithObj: curActivity];
178
+ }
154
179
}else {
155
- cellHeight = [FileActivityCell cellHeightWithObj: curActivity ];
180
+ cellHeight = [AddCommentCell cellHeight ];
156
181
}
157
182
return cellHeight;
158
183
}
159
184
160
185
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
161
186
[tableView deselectRowAtIndexPath: indexPath animated: YES ];
162
-
163
- ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
164
- if (![curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
165
- return ;
166
- }
167
- UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
168
- if ([cell.contentView isMenuVCVisible ]) {
169
- [cell.contentView removePressMenu ];
170
- return ;
171
- }
172
- NSArray *menuTitles;
173
- if ([curActivity.projectFileComment.owner.global_key isEqualToString: [Login curLoginUser ].global_key]) {
174
- menuTitles = @[@" 拷贝文字" , @" 删除" ];
187
+ if (indexPath.section == 0 ) {
188
+ ProjectActivity *curActivity = [self .activityList objectAtIndex: indexPath.row];
189
+ if (![curActivity.target_type isEqualToString: @" ProjectFileComment" ]) {
190
+ return ;
191
+ }
192
+ UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
193
+ if ([cell.contentView isMenuVCVisible ]) {
194
+ [cell.contentView removePressMenu ];
195
+ return ;
196
+ }
197
+ NSArray *menuTitles;
198
+ if ([curActivity.projectFileComment.owner.global_key isEqualToString: [Login curLoginUser ].global_key]) {
199
+ menuTitles = @[@" 拷贝文字" , @" 删除" ];
200
+ }else {
201
+ menuTitles = @[@" 拷贝文字" , @" 回复" ];
202
+ }
203
+ __weak typeof (self) weakSelf = self;
204
+ [cell.contentView showMenuTitles: menuTitles menuClickedBlock: ^(NSInteger index , NSString *title) {
205
+ if ([title hasPrefix: @" 拷贝" ]) {
206
+ [[UIPasteboard generalPasteboard ] setString: curActivity.projectFileComment.content];
207
+ }else if ([title isEqualToString: @" 删除" ]){
208
+ [weakSelf deleteCommentOfActivity: curActivity];
209
+ }else if ([title isEqualToString: @" 回复" ]){
210
+ [weakSelf goToAddCommentVCToActivity: curActivity];
211
+ }
212
+ }];
175
213
}else {
176
- menuTitles = @[ @" 拷贝文字 " , @" 回复 " ];
214
+ [ self goToAddCommentVCToActivity: nil ];
177
215
}
178
- __weak typeof (self) weakSelf = self;
179
- [cell.contentView showMenuTitles: menuTitles menuClickedBlock: ^(NSInteger index , NSString *title) {
180
- if ([title hasPrefix: @" 拷贝" ]) {
181
- [[UIPasteboard generalPasteboard ] setString: curActivity.projectFileComment.content];
182
- }else if ([title isEqualToString: @" 删除" ]){
183
- [weakSelf deleteCommentOfActivity: curActivity];
184
- }else if ([title isEqualToString: @" 回复" ]){
185
- [weakSelf goToAddCommentVCToActivity: curActivity];
186
- }
187
- }];
188
216
}
189
217
190
-
191
218
#pragma mark Comment
192
219
- (void )goToAddCommentVCToActivity : (ProjectActivity *)curActivity {
193
220
Project *curProject;
0 commit comments