Skip to content

Commit 3421984

Browse files
committed
一些布局的调整~
1 parent a57ffed commit 3421984

7 files changed

Lines changed: 67 additions & 55 deletions

File tree

Coding_iOS/Controllers/AllSearchDisplayVC.m

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ - (void)goToMRDetail:(MRPR *)curMR{
346346
#pragma mark Search Data Request
347347

348348
- (void)refresh {
349-
350349
if(_isLoading){
351350
[_searchTableView.infiniteScrollingView stopAnimating];
352351
return;
@@ -563,52 +562,60 @@ -(void)requestAll{
563562
__weak typeof(self) weakSelf = self;
564563
[[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"all" andPage:1 andBlock:^(id data, NSError *error) {
565564
if(data) {
566-
_searchPros = [NSObject objectOfClass:@"PublicSearchModel" fromJSON:data];
565+
[weakSelf.dateSource removeAllObjects];
566+
weakSelf.searchPros = [NSObject objectOfClass:@"PublicSearchModel" fromJSON:data];
567567
NSDictionary *dataDic = (NSDictionary *)data;
568-
NSArray *resultA =[dataDic[@"project_topics"] objectForKey:@"list"] ;
568+
569+
//topic 处理 content 关键字
570+
NSArray *resultTopic =[dataDic[@"project_topics"] objectForKey:@"list"] ;
569571
for (int i=0;i<[_searchPros.project_topics.list count];i++) {
570572
ProjectTopic *curTopic=[_searchPros.project_topics.list objectAtIndex:i];
571-
if ([resultA count]>i) {
572-
curTopic.content= [[[resultA objectAtIndex:i] objectForKey:@"content"] firstObject];
573+
if ([resultTopic count]>i) {
574+
curTopic.contentStr= [[[resultTopic objectAtIndex:i] objectForKey:@"content"] firstObject];
575+
}
576+
}
577+
578+
//task 处理 description 关键字
579+
NSArray *resultTask =[dataDic[@"tasks"] objectForKey:@"list"] ;
580+
for (int i=0;i<[weakSelf.searchPros.tasks.list count];i++) {
581+
Task *curTask=[weakSelf.searchPros.tasks.list objectAtIndex:i];
582+
if ([resultTask count]>i) {
583+
curTask.descript= [[[resultTask objectAtIndex:i] objectForKey:@"description"] firstObject];
584+
NSLog(@"%@",curTask.description_mine);
573585
}
574586
}
575-
switch (_curSearchType) {
587+
588+
switch (weakSelf.curSearchType) {
576589
case eSearchType_Project:
577-
[weakSelf.dateSource addObjectsFromArray:_searchPros.projects.list];
590+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.projects.list];
578591
break;
579592
case eSearchType_Tweet:
580-
[weakSelf.dateSource addObjectsFromArray:_searchPros.tweets.list];
593+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.tweets.list];
581594
break;
582595
case eSearchType_Document:
583-
[weakSelf.dateSource addObjectsFromArray:_searchPros.files.list];
596+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.files.list];
584597
break;
585598
case eSearchType_User:
586-
[weakSelf.dateSource addObjectsFromArray:_searchPros.friends.list];
599+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.friends.list];
587600
break;
588601
case eSearchType_Task:
589-
[weakSelf.dateSource addObjectsFromArray:_searchPros.tasks.list];
602+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.tasks.list];
590603
break;
591604
case eSearchType_Topic:
592-
[weakSelf.dateSource addObjectsFromArray:_searchPros.project_topics.list];
605+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.project_topics.list];
593606
break;
594607
case eSearchType_Merge:
595-
[weakSelf.dateSource addObjectsFromArray:_searchPros.merge_requests.list];
608+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.merge_requests.list];
596609
break;
597610
case eSearchType_Pull:
598-
[weakSelf.dateSource addObjectsFromArray:_searchPros.pull_requests.list];
611+
[weakSelf.dateSource addObjectsFromArray:weakSelf.searchPros.pull_requests.list];
599612
break;
600613
default:
601614
break;
602615
}
603616

604617
[weakSelf.searchTableView configBlankPage:EaseBlankPageTypeProject_SEARCH hasData:[weakSelf noEmptyList] hasError:(error != nil) reloadButtonBlock:^(id sender) {
605-
[weakSelf requestAll];
606618
}];
607-
608-
//空白页按钮事件
609-
weakSelf.searchTableView.blankPageView.clickButtonBlock=^(EaseBlankPageType curType) {
610-
[weakSelf requestAll];
611-
};
612619

613620
[weakSelf.searchTableView reloadData];
614621
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
@@ -709,10 +716,23 @@ - (void)requestDataWithPage:(NSInteger)page {
709716
if(data) {
710717
NSDictionary *dataDic = (NSDictionary *)data;
711718
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"Task"];
719+
720+
//task 处理 description 关键字
721+
NSArray *resultTask =dataDic[@"list"];
722+
for (int i=0;i<[resultA count];i++) {
723+
Task *curTask=[resultA objectAtIndex:i];
724+
if ([resultTask count]>i) {
725+
curTask.descript= [[[resultTask objectAtIndex:i] objectForKey:@"description"] firstObject];
726+
NSLog(@"%@",curTask.description_mine);
727+
}
728+
}
729+
712730
[weakSelf.searchPros.tasks.list addObjectsFromArray:resultA];
713731
//更新page
714732
weakSelf.searchPros.tasks.page = dataDic[@"page"] ;
715733
weakSelf.searchPros.tasks.totalPage = dataDic[@"totalPage"] ;
734+
735+
716736
[weakSelf.dateSource addObjectsFromArray:resultA];
717737
[weakSelf.searchTableView reloadData];
718738
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];

Coding_iOS/Models/ProjectTopic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@property (readwrite, nonatomic, strong) NSNumber *id, *child_count, *current_user_role_id, *owner_id, *project_id, *parent_id, *number,*resource_id;
2020
@property (readwrite, nonatomic, strong) NSDate *created_at;
2121
@property (readwrite, nonatomic, strong) NSDate *updated_at;
22-
@property (readwrite, nonatomic, strong) NSString *title, *content, *path;
22+
@property (readwrite, nonatomic, strong) NSString *title, *content, *path,*contentStr;
2323
@property (readwrite, strong, nonatomic) NSMutableArray *labels;
2424
@property (readwrite, nonatomic, strong) NSDictionary *propertyArrayMap;
2525

Coding_iOS/Models/Task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, TaskHandleType) {
2424

2525
@interface Task : NSObject
2626
@property (readwrite, nonatomic, strong) User *owner, *creator;
27-
@property (readwrite, nonatomic, strong) NSString *title, *content, *backend_project_path, *deadline, *path, *description_mine;
27+
@property (readwrite, nonatomic, strong) NSString *title, *content, *backend_project_path, *deadline, *path, *description_mine,*descript;
2828
@property (readwrite, nonatomic, strong) NSDate *created_at, *updated_at;
2929
@property (readonly, nonatomic, strong) NSDate *deadline_date;
3030
@property (readwrite, nonatomic, strong) Project *project;

Coding_iOS/Views/Cell/ProjectAboutMeListCell.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ - (void)setProject:(Project *)project hasSWButtons:(BOOL)hasSWButtons hasBadgeTi
142142
}else{
143143
_describeLabel.text=_project.description_mine;
144144
}
145-
_ownerTitleLabel.text = _project.owner_user_name;
145+
_ownerTitleLabel.text = _project.owner_user_name? _project.owner_user_name:[[[[_project.project_path componentsSeparatedByString:@"/p"] firstObject] componentsSeparatedByString:@"u/"] lastObject];
146146

147147

148148
//hasSWButtons
@@ -172,9 +172,6 @@ - (void)setProject:(Project *)project hasSWButtons:(BOOL)hasSWButtons hasBadgeTi
172172

173173
- (NSArray *)rightButtons{
174174
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
175-
// [rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:_project.pin.boolValue? @"0xe6e6e6": @"0x3bbd79"]
176-
// icon:[UIImage imageNamed:_project.pin.boolValue? @"icon_project_cell_pin": @"icon_project_cell_nopin"]];
177-
178175
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:_project.pin.boolValue? @"0xeeeeee": @"0x3bbd79"]
179176
title:_project.pin.boolValue?@"取消常用":@"设置常用" titleColor:[UIColor colorWithHexString:_project.pin.boolValue?@"0x3bbd79":@"0xffffff"]];
180177
return rightUtilityButtons;

Coding_iOS/Views/Cell/TaskSearchCell.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define kProjectTaskListViewCell_MaxContentHeight 20.0
1414
#define kProjectTaskListViewCell_ContentWidth (kScreen_Width - kProjectTaskListViewCell_LeftPading - kProjectTaskListViewCell_RightPading)
1515
#define kProjectTaskListViewCell_ContentFont [UIFont systemFontOfSize:15]
16-
#define kProjectTaskListViewCell_TextPading 10.0
16+
#define kInnerHorizonOffset 12.0
1717

1818

1919
#import "TaskSearchCell.h"
@@ -113,21 +113,21 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
113113

114114
[_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
115115
make.top.equalTo(self.contentView).offset(19-3);
116-
make.left.equalTo(self.userIconView.mas_right).offset(10);
116+
make.left.equalTo(self.userIconView.mas_right).offset(kInnerHorizonOffset);
117117
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
118118
make.height.mas_equalTo(20);
119119
}];
120120

