Skip to content

Commit 059795f

Browse files
committed
进行代码的整理
1 parent 843d75b commit 059795f

3 files changed

Lines changed: 9 additions & 68 deletions

File tree

Coding_iOS/Controllers/AddReviewerViewController.m

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,12 @@ -(void)viewDidLoad {
3939
self.allUsers = [[NSMutableArray alloc] init];
4040
[self.myTableView registerNib:[UINib nibWithNibName:kCellIdentifier_ReviewCell bundle:nil] forCellReuseIdentifier:kCellIdentifier_ReviewCell];
4141
self.myTableView.separatorStyle = NO;
42-
43-
4442
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
4543
make.edges.equalTo(self.view);
4644
}];
4745
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0);
4846
self.myTableView.contentInset = insets;
4947
self.myTableView.scrollIndicatorInsets = insets;
50-
51-
5248
_mySearchBar = ({
5349
UISearchBar *searchBar = [[UISearchBar alloc] init];
5450
searchBar.delegate = self;
@@ -120,15 +116,6 @@ -(void)updateUnReviewers {
120116
self.allUsers = totalUser;
121117
}
122118

123-
- (id)initWithFrame:(CGRect)frame projects:(Projects *)projects block:(AddReviewerViewControllerBlock)block tabBarHeight:(CGFloat)tabBarHeight
124-
{
125-
//self = [super initWithFrame:frame];
126-
if (self) {
127-
// Initialization code
128-
129-
}
130-
return self;
131-
}
132119
#pragma mark Table M
133120

134121
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
@@ -149,14 +136,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
149136

150137
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
151138
ReviewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ReviewCell forIndexPath:indexPath];
152-
153-
// [cell configureCellWithHeadIconURL:@"test" reviewIconURL:@"PointLikeHead" userName:@"test" userState:@"test"];
154139
User* cellReviewer = self.allUsers[indexPath.row];
155140
cell.accessoryType = UITableViewCellAccessoryNone;
156141
[cell initCellWithUsers:cellReviewer];
157142
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
158143
return cell;
159-
160144
}
161145

162146
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -195,32 +179,20 @@ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
195179
[self searchProjectWithStr:searchText];
196180
}
197181

198-
199182
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
200183
[searchBar resignFirstResponder];
201184
[self searchProjectWithStr:searchBar.text];
202185
}
203186

204187
- (void)searchProjectWithStr:(NSString *)searchString{
205-
// strip out all the leading and trailing spaces
206188
NSString *strippedStr = [searchString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
207-
208-
// break up the search terms (separated by spaces)
209189
NSArray *searchItems = nil;
210-
if (strippedStr.length > 0)
211-
{
190+
if (strippedStr.length > 0) {
212191
searchItems = [strippedStr componentsSeparatedByString:@" "];
213192
}
214-
215-
// build all the "AND" expressions for each value in the searchString
216193
NSMutableArray *andMatchPredicates = [NSMutableArray array];
217-
218-
for (NSString *searchString in searchItems)
219-
{
220-
// each searchString creates an OR predicate for: name, global_key
194+
for (NSString *searchString in searchItems) {
221195
NSMutableArray *searchItemsPredicate = [NSMutableArray array];
222-
223-
// name field matching
224196
NSExpression *lhs = [NSExpression expressionForKeyPath:@"name"];
225197
NSExpression *rhs = [NSExpression expressionForConstantValue:searchString];
226198
NSPredicate *finalPredicate = [NSComparisonPredicate
@@ -230,14 +202,10 @@ - (void)searchProjectWithStr:(NSString *)searchString{
230202
type:NSContainsPredicateOperatorType
231203
options:NSCaseInsensitivePredicateOption];
232204
[searchItemsPredicate addObject:finalPredicate];
233-
234-
// at this OR predicate to ourr master AND predicate
235205
NSCompoundPredicate *orMatchPredicates = (NSCompoundPredicate *)[NSCompoundPredicate orPredicateWithSubpredicates:searchItemsPredicate];
236206
[andMatchPredicates addObject:orMatchPredicates];
237207
}
238-
239208
NSCompoundPredicate *finalCompoundPredicate = (NSCompoundPredicate *)[NSCompoundPredicate andPredicateWithSubpredicates:andMatchPredicates];
240-
241209
self.allUsers = [[self.users filteredArrayUsingPredicate:finalCompoundPredicate] mutableCopy];
242210
[self.myTableView reloadData];
243211
}

Coding_iOS/Controllers/MRDetailViewController.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@ - (void)configBottomView{
140140
make.left.right.bottom.equalTo(self.view);
141141
make.height.mas_equalTo(kMRPRDetailViewController_BottomViewHeight);
142142
}];
143-
144143
NSArray *buttonArray;
145144
if (canAction && canCancel) {//三个按钮
146145
buttonArray = @[ [self buttonWithType:MRPRActionCancel],
147146
[self buttonWithType:MRPRActionRefuse],
148147
[self buttonWithType:MRPRActionAccept]];
149-
}else if (canAction && !canCancel){//两个按钮
148+
} else if (canAction && !canCancel){//两个按钮
150149
if(canAuthorization) {
151150
buttonArray = @[[self buttonWithType:MRPRActionRefuse],
152151
[self buttonWithType:MRPRActionAuthorization],
@@ -162,9 +161,9 @@ - (void)configBottomView{
162161
[self buttonWithType:MRPRActionAccept]];
163162
}
164163

165-
}else if (!canAction && canCancel){//一个按钮
164+
} else if (!canAction && canCancel){//一个按钮
166165
buttonArray = @[[self buttonWithType:MRPRActionCancel]];
167-
}else{//无按钮
166+
} else{//无按钮
168167
buttonArray = nil;
169168
}
170169
if (buttonArray.count > 0) {
@@ -329,10 +328,10 @@ - (UIButton *)buttonWithType:(MRPRAction)actionType{
329328
if (_curMRPRInfo.mrpr.status == MRPRStatusCannotMerge) {
330329
curButton.alpha = 0.5;
331330
}
332-
}else if (actionType == MRPRActionRefuse){
331+
} else if (actionType == MRPRActionRefuse){
333332
title = @"拒绝";
334333
colorStr = @"0xE15957";
335-
}else if (actionType == MRPRActionCancel){
334+
} else if (actionType == MRPRActionCancel){
336335
title = @"取消";
337336
colorStr = @"0xF8F8F8";
338337
[curButton doBorderWidth:0.5 color:[UIColor colorWithHexString:@"0xB5B5B5"] cornerRadius:2.0];

Coding_iOS/Controllers/ReviewerListController.m

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ -(void)viewDidLoad {
3939
self.myTableView.separatorStyle = NO;
4040
self.reviewers = [[NSMutableArray alloc] init];
4141
self.volunteer_reviewers = [[NSMutableArray alloc] init];
42-
43-
4442
}
4543

4644
-(void)viewWillAppear:(BOOL)animated {
@@ -69,27 +67,20 @@ - (void)updateData {
6967
}
7068

7169
- (void)sortReviewers {
72-
7370
NSMutableArray *dataArray = [[NSMutableArray alloc] init];
7471
for(int i = 0; i < self.curReviewersInfo.reviewers.count; i ++) {
7572
Reviewer* tmpReviewer = self.curReviewersInfo.reviewers[i];
76-
77-
[dataArray addObject:tmpReviewer];
78-
73+
[dataArray addObject:tmpReviewer];
7974
}
80-
8175
for(int i = 0; i < self.curReviewersInfo.volunteer_reviewers.count; i ++) {
8276
Reviewer* tmpReviewer = self.curReviewersInfo.volunteer_reviewers[i];
83-
84-
[dataArray addObject:tmpReviewer];
77+
[dataArray addObject:tmpReviewer];
8578
}
8679
NSMutableArray *reviewerList= [dataArray sortedArrayUsingComparator:^NSComparisonResult(Reviewer *obj1, Reviewer *obj2) {
87-
8880
NSComparisonResult result = [ obj2.value compare:obj1.value];
8981
if(result == NSOrderedSame) {
9082
result = [ obj1.volunteer compare:obj2.volunteer];
9183
}
92-
9384
return result;
9485
}];
9586
self.reviewers = reviewerList;
@@ -103,21 +94,10 @@ -(void)selectRightAction:(id)sender
10394
appview.volunteer_reviewers = self.volunteer_reviewers;
10495
appview.curMRPR = self.curMRPR;
10596
appview.currentProject = self.currentProject;
106-
10797
[self.navigationController pushViewController:appview animated:YES];
10898
}
10999

110-
- (id)initWithFrame:(CGRect)frame projects:(Projects *)projects block:(ReviewerListControllerBlock)block tabBarHeight:(CGFloat)tabBarHeight
111-
{
112-
//self = [super initWithFrame:frame];
113-
if (self) {
114-
// Initialization code
115-
116-
}
117-
return self;
118-
}
119100
#pragma mark Table M
120-
121101
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
122102
return 20;
123103
}
@@ -178,7 +158,6 @@ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
178158
[self searchProjectWithStr:searchText];
179159
}
180160

181-
182161
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
183162
[searchBar resignFirstResponder];
184163
[self searchProjectWithStr:searchBar.text];
@@ -188,7 +167,6 @@ - (void)searchProjectWithStr:(NSString *)string{
188167
[self.myTableView reloadData];
189168
}
190169

191-
192170
//先要设Cell可编辑
193171
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
194172
{
@@ -218,15 +196,12 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
218196
}];
219197
}
220198

221-
222-
223199
//修改编辑按钮文字
224200
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
225201
{
226202
return @"删除";
227203
}
228204

229-
230205
//先设置Cell可移动
231206
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
232207
{
@@ -237,7 +212,6 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
237212
}
238213
}
239214

240-
241215
//设置进入编辑状态时,Cell不会缩进
242216
- (BOOL)tableView: (UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
243217
{

0 commit comments

Comments
 (0)