Skip to content

Commit a066897

Browse files
committed
首页修正~
1 parent 24f60ea commit a066897

3 files changed

Lines changed: 100 additions & 25 deletions

File tree

Coding_iOS/Models/Projects.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ - (NSDictionary *)toParams{
7474
}
7575
return params;
7676
}
77+
7778
- (NSString *)toPath{
7879
NSString *path;
7980
if (self.type >= ProjectsTypeTaProject) {

Coding_iOS/Views/Cell/ProjectAboutMeListCell.m

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,25 @@
99
#define kIconSize 90
1010
#define kSwapBtnWidth 135
1111
#define kLeftOffset 12
12+
#define kPinSize 18
1213

1314
#import "ProjectAboutMeListCell.h"
1415

1516
@interface ProjectAboutMeListCell ()
1617
@property (nonatomic, strong) Project *project;
17-
18-
@property (nonatomic, strong) UIImageView *projectIconView, *privateIconView;
18+
@property (nonatomic, strong) UIImageView *projectIconView, *privateIconView, *pinIconView, *setCommonIconView;
1919
@property (nonatomic, strong) UILabel *projectTitleLabel;
2020
@property (nonatomic, strong) UILabel *ownerTitleLabel;
21+
@property (nonatomic, strong) UILabel *describeLabel;
2122
@end
2223

23-
2424
@implementation ProjectAboutMeListCell
2525

2626
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
2727
{
2828
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
2929
if (self) {
3030
// Initialization code
31-
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3231
self.backgroundColor = [UIColor clearColor];
3332
if (!_projectIconView) {
3433
_projectIconView = [[UIImageView alloc] initWithFrame:CGRectMake(kLeftOffset, 10, kIconSize, kIconSize)];
@@ -49,23 +48,45 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4948
_ownerTitleLabel.font = [UIFont systemFontOfSize:15];
5049
[self.contentView addSubview:_ownerTitleLabel];
5150
}
51+
if (!_describeLabel) {
52+
_describeLabel = [UILabel new];
53+
_describeLabel.textColor = [UIColor colorWithHexString:@"0x666666"];
54+
_describeLabel.font = [UIFont systemFontOfSize:14];
55+
_describeLabel.numberOfLines=2;
56+
[self.contentView addSubview:_describeLabel];
57+
}
58+
5259
if (!_privateIconView) {
5360
_privateIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_project_private"]];
5461
_privateIconView.hidden = YES;
5562
[self.contentView addSubview:_privateIconView];
5663
}
5764

58-
[_projectTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
59-
make.top.equalTo(_projectIconView.mas_top);
60-
make.height.equalTo(@(25));
61-
make.left.equalTo(_privateIconView.mas_right).offset(8);
62-
make.right.lessThanOrEqualTo(self.mas_right);
63-
}];
65+
if (!_pinIconView) {
66+
_pinIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_project_cell_pin"]];
67+
_pinIconView.hidden = YES;
68+
[self.contentView addSubview:_pinIconView];
69+
[_pinIconView mas_makeConstraints:^(MASConstraintMaker *make) {
70+
make.size.mas_equalTo(CGSizeMake(kPinSize, kPinSize));
71+
make.left.equalTo(self.projectIconView).offset(5);
72+
make.top.equalTo(self.projectIconView).offset(6);
73+
}];
74+
}
6475

65-
[_ownerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
66-
make.left.right.height.equalTo(self.projectTitleLabel);
67-
make.bottom.equalTo(_projectIconView.mas_bottom);
68-
}];
76+
if (!_setCommonIconView) {
77+
_setCommonIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
78+
_setCommonIconView.hidden = YES;
79+
//for test
80+
_setCommonIconView.backgroundColor=[UIColor greenColor];
81+
[self.contentView addSubview:_setCommonIconView];
82+
[_setCommonIconView mas_makeConstraints:^(MASConstraintMaker *make) {
83+
make.size.mas_equalTo(CGSizeMake(13, 3));
84+
make.right.equalTo(self).offset(-15);
85+
make.bottom.equalTo(self.projectIconView);
86+
}];
87+
}
88+
89+
6990
}
7091
return self;
7192
}
@@ -85,9 +106,31 @@ - (void)setProject:(Project *)project hasSWButtons:(BOOL)hasSWButtons hasBadgeTi
85106
make.left.equalTo(_projectIconView.mas_right).offset(kLeftOffset);
86107
}];
87108