121121
[_describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
122122
make.top.equalTo(self.contentLabel.mas_bottom).offset(10);
123-
make.left.equalTo(self.userIconView.mas_right).offset(10);
123+
make.left.equalTo(self.userIconView.mas_right).offset(kInnerHorizonOffset);
124124
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
125125
make.height.mas_equalTo(40);
126126
}];
127127

128128
[_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
129129
make.bottom.equalTo(self.contentView).offset(-10);
130-
make.left.equalTo(self.userIconView.mas_right).offset(10);
130+
make.left.equalTo(self.userIconView.mas_right).offset(kInnerHorizonOffset);
131131
make.height.mas_equalTo(15);
132132
}];
133133
[_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -179,14 +179,13 @@ - (void)layoutSubviews{
179179

180180
_contentLabel.attributedText=[NSString getAttributeFromText:[_task.content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
181181

182-
// _contentLabel.text = [_task.content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
183182
//Bottom
184183
_numLabel.text = [NSString stringWithFormat:@"#%@", _task.resource_id.stringValue];
185184
_userNameLabel.text = _task.creator.name;
186185
_timeLabel.text = [_task.created_at stringDisplay_MMdd];
187186
_commentCountLabel.text = _task.comments.stringValue;
188187
_mdIconView.hidden = _mdLabel.hidden = !_task.has_description.boolValue;
189-
_describeLabel.text=_task.description_mine;
188+
_describeLabel.attributedText=[NSString getAttributeFromText:[_task.descript stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
190189
}
191190

192191
@end

Coding_iOS/Views/Cell/TopicSearchCell.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define kProjectTopicCell_ContentWidth (kScreen_Width - kProjectTopicCell_PadingLeft - kProjectTopicCell_PadingRight)
1212
#define kProjectTopicCell_ContentHeightMax 40.0
1313
#define kProjectTopicCell_ContentFont [UIFont systemFontOfSize:16]
14-
14+
#define kInnerHorizonOffset 12
1515

1616
#import "TopicSearchCell.h"
1717
#import "ProjectTag.h"
@@ -33,12 +33,12 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3333
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3434
self.backgroundColor = [UIColor clearColor];
3535
if (!_userIconView) {
36-
_userIconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 40, 40)];
36+
_userIconView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 18, 40, 40)];
3737
[_userIconView doCircleFrame];
3838
[self.contentView addSubview:_userIconView];
3939
}
4040
if (!_titleLabel) {
41-
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kProjectTopicCell_PadingLeft, 12, kProjectTopicCell_ContentWidth, 20)];
41+
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15+40+kInnerHorizonOffset, 15, kProjectTopicCell_ContentWidth, 20)];
4242
_titleLabel.font = kProjectTopicCell_ContentFont;
4343
_titleLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
4444
[self.contentView addSubview:_titleLabel];
@@ -52,13 +52,6 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
5252
[self.contentView addSubview:_describeLabel];
5353
}
5454

55-
[_describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
56-
make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
57-
make.left.equalTo(self.userIconView.mas_right).offset(10);
58-
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
59-
make.height.mas_equalTo(40);
60-
}];
61-
6255

6356
if (!_numLabel) {
6457
_numLabel = [[UILabel alloc] initWithFrame:CGRectMake(kProjectTopicCell_PadingLeft, 0, 150, 15)];
@@ -101,10 +94,16 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
10194
}
10295

10396

97+
[_describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
98+
make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
99+
make.left.equalTo(self.userIconView.mas_right).offset(kInnerHorizonOffset);
100+
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
101+
make.height.mas_equalTo(40);
102+
}];
104103

105104
[_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
106105
make.bottom.equalTo(self.contentView).offset(-10);
107-
make.left.equalTo(self.userIconView.mas_right).offset(10);
106+
make.left.equalTo(self.userIconView.mas_right).offset(kInnerHorizonOffset);
108107
make.height.mas_equalTo(15);
109108
}];
110109
[_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -169,7 +168,8 @@ - (void)layoutSubviews{
169168
_commentCountLabel.text = _curTopic.child_count.stringValue;
170169
[_commentCountLabel sizeToFit];
171170

172-
_describeLabel.attributedText=[NSString getAttributeFromText:[_curTopic.content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
171+
NSString *content=[_curTopic.contentStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
172+
_describeLabel.attributedText=[NSString getAttributeFromText:[content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
173173
}
174174

175175
//+(CGFloat)cellHeightWithObj:(id)aObj{

Coding_iOS/Views/Cell/TweetSearchCell.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#import "TweetLikeUserCCell.h"
1414
#import "MJPhotoBrowser.h"
1515

16-
#define kTweetCell_PadingLeft 52.0
16+
#define kTweetCell_PadingLeft (15+40+kInnerHorzionOffset)
1717
#define kTweetCell_PadingTop 15.0
1818
#define kTweetCell_PadingBottom 10.0
1919
#define kTweetCell_ContentWidth (kScreen_Width - kTweetCell_PadingLeft - 30)
2020
#define kTweet_ContentMaxHeight 36.0
2121
#define kTweet_ContentFont [UIFont systemFontOfSize:15]
2222
#define kTweetCell_LikeUserCCell_Height 25.0
23-
#define kTweetCell_LikeUserCCell_Pading 10.0
23+
#define kInnerHorzionOffset 12
2424
#define kTweet_TimtFont [UIFont systemFontOfSize:12]
2525
#define kTweetCell_NameMaxWidth (kTweetCell_ContentWidth - )
2626

@@ -41,7 +41,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4141
self.accessoryType = UITableViewCellAccessoryNone;
4242

4343
if (!self.ownerImgView) {
44-
self.ownerImgView = [[UITapImageView alloc] initWithFrame:CGRectMake(12, 10, 30, 30)];
44+
self.ownerImgView = [[UITapImageView alloc] initWithFrame:CGRectMake(15, 18, 40, 40)];
4545
[self.ownerImgView doCircleFrame];
4646
[self.contentView addSubview:self.ownerImgView];
4747
}
@@ -145,7 +145,7 @@ - (void)layoutSubviews {
145145
[self.contentLabel addLinkToTransitInformation:[NSDictionary dictionaryWithObject:item forKey:@"value"] withRange:item.range];
146146
}
147147
}
148-
CGFloat curBottomY = kTweetCell_PadingTop + [TweetSearchCell contentLabelHeightWithTweet:_tweet] + 10;
148+
CGFloat curBottomY = self.frame.size.height-12-15;
149149

150150
CGFloat curX = kTweetCell_PadingLeft;
151151
[self.nameLabel setLongString:_tweet.owner.name withVariableWidth:kScreen_Width / 2];
@@ -192,15 +192,11 @@ + (CGFloat)cellHeightWithObj:(id)obj {
192192

193193
Tweet *tweet = (Tweet *)obj;
194194
CGFloat cellHeight = 0;
195-
// if (tweet.likes.integerValue > 0 || tweet.comments.integerValue > 0) {
196-
// cellHeight = 6;
197-
// }else{
198-
// cellHeight = 3;
199-
// }
200-
cellHeight += 15 * 2 + 10;
195+
196+
cellHeight += 18+20+12+5;
201197
// cellHeight += kTweetCell_PadingTop;
202198
cellHeight += [TweetSearchCell contentLabelHeightWithTweet:tweet];
203-
cellHeight += 12;
199+
cellHeight += 15;
204200
return cellHeight;
205201
}
206202

0 commit comments

Comments
 (0)