Skip to content

Commit c113c1f

Browse files
committed
实现了评论cell
1 parent 15596e8 commit c113c1f

12 files changed

Lines changed: 141 additions & 69 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
13FB5D441CA17A6400EE127C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D231CA17A6400EE127C /* [email protected] */; };
6060
13FB5D451CA17A6400EE127C /* merge-request [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D241CA17A6400EE127C /* merge-request [email protected] */; };
6161
13FB5D461CA17A6400EE127C /* merge-request [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D251CA17A6400EE127C /* merge-request [email protected] */; };
62-
13FB5D471CA17A6400EE127C /* MergeChanges@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D261CA17A6400EE127C /* MergeChanges@2x.png */; };
63-
13FB5D481CA17A6400EE127C /* MergeChanges@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D271CA17A6400EE127C /* MergeChanges@3x.png */; };
62+
13FB5D471CA17A6400EE127C /* PR_mergeChanges@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D261CA17A6400EE127C /* PR_mergeChanges@2x.png */; };
63+
13FB5D481CA17A6400EE127C /* PR_mergeChanges@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D271CA17A6400EE127C /* PR_mergeChanges@3x.png */; };
6464
13FB5D491CA17A6400EE127C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D281CA17A6400EE127C /* [email protected] */; };
6565
13FB5D4A1CA17A6400EE127C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D291CA17A6400EE127C /* [email protected] */; };
6666
13FB5D4B1CA17A6400EE127C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 13FB5D2A1CA17A6400EE127C /* [email protected] */; };
@@ -1202,8 +1202,8 @@
12021202
13FB5D231CA17A6400EE127C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
12031203
13FB5D241CA17A6400EE127C /* merge-request [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "merge-request [email protected]"; sourceTree = "<group>"; };
12041204
13FB5D251CA17A6400EE127C /* merge-request [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "merge-request [email protected]"; sourceTree = "<group>"; };
1205-
13FB5D261CA17A6400EE127C /* MergeChanges@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MergeChanges@2x.png"; sourceTree = "<group>"; };
1206-
13FB5D271CA17A6400EE127C /* MergeChanges@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MergeChanges@3x.png"; sourceTree = "<group>"; };
1205+
13FB5D261CA17A6400EE127C /* PR_mergeChanges@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PR_mergeChanges@2x.png"; sourceTree = "<group>"; };
1206+
13FB5D271CA17A6400EE127C /* PR_mergeChanges@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PR_mergeChanges@3x.png"; sourceTree = "<group>"; };
12071207
13FB5D281CA17A6400EE127C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
12081208
13FB5D291CA17A6400EE127C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
12091209
13FB5D2A1CA17A6400EE127C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -2911,8 +2911,8 @@
29112911
13FB5D231CA17A6400EE127C /* [email protected] */,
29122912
13FB5D241CA17A6400EE127C /* merge-request [email protected] */,
29132913
13FB5D251CA17A6400EE127C /* merge-request [email protected] */,
2914-
13FB5D261CA17A6400EE127C /* MergeChanges@2x.png */,
2915-
13FB5D271CA17A6400EE127C /* MergeChanges@3x.png */,
2914+
13FB5D261CA17A6400EE127C /* PR_mergeChanges@2x.png */,
2915+
13FB5D271CA17A6400EE127C /* PR_mergeChanges@3x.png */,
29162916
13FB5D281CA17A6400EE127C /* [email protected] */,
29172917
13FB5D291CA17A6400EE127C /* [email protected] */,
29182918
13FB5D2A1CA17A6400EE127C /* [email protected] */,
@@ -5677,7 +5677,7 @@
56775677
4E2BF3CF1B96CDF800A5A0A8 /* [email protected] in Resources */,
56785678
8EA6D15019E240C40076D59C /* [email protected] in Resources */,
56795679
4EB52F5F1C7C5C4F00B5EBEA /* [email protected] in Resources */,
5680-
13FB5D481CA17A6400EE127C /* MergeChanges@3x.png in Resources */,
5680+
13FB5D481CA17A6400EE127C /* PR_mergeChanges@3x.png in Resources */,
56815681
134E1B9B1CA41217002A3E0D /* ReviewCell.xib in Resources */,
56825682
8EA6D15E19E240C40076D59C /* [email protected] in Resources */,
56835683
4EB52F101C74691B00B5EBEA /* [email protected] in Resources */,
@@ -6072,7 +6072,7 @@
60726072
8EA6D19819E240C40076D59C /* [email protected] in Resources */,
60736073
8E97CEA81A0C7E26006F9AD7 /* [email protected] in Resources */,
60746074
4E6383B91B32640900D98648 /* [email protected] in Resources */,
6075-
13FB5D471CA17A6400EE127C /* MergeChanges@2x.png in Resources */,
6075+
13FB5D471CA17A6400EE127C /* PR_mergeChanges@2x.png in Resources */,
60766076
8E97CEAB1A0C7E26006F9AD7 /* [email protected] in Resources */,
60776077
8EA6D1AA19E240C40076D59C /* Images.xcassets in Resources */,
60786078
4E63840F1B34124000D98648 /* [email protected] in Resources */,

Coding_iOS/Controllers/AddReviewerViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ typedef void(^AddReviewerViewControllerBlock)(Project *project);
77

88
@property (readwrite, nonatomic, strong) NSMutableArray *reviewers;
99
@property (readwrite, nonatomic, strong) NSMutableArray *volunteer_reviewers;
10+
@property (nonatomic, strong) Project *currentProject;
1011

1112
@end

Coding_iOS/Controllers/AddReviewerViewController.m

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#import "ProjectPublicListCell.h"
1212
#import "SVPullToRefresh.h"
1313
#import "Reviewer.h"
14+
#import "ProjectMember.h"
1415

1516
@interface AddReviewerViewController ()<UISearchBarDelegate>
1617
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
1718
@property (strong, nonatomic) UISearchBar *mySearchBar;
18-
@property (readwrite, nonatomic, strong) NSMutableArray *allrReviewers;
19+
@property (readwrite, nonatomic, strong) NSMutableArray *users;
20+
@property (readwrite, nonatomic, strong) NSMutableArray *allUsers;
1921
@end
2022

2123
@implementation AddReviewerViewController
@@ -25,7 +27,8 @@ @implementation AddReviewerViewController
2527

2628
-(void)viewDidLoad {
2729
self.title = @"评审人";
28-
self.allrReviewers = [[NSMutableArray alloc] init];
30+
self.users = [[NSMutableArray alloc] init];
31+
self.allUsers = [[NSMutableArray alloc] init];
2932
[self.myTableView registerNib:[UINib nibWithNibName:kCellIdentifier_ReviewCell bundle:nil] forCellReuseIdentifier:kCellIdentifier_ReviewCell];
3033
self.myTableView.separatorStyle = NO;
3134
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
@@ -43,13 +46,36 @@ -(void)viewDidLoad {
4346
}
4447

4548
- (void)viewWillAppear:(BOOL)animated {
46-
for(int i = 0; i < self.reviewers.count; i ++) {
47-
[self.allrReviewers addObject:self.reviewers[i]];
48-
}
49-
50-
for(int i = 0; i < self.volunteer_reviewers.count; i ++) {
51-
[self.allrReviewers addObject:self.volunteer_reviewers[i]];
52-
}
49+
__weak typeof(self) weakSelf = self;
50+
[[Coding_NetAPIManager sharedManager] request_ProjectMembers_WithObj:self.currentProject andBlock:^(id data, NSError *error) {
51+
[weakSelf.view endLoading];
52+
if (data) {
53+
NSMutableArray* projectUsers = data;
54+
BOOL flag = YES;
55+
for(int i = 0; i < projectUsers.count; i ++) {
56+
flag = YES;
57+
ProjectMember* member = projectUsers[i];
58+
for(int j = 0; j < self.reviewers.count; j ++) {
59+
Reviewer* reviewer = self.reviewers[j];
60+
if(member.user.id == reviewer.reviewer.id) {
61+
flag = NO;
62+
}
63+
}
64+
65+
for(int j = 0; j < self.volunteer_reviewers.count; j ++) {
66+
Reviewer* reviewer = self.volunteer_reviewers[j];
67+
if(member.user.id == reviewer.reviewer.id) {
68+
flag = NO;
69+
}
70+
}
71+
if(flag) {
72+
[weakSelf.allUsers addObject:member.user];
73+
}
74+
}
75+
weakSelf.users = weakSelf.allUsers;
76+
[weakSelf.myTableView reloadData];
77+
}
78+
}];
5379
}
5480

5581
- (id)initWithFrame:(CGRect)frame projects:(Projects *)projects block:(AddReviewerViewControllerBlock)block tabBarHeight:(CGFloat)tabBarHeight
@@ -76,14 +102,15 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
76102
}
77103

78104
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
79-
return [self.allrReviewers count];
105+
return [self.allUsers count];
80106
}
81107

82108
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
83109
ReviewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ReviewCell forIndexPath:indexPath];
84110

85111
// [cell configureCellWithHeadIconURL:@"test" reviewIconURL:@"PointLikeHead" userName:@"test" userState:@"test"];
86-
[cell initCellWithReviewer:self.allrReviewers[indexPath.row]];
112+
User* cellReviewer = self.allUsers[indexPath.row];
113+
[cell initCellWithUsers:cellReviewer];
87114
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:50];
88115
return cell;
89116

@@ -123,15 +150,6 @@ - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
123150
}
124151

125152
- (void)searchProjectWithStr:(NSString *)searchString{
126-
NSMutableArray* arry = [[NSMutableArray alloc] init];
127-
128-
for(int i = 0; i < self.reviewers.count; i ++) {
129-
[arry addObject:self.reviewers[i]];
130-
}
131-
132-
for(int i = 0; i < self.volunteer_reviewers.count; i ++) {
133-
[arry addObject:self.volunteer_reviewers[i]];
134-
}
135153
// strip out all the leading and trailing spaces
136154
NSString *strippedStr = [searchString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
137155

@@ -168,7 +186,7 @@ - (void)searchProjectWithStr:(NSString *)searchString{
168186

169187
NSCompoundPredicate *finalCompoundPredicate = (NSCompoundPredicate *)[NSCompoundPredicate andPredicateWithSubpredicates:andMatchPredicates];
170188

171-
self.allrReviewers = [[arry filteredArrayUsingPredicate:finalCompoundPredicate] mutableCopy];
189+
self.allUsers = [[self.users filteredArrayUsingPredicate:finalCompoundPredicate] mutableCopy];
172190
[self.myTableView reloadData];
173191
}
174192

Coding_iOS/Controllers/PRDetailViewController.m

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ @interface PRDetailViewController ()<UITableViewDataSource, UITableViewDelegate,
5252
@property (strong, nonatomic) ResourceReference *resourceReference;
5353
@property (strong, nonatomic) NSMutableArray *activityList;
5454
@property (strong, nonatomic) NSMutableArray *activityCList;
55+
@property (strong, nonatomic) NSMutableArray *allDiscussions;
5556
@end
5657

5758
@implementation PRDetailViewController
@@ -74,6 +75,7 @@ - (void)viewDidLoad{
7475
[super viewDidLoad];
7576
self.activityList = [[NSMutableArray alloc] init];
7677
self.activityCList = [[NSMutableArray alloc] init];
78+
self.allDiscussions = [[NSMutableArray alloc] init];
7779
self.title = [NSString stringWithFormat:@"%@ #%@", _curMRPR.des_project_name, _curMRPR.iid.stringValue];
7880
self.referencePath = [NSString stringWithFormat:@"/api/user/%@/project/%@/resource_reference/%@", _curMRPR.des_owner_name, _curMRPR.des_project_name,self.curMRPR.iid];
7981
self.activityPath = [NSString stringWithFormat:@"/api/user/%@/project/%@/git/merge/%@/activities", _curMRPR.des_owner_name, _curMRPR.des_project_name,self.curMRPR.iid];
@@ -160,8 +162,8 @@ - (void)configBottomView{
160162

161163
-(void)sortActivityList {
162164
NSMutableArray *dataArray = [[NSMutableArray alloc] initWithArray:self.activityList];
163-
for(int i = 0; i < self.activityCList.count; i ++) {
164-
[dataArray addObject:self.activityCList[i]];
165+
for(int i = 0; i < self.allDiscussions.count; i ++) {
166+
[dataArray addObject:self.allDiscussions[i]];
165167
}
166168
//NSArray *sortedArray = [[NSArray alloc] initWithArray:dataArray];
167169
self.activityList = [dataArray sortedArrayUsingComparator:^NSComparisonResult(ProjectLineNote *obj1, ProjectLineNote *obj2) {
@@ -192,26 +194,31 @@ - (void)refresh{
192194
NSMutableArray *resultA = weakSelf.curMRPRInfo.discussions;
193195
if(resultA != nil){
194196
BOOL flag = false;
195-
if(weakSelf.activityCList == nil || weakSelf.activityCList.count <= 0) {
197+
if(weakSelf.allDiscussions == nil || weakSelf.allDiscussions.count <= 0) {
196198
for (int i = 0; i<resultA.count; i ++) {
197199
NSArray *pArray = resultA[i];
198200
ProjectLineNote* addTmp = pArray[0];
199-
200-
[weakSelf.activityCList addObject:addTmp];
201+
if (addTmp.path != nil) {
202+
addTmp.action = @"mergeChanges";
203+
}
204+
[weakSelf.allDiscussions addObject:addTmp];
201205
}
202206

203207
} else {
204208
for (int i = 0; i< resultA.count; i++) {
205209
NSArray *pArray = resultA[i];
206210
ProjectLineNote* addTmp = [pArray firstObject];
211+
if (addTmp.path != nil) {
212+
addTmp.action = @"mergeChanges";
213+
}
207214
flag = false;
208-
for(int j = 0; j < weakSelf.activityCList.count; j ++) {
209-
ProjectLineNote* addTmp1 = weakSelf.activityCList[j];
215+
for(int j = 0; j < weakSelf.allDiscussions.count; j ++) {
216+
ProjectLineNote* addTmp1 = weakSelf.allDiscussions[j];
210217
if(addTmp.id == addTmp1.id) {
211218
flag = true;
212219
}
213220
}
214-
[weakSelf.activityCList addObject:addTmp];
221+
[weakSelf.allDiscussions addObject:addTmp];
215222
}
216223
}
217224
}
@@ -246,9 +253,6 @@ - (void)refresh{
246253
weakSelf.resourceReference = [NSObject objectOfClass:@"ResourceReference" fromJSON:data[@"data"]];
247254
[weakSelf.myTableView reloadData];
248255
}
249-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(_curMRPRInfo != nil) hasError:(error != nil) reloadButtonBlock:^(id sender) {
250-
[weakSelf refresh];
251-
}];
252256
}];
253257

254258

@@ -261,7 +265,6 @@ - (void)refresh{
261265
if(weakSelf.activityList == nil || weakSelf.activityList.count <= 0) {
262266
for (int i = 0; i<resultA.count; i ++) {
263267
ProjectLineNote* addTmp = resultA[i];
264-
265268
[weakSelf.activityList addObject:addTmp];
266269
}
267270
} else {
@@ -281,9 +284,6 @@ - (void)refresh{
281284
[weakSelf.myTableView reloadData];
282285
}
283286
}
284-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(_curMRPRInfo != nil) hasError:(error != nil) reloadButtonBlock:^(id sender) {
285-
[weakSelf refresh];
286-
}];
287287
}];
288288

289289
//推送过来的页面,可能 curProject 对象为空
@@ -493,18 +493,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
493493
}
494494
}else if (self.activityList.count > 0 && indexPath.section == 3){//Comment
495495
ProjectLineNote *curCommentItem = self.activityList[indexPath.row];
496-
if(curCommentItem.noteable_type != nil) {
496+
if(curCommentItem.action == nil) {
497497
DynamicCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:curCommentItem.htmlMedia.imageItems.count> 0? kCellIdentifier_DynamicCommentCell_Media: kCellIdentifier_DynamicCommentCell forIndexPath:indexPath];
498498
cell.curComment = curCommentItem;
499499
cell.contentLabel.delegate = self;
500-
[cell configTop:(indexPath.row == 0) andBottom:(indexPath.row == _curMRPRInfo.discussions.count - 1)];
500+
[cell configTop:(indexPath.row == 0) andBottom:(indexPath.row == self.activityList.count +self.curMRPRInfo.discussions.count - 1)];
501501
cell.backgroundColor = kColorTableBG;
502502
return cell;
503503
} else {
504504

505505
DynamicActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_DynamicActivityCell forIndexPath:indexPath];
506506
cell.curActivity = curCommentItem;
507-
[cell configTop:(indexPath.row == 0) andBottom:(indexPath.row == self.activityList.count - 1)];
507+
[cell configTop:(indexPath.row == 0) andBottom:(indexPath.row == self.activityList.count +self.curMRPRInfo.discussions.count - 1)];
508508
cell.backgroundColor = kColorTableBG;
509509
return cell;
510510
}
@@ -559,10 +559,10 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
559559
}else if (self.activityList.count > 0 && indexPath.section == 3){//Comment
560560
NSLog(@"test %lu", indexPath.row);
561561
ProjectLineNote *curCommentItem = self.activityList[indexPath.row];
562-
if(curCommentItem.noteable_type != nil) {
562+
if(curCommentItem.action == nil) {
563563
return [DynamicCommentCell cellHeightWithObj:curCommentItem];
564564
} else {
565-
return [DynamicActivityCell cellHeightWithObj:curCommentItem];
565+
return [DynamicActivityCell cellHeightWithObj:curCommentItem contentHeight:0];
566566
}
567567
}else{//Add Comment
568568
return [AddCommentCell cellHeight];
@@ -602,6 +602,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
602602
if(![self CurrentUserIsOwer]) return;
603603
NSArray *apparray= [[NSBundle mainBundle]loadNibNamed:@"ReviewerListController" owner:nil options:nil];
604604
ReviewerListController *appview=[apparray firstObject];
605+
appview.currentProject = self.curProject;
605606
appview.reviewers = self.curReviewersInfo.reviewers;
606607
appview.volunteer_reviewers = self.curReviewersInfo.volunteer_reviewers;
607608

Coding_iOS/Controllers/ReviewCell.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
#import <UIKit/UIKit.h>
11-
#import "Reviewer.h"
11+
#import "User.h"
1212

1313
#define kCellIdentifier_ReviewCell @"ReviewCell"
1414

@@ -24,8 +24,11 @@
2424
userName:(NSString *)userName
2525
userState:(NSString *)userState;
2626

27-
- (void)initCellWithReviewer:(Reviewer*)reviewer;
28-
- (void)initCellWithVolunteerReviewers:(Reviewer*)reviewer;
27+
- (void)initCellWithReviewer:(User*)reviewer
28+
likeValue:(NSNumber*)likeValue;
29+
- (void)initCellWithVolunteerReviewers:(User*)reviewer
30+
likeValue:(NSNumber*)likeValue;
31+
- (void)initCellWithUsers:(User*)user;
2932

3033
+ (CGFloat)cellHeight;
3134
@end

0 commit comments

Comments
 (0)