Skip to content

Commit 0db09ab

Browse files
committed
一些调整~
1 parent 3421984 commit 0db09ab

5 files changed

Lines changed: 107 additions & 32 deletions

File tree

Coding_iOS/Controllers/AllSearchDisplayVC.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ - (void)requestDataWithPage:(NSInteger)page {
680680
weakSelf.isLoading = NO;
681681
}];
682682
}else if(_curSearchType==eSearchType_Merge){
683-
[[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"merge_request" andPage:page andBlock:^(id data, NSError *error) {
683+
[[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"mr" andPage:page andBlock:^(id data, NSError *error) {
684684
if(data) {
685685
NSDictionary *dataDic = (NSDictionary *)data;
686686
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"MRPR"];
@@ -696,7 +696,7 @@ - (void)requestDataWithPage:(NSInteger)page {
696696
weakSelf.isLoading = NO;
697697
}];
698698
}else if(_curSearchType==eSearchType_Pull){
699-
[[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"pull_request" andPage:page andBlock:^(id data, NSError *error) {
699+
[[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"pr" andPage:page andBlock:^(id data, NSError *error) {
700700
if(data) {
701701
NSDictionary *dataDic = (NSDictionary *)data;
702702
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"MRPR"];

Coding_iOS/Models/MRPR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef NS_ENUM(NSInteger, MRPRStatus) {
1919

2020
@interface MRPR : NSObject
2121
@property (strong, nonatomic) NSNumber *id, *iid, *srcExist, *comment_count;
22-
@property (strong, nonatomic) NSString *title, *path, *srcBranch, *desBranch, *merge_status, *src_owner_name;
22+
@property (strong, nonatomic) NSString *title, *path, *srcBranch, *desBranch, *merge_status, *src_owner_name,*source_branch,*target_branch;
2323
@property (strong, nonatomic) NSString *des_owner_name, *des_project_name;
2424
@property (strong, nonatomic) User *author, *action_author;
2525
@property (strong, nonatomic) NSDate *created_at, *action_at;

Coding_iOS/Views/Cell/FileSearchCell.m

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

99
#define kFileListFileCell_IconWidth 45.0
10-
#define kFileListFileCell_LeftPading (kPaddingLeftWidth +kFileListFileCell_IconWidth +20.0)
10+
#define kFileListFileCell_LeftPading (kPaddingLeftWidth +kFileListFileCell_IconWidth +12.0)
1111
#define kFileListFileCell_TopPading 10.0
1212

1313

@@ -38,7 +38,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3838
[self.contentView addSubview:_iconView];
3939
}
4040
if (!_nameLabel) {
41-
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kFileListFileCell_LeftPading, kFileListFileCell_TopPading, (kScreen_Width - kFileListFileCell_LeftPading - 60), 25)];
41+
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kFileListFileCell_LeftPading, kFileListFileCell_TopPading-3, (kScreen_Width - kFileListFileCell_LeftPading - 60), 25)];
4242
_nameLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
4343
_nameLabel.font = [UIFont systemFontOfSize:16];
4444
[self.contentView addSubview:_nameLabel];
@@ -50,7 +50,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
5050
[self.contentView addSubview:_sizeLabel];
5151
}
5252
if (!_infoLabel) {
53-
_infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(kFileListFileCell_LeftPading, (kFileSearchCellHeight- 15 - kFileListFileCell_TopPading), (kScreen_Width - kFileListFileCell_LeftPading - 60), 15)];
53+
_infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(kFileListFileCell_LeftPading, (kFileSearchCellHeight- 15 - kFileListFileCell_TopPading+1), (kScreen_Width - kFileListFileCell_LeftPading - 60), 15)];
5454
_infoLabel.textColor = [UIColor colorWithHexString:@"0x999999"];
5555
_infoLabel.font = [UIFont systemFontOfSize:12];
5656
[self.contentView addSubview:_infoLabel];

Coding_iOS/Views/Cell/PRMRSearchCell.m

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
// Copyright © 2015年 Coding. All rights reserved.
77
//
88

9+
#define kBaseCellHeight 110
10+
911
#define kMRPRListCell_UserWidth 33.0
1012

1113
#import "PRMRSearchCell.h"
14+
#import "NSString+Attribute.h"
1215

1316
@interface PRMRSearchCell ()
14-
@property (strong, nonatomic) UIImageView *imgView;
15-
@property (strong, nonatomic) UILabel *titleLabel, *subTitleLabel;
17+
@property (strong, nonatomic) UIImageView *imgView,*arrowIcon;
18+
@property (strong, nonatomic) UILabel *titleLabel, *subTitleLabel,*fromL,*toL;
1619
@end
1720

1821

19-
2022
@implementation PRMRSearchCell
2123

2224
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
@@ -39,8 +41,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3941
make.centerY.equalTo(self.contentView);
4042
}];
4143
}
44+
4245
if (!_titleLabel) {
4346
_titleLabel = [UILabel new];
47+
_titleLabel.textColor=[UIColor colorWithHexString:@"0x222222"];
48+
_titleLabel.font=[UIFont boldSystemFontOfSize:14];
4449
[self.contentView addSubview:_titleLabel];
4550
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
4651
make.left.equalTo(_imgView.mas_right).offset(12);
@@ -49,6 +54,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4954
make.height.mas_equalTo(20);
5055
}];
5156
}
57+
5258
if (!_subTitleLabel) {
5359
_subTitleLabel = [UILabel new];
5460
[self.contentView addSubview:_subTitleLabel];
@@ -57,6 +63,44 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
5763
make.bottom.equalTo(self.contentView.mas_bottom).offset(-13);
5864
}];
5965
}
66+
67+
if (!_fromL) {
68+
_fromL = [UILabel new];
69+
[_fromL doBorderWidth:0.5 color:[UIColor colorWithHexString:@"0x4E90BF"] cornerRadius:2.0];
70+
_fromL.font = [UIFont systemFontOfSize:12];
71+
_fromL.textColor = [UIColor colorWithHexString:@"0x4E90BF"];
72+
[self.contentView addSubview:_fromL];
73+
}
74+
75+
if (!_arrowIcon) {
76+
_arrowIcon = [UIImageView new];
77+
_arrowIcon.image = [UIImage imageNamed:@"mrpr_icon_arrow"];
78+
[self.contentView addSubview:_arrowIcon];
79+
}
80+
81+
if (!_toL) {
82+
_toL = [UILabel new];
83+
[_toL doBorderWidth:0.5 color:[UIColor colorWithHexString:@"0x4E90BF"] cornerRadius:2.0];
84+
_toL.font = [UIFont systemFontOfSize:12];
85+
_toL.textColor = [UIColor colorWithHexString:@"0x4E90BF"];
86+
[self.contentView addSubview:_toL];
87+
}
88+
89+
90+
[_fromL mas_makeConstraints:^(MASConstraintMaker *make) {
91+
make.left.equalTo(_titleLabel);
92+
make.top.equalTo(_titleLabel.mas_bottom).offset(15);
93+
make.height.mas_equalTo(20);
94+
}];
95+
96+
[_arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
97+
make.left.equalTo(_fromL.mas_right).offset(10);
98+
make.centerY.equalTo(_fromL);
99+
make.size.mas_equalTo(CGSizeMake(15, 15));
100+
make.right.lessThanOrEqualTo(self.contentView).offset(-kPaddingLeftWidth);
101+
}];
102+
103+
60104
}
61105
return self;
62106
}
@@ -67,25 +111,41 @@ - (void)setCurMRPR:(MRPR *)curMRPR{
67111
return;
68112
}
69113
[_imgView sd_setImageWithURL:[_curMRPR.author.avatar urlImageWithCodePathResize:2*kMRPRListCell_UserWidth] placeholderImage:kPlaceholderMonkeyRoundWidth(2*kMRPRListCell_UserWidth)];
70-
_titleLabel.attributedText = [self attributeTitle];
114+
_titleLabel.attributedText = [NSString getAttributeFromText:[_curMRPR.title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
71115
_subTitleLabel.attributedText = [self attributeTail];
72116

73-
}
117+
118+
NSString *fromStr, *toStr;
119+
if (_curMRPR.isMR) {
120+
fromStr = [NSString stringWithFormat:@" %@ ", _curMRPR.source_branch];
121+
toStr = [NSString stringWithFormat:@" %@ ", _curMRPR.target_branch];
122+
}else{
123+
fromStr = [NSString stringWithFormat:@" %@ : %@ ", _curMRPR.src_owner_name, _curMRPR.source_branch];
124+
toStr = [NSString stringWithFormat:@" %@ : %@ ", _curMRPR.des_owner_name, _curMRPR.target_branch];
125+
}
126+
NSString *totalStr = [NSString stringWithFormat:@"%@%@", fromStr, toStr];
127+
if ([totalStr getWidthWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(CGFLOAT_MAX, 20)] + 40 > kScreen_Width - 2*kPaddingLeftWidth) {
128+
[_toL mas_remakeConstraints:^(MASConstraintMaker *make) {
129+
make.left.equalTo(_titleLabel);
130+
make.top.equalTo(_fromL.mas_bottom).offset(15);
131+
make.height.equalTo(_fromL);
132+
make.right.lessThanOrEqualTo(self.contentView).offset(-kPaddingLeftWidth);
133+
}];
134+
}else{
135+
[_toL mas_remakeConstraints:^(MASConstraintMaker *make) {
136+
make.left.equalTo(_arrowIcon.mas_right).offset(10);
137+
make.top.equalTo(_fromL);
138+
make.height.top.equalTo(_fromL);
139+
make.right.lessThanOrEqualTo(self.contentView).offset(-kPaddingLeftWidth);
140+
}];
141+
}
142+
_fromL.attributedText = [NSString getAttributeFromText:[fromStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
143+
_toL.attributedText = [NSString getAttributeFromText:[fromStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
74144

75-
- (NSAttributedString *)attributeTitle{
76-
NSString *iidStr = [NSString stringWithFormat:@"#%@", _curMRPR.iid.stringValue? _curMRPR.iid.stringValue: @""];
77-
NSString *titleStr = _curMRPR.title? _curMRPR.title: @"";
78-
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", iidStr, titleStr]];
79-
[attrString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
80-
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x4E90BF"]}
81-
range:NSMakeRange(0, iidStr.length)];
82-
[attrString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
83-
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x222222"]}
84-
range:NSMakeRange(iidStr.length + 1, titleStr.length)];
85-
return attrString;
86145

87146
}
88147

148+
89149
- (NSAttributedString *)attributeTail{
90150
NSString *nameStr = _curMRPR.author.name? _curMRPR.author.name: @"";
91151
NSString *timeStr = _curMRPR.created_at? [_curMRPR.created_at stringDisplay_HHmm]: @"";
@@ -101,7 +161,7 @@ - (NSAttributedString *)attributeTail{
101161

102162

103163
+ (CGFloat)cellHeight{
104-
return 70.0;
164+
return kBaseCellHeight;
105165
}
106166

107167
@end

Coding_iOS/Views/Cell/UserSearchCell.m

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
#import "UserSearchCell.h"
1010
#import "NSString+Attribute.h"
11+
#import "Login.h"
1112

1213
@interface UserSearchCell ()
13-
@property (strong, nonatomic) UIImageView *userIconView;
14-
@property (strong, nonatomic) UILabel *userNameLabel;
14+
@property (strong, nonatomic) UIImageView *userIconView,*timeClockIconView;
15+
@property (strong, nonatomic) UILabel *userNameLabel,*timeLabel;
1516
@property (strong, nonatomic) UIButton *rightBtn;
1617
@property (strong, nonatomic) UIActivityIndicatorView *sendingStatus;
1718

@@ -47,17 +48,27 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4748
[self.contentView addSubview:_userNameLabel];
4849
}
4950
if (!_rightBtn) {
50-
_rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreen_Width - 80-kPaddingLeftWidth, (kUserSearchCellHeight-30)/2, 80, 32)];
51+
_rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreen_Width - 80-10, (kUserSearchCellHeight-40)/2-3, 60, 25)];
5152
[_rightBtn addTarget:self action:@selector(rightBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
52-
[_rightBtn setTitle:@"私信" forState:UIControlStateNormal];
53-
[_rightBtn setTitleColor:[UIColor colorWithHexString:@"0x999999"] forState:UIControlStateNormal];
53+
[_rightBtn setBackgroundImage:[UIImage imageNamed:@"btn_privateMsg_stranger"] forState:UIControlStateNormal];
5454
[_rightBtn setBackgroundColor:[UIColor clearColor]];
55-
_rightBtn.layer.borderWidth=1;
56-
_rightBtn.layer.borderColor=[UIColor colorWithHexString:@"0x999999"].CGColor;
57-
_rightBtn.layer.masksToBounds=TRUE;
58-
_rightBtn.layer.cornerRadius=3;
5955
[self.contentView addSubview:_rightBtn];
6056
}
57+
58+
if (!self.timeClockIconView) {
59+
self.timeClockIconView = [[UIImageView alloc] initWithFrame:CGRectMake(66, kUserSearchCellHeight-12-15, 12, 12)];
60+
self.timeClockIconView.image = [UIImage imageNamed:@"time_clock_icon"];
61+
[self.contentView addSubview:self.timeClockIconView];
62+
}
63+
64+
if (!self.timeLabel) {
65+
self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(66+12+3, kUserSearchCellHeight-12-15, 200, 12)];
66+
self.timeLabel.font = [UIFont systemFontOfSize:12];
67+
self.timeLabel.textAlignment = NSTextAlignmentLeft;
68+
self.timeLabel.textColor = [UIColor colorWithHexString:@"0x999999"];
69+
[self.contentView addSubview:self.timeLabel];
70+
}
71+
6172
}
6273
return self;
6374
}
@@ -72,6 +83,10 @@ - (void)layoutSubviews{
7283
[_userIconView sd_setImageWithURL:[_curUser.avatar urlImageWithCodePathResizeToView:_userIconView] placeholderImage:kPlaceholderMonkeyRoundView(_userIconView)];
7384
_userNameLabel.attributedText=[NSString getAttributeFromText:_curUser.name emphasizeTag:@"em" emphasizeColor:[UIColor colorWithHexString:@"0xE84D60"]];
7485
}
86+
87+
_rightBtn.hidden=[[Login curLoginUser].global_key isEqualToString:_curUser.global_key];
88+
89+
self.timeLabel.text=[NSString stringWithFormat:@"%@ 加入coding",[_curUser.created_at stringDisplay_HHmm]];
7590
[self configSendingStatusUI];
7691
}
7792

0 commit comments

Comments
 (0)