88-
//Title & UserName
109+
[_projectTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
110+
make.top.equalTo(_projectIconView.mas_top);
111+
make.height.equalTo(@(25));
112+
make.left.equalTo(_privateIconView.mas_right).offset(_privateIconView.hidden?0:8);
113+
make.right.lessThanOrEqualTo(self.mas_right);
114+
}];
115+
116+
[_ownerTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
117+
make.right.height.equalTo(self.projectTitleLabel);
118+
make.left.equalTo(self.privateIconView);
119+
make.bottom.equalTo(_projectIconView.mas_bottom);
120+
}];
121+
122+
[_describeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
123+
make.left.equalTo(self.privateIconView);
124+
make.height.equalTo(@(40));
125+
make.width.equalTo(@(kScreen_Width-kLeftOffset-kIconSize-kLeftOffset));
126+
make.top.equalTo(_projectTitleLabel.mas_bottom);
127+
}];
128+
129+
130+
//Title & UserName & description
89131
_projectTitleLabel.text = _project.name;
90132
_ownerTitleLabel.text = _project.owner_user_name;
133+
_describeLabel.text=_project.description_mine;
91134

92135
//hasSWButtons
93136
[self setRightUtilityButtons:hasSWButtons? [self rightButtons]: nil
@@ -110,14 +153,16 @@ - (void)setProject:(Project *)project hasSWButtons:(BOOL)hasSWButtons hasBadgeTi
110153

111154
//hasIndicator
112155
self.accessoryType = hasIndicator? UITableViewCellAccessoryDisclosureIndicator: UITableViewCellAccessoryNone;
156+
_pinIconView.hidden=!_project.pin.boolValue;
157+
_setCommonIconView.hidden=!hasBadgeTip;
113158
}
114159

115160
- (NSArray *)rightButtons{
116161
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
117162
// [rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:_project.pin.boolValue? @"0xe6e6e6": @"0x3bbd79"]
118163
// icon:[UIImage imageNamed:_project.pin.boolValue? @"icon_project_cell_pin": @"icon_project_cell_nopin"]];
119164

120-
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:_project.pin.boolValue? @"0xe6e6e6": @"0x3bbd79"]
165+
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:_project.pin.boolValue? @"0xeeeeee": @"0x3bbd79"]
121166
title:_project.pin.boolValue?@"取消常用":@"设置常用" titleColor:[UIColor colorWithHexString:_project.pin.boolValue?@"0x3bbd79":@"0xffffff"]];
122167

123168
return rightUtilityButtons;

Coding_iOS/Views/TableListView/ProjectListView.m

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,49 @@ - (void)sendRequest{
186186
}];
187187
}];
188188
}
189+
190+
-(NSString*)getSectionHeaderName{
191+
switch (self.myProjects.type) {
192+
case ProjectsTypeAll:
193+
return @"全部项目";
194+
break;
195+
case ProjectsTypeJoined:
196+
return @"已筛选\"我参与的\"项目";
197+
break;
198+
case ProjectsTypeCreated:
199+
return @"已筛选\"我创建的\"项目";
200+
break;
201+
case ProjectsTypeWatched:
202+
return @"已筛选\"我关注的\"项目";
203+
break;
204+
case ProjectsTypeTaStared:
205+
return @"已筛选\"我收藏的\"项目";
206+
break;
207+
default:
208+
return nil;
209+
break;
210+
}
211+
}
212+
189213
#pragma mark Table M
190214

191215
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
192-
return _dataList.count > 1? kScaleFrom_iPhone5_Desgin(24): 0;
216+
return (self.myProjects.type < ProjectsTypeTaProject)&&(section==0)? 27: 0;
193217
}
194218

195219
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
196-
NSString *headerStr = [self titleForSection:section];
197-
return [tableView getHeaderViewWithStr:headerStr andBlock:nil];
220+
if(self.myProjects.type < ProjectsTypeTaProject){
221+
NSString *headerTitle=[self getSectionHeaderName];
222+
if (headerTitle.length==0) {
223+
return nil;
224+
}
225+
UIView *headerView=[tableView getHeaderViewWithStr:headerTitle color:[UIColor colorWithHexString:@"0xf3f3f3"] andBlock:nil];
226+
return headerView;
227+
}else{
228+
return nil;
229+
}
198230
}
231+
199232
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
200233
return [_dataList count];
201234
}
@@ -209,12 +242,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
209242

210243
if (_useNewStyle) {
211244
if (_myProjects.type < ProjectsTypeTaProject) {
212-
ProjectListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProjectAboutMeListCell" forIndexPath:indexPath];
213-
if (self.myProjects.type == ProjectsTypeToChoose) {
214-
[cell setProject:curPro hasSWButtons:NO hasBadgeTip:NO hasIndicator:NO];
215-
}else{
216-
[cell setProject:curPro hasSWButtons:YES hasBadgeTip:YES hasIndicator:YES];
217-
}
245+
ProjectAboutMeListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProjectAboutMeListCell" forIndexPath:indexPath];
246+
[cell setProject:curPro hasSWButtons:self.myProjects.type == ProjectActivityTypeAll?YES:NO hasBadgeTip:YES hasIndicator:NO];
218247
cell.delegate = self;
219248
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
220249
return cell;

0 commit comments

Comments
 (0)