Skip to content

Commit b39f8d4

Browse files
committed
讨论标签优化
1 parent 800a8af commit b39f8d4

13 files changed

Lines changed: 262 additions & 94 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@
399399
4EE1A2311B5D02CA004284F1 /* ProjectTasksView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE1A2261B5D02CA004284F1 /* ProjectTasksView.m */; };
400400
4EE1A2321B5D02CA004284F1 /* ProjectTopicListView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE1A2281B5D02CA004284F1 /* ProjectTopicListView.m */; };
401401
4EE1A2331B5D02CA004284F1 /* ProjectTopicsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE1A22A1B5D02CA004284F1 /* ProjectTopicsView.m */; };
402+
4EE1A2361B5DF568004284F1 /* ProjectTagLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE1A2351B5DF568004284F1 /* ProjectTagLabel.m */; };
402403
4EE5481E1AE7B7CA00A92306 /* UISearchBar+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE5481D1AE7B7CA00A92306 /* UISearchBar+Common.m */; };
403404
4EE548211AE8DB5600A92306 /* Project.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE548201AE8DB5600A92306 /* Project.m */; };
404405
4EE548281AE9166B00A92306 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4EE548261AE9166B00A92306 /* [email protected] */; };
@@ -1395,6 +1396,8 @@
13951396
4EE1A2281B5D02CA004284F1 /* ProjectTopicListView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTopicListView.m; sourceTree = "<group>"; };
13961397
4EE1A2291B5D02CA004284F1 /* ProjectTopicsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectTopicsView.h; sourceTree = "<group>"; };
13971398
4EE1A22A1B5D02CA004284F1 /* ProjectTopicsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTopicsView.m; sourceTree = "<group>"; };
1399+
4EE1A2341B5DF568004284F1 /* ProjectTagLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectTagLabel.h; sourceTree = "<group>"; };
1400+
4EE1A2351B5DF568004284F1 /* ProjectTagLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTagLabel.m; sourceTree = "<group>"; };
13981401
4EE5481C1AE7B7CA00A92306 /* UISearchBar+Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UISearchBar+Common.h"; sourceTree = "<group>"; };
13991402
4EE5481D1AE7B7CA00A92306 /* UISearchBar+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UISearchBar+Common.m"; sourceTree = "<group>"; };
14001403
4EE5481F1AE8DB5600A92306 /* Project.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Project.h; sourceTree = "<group>"; };
@@ -3673,6 +3676,8 @@
36733676
4E996BCF1ABA774800C704F1 /* EaseUserHeaderView.m */,
36743677
4EDC33CC1AFB4DCC00698315 /* EaseInputTipsView.h */,
36753678
4EDC33CD1AFB4DCC00698315 /* EaseInputTipsView.m */,
3679+
4EE1A2341B5DF568004284F1 /* ProjectTagLabel.h */,
3680+
4EE1A2351B5DF568004284F1 /* ProjectTagLabel.m */,
36763681
);
36773682
path = Views;
36783683
sourceTree = "<group>";
@@ -4416,6 +4421,7 @@
44164421
4E07D3081A4A96EA009EDDF2 /* FileListUploadCell.m in Sources */,
44174422
4EE1A22F1B5D02CA004284F1 /* ProjectListView.m in Sources */,
44184423
4EA679161A1496A7001A0324 /* ProjectFolders.m in Sources */,
4424+
4EE1A2361B5DF568004284F1 /* ProjectTagLabel.m in Sources */,
44194425
4EA7F1591A6D192B00A046BD /* NSData+ImageContentType.m in Sources */,
44204426
4E8D5D631B45295D00B70936 /* UIColor+MobileColors.m in Sources */,
44214427
8EA6D1FA19E240C40076D59C /* MJPhotoProgressView.m in Sources */,

Coding_iOS/Controllers/EditLabelViewController.m

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
228228
ProjectTag *ptLabel = _labels[indexPath.row];
229229

230230
EditLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_EditLabelCell forIndexPath:indexPath];
231-
cell.nameLbl.text = ptLabel.name;
231+
[cell setRightUtilityButtons:[self rightButtons] WithButtonWidth:[EditLabelCell cellHeight]];
232+
cell.delegate = self;
232233

233234
BOOL selected = FALSE;
234235
for (ProjectTag *lbl in _curProTopic.mdLabels) {
@@ -237,16 +238,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
237238
break;
238239
}
239240
}
240-
cell.selectBtn.selected = selected;
241-
242-
//if (indexPath.row > 2) {
243-
[cell setRightUtilityButtons:[self rightButtons] WithButtonWidth:[EditLabelCell cellHeight]];
244-
cell.delegate = self;
245-
//}
246-
241+
[cell setTag:ptLabel andSelected:selected];
242+
247243
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
248-
cell.backgroundColor = kColorTableBG;
249-
[cell resetLbl];
250244
return cell;
251245
}
252246

@@ -339,32 +333,8 @@ - (BOOL)swipeableTableViewCellShouldHideUtilityButtonsOnSwipe:(SWTableViewCell *
339333
return YES;
340334
}
341335

342-
- (void)swipeableTableViewCell:(SWTableViewCell *)cell scrollingToState:(SWCellState)state
343-
{
344-
switch (state) {
345-
case 0:
346-
{
347-
EditLabelCell *eCell = (EditLabelCell *)cell;
348-
[eCell showRightBtn:FALSE];
349-
} break;
350-
case 1:
351-
break;
352-
case 2:
353-
{
354-
EditLabelCell *eCell = (EditLabelCell *)cell;
355-
[eCell showRightBtn:TRUE];
356-
} break;
357-
default:
358-
break;
359-
}
360-
}
361-
362336
- (BOOL)swipeableTableViewCell:(SWTableViewCell *)cell canSwipeToState:(SWCellState)state
363337
{
364-
// NSIndexPath *indexPath = [self.myTableView indexPathForCell:cell];
365-
// if (indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2) {
366-
// return NO;
367-
// }
368338
return YES;
369339
}
370340

Coding_iOS/Controllers/EditTopicViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ - (void)loadEditView
207207

208208
if (self.type != TopicEditTypeFeedBack) {
209209
// 标签
210-
CGFloat tagsViewHeight = [ProjectTagsView heghtForTags:_curProTopic.mdLabels];
210+
CGFloat tagsViewHeight = [ProjectTagsView getHeightForTags:_curProTopic.mdLabels];
211211
[_tagsView mas_makeConstraints:^(MASConstraintMaker *make) {
212212
make.top.equalTo(_inputTitleView.mas_bottom).offset(16.0);
213213
make.height.mas_equalTo(tagsViewHeight);

Coding_iOS/Views/Cell/EditLabelCell.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
//
88

99
#import "SWTableViewCell.h"
10+
#import "ProjectTag.h"
1011

1112
@interface EditLabelCell : SWTableViewCell
12-
1313
@property (strong, nonatomic) UIButton *selectBtn;
14-
@property (strong, nonatomic) UILabel *nameLbl;
1514

16-
- (void)showRightBtn:(BOOL)show;
17-
- (void)resetLbl;
15+
- (void)setTag:(ProjectTag *)curTag andSelected:(BOOL)selected;
1816

1917
+ (CGFloat)cellHeight;
2018

Coding_iOS/Views/Cell/EditLabelCell.m

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
//
88

99
#import "EditLabelCell.h"
10+
#import "ProjectTagLabel.h"
1011

1112
@interface EditLabelCell ()
13+
@property (strong, nonatomic) ProjectTagLabel *nameLbl;
1214
@end
1315

1416
@implementation EditLabelCell
@@ -17,15 +19,10 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1719
{
1820
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1921
if (self) {
20-
self.accessoryType = UITableViewCellAccessoryNone;
21-
self.backgroundColor = [UIColor clearColor];
2222
// Initialization code
23-
if (!_nameLbl) {
24-
_nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, (kScreen_Width - kPaddingLeftWidth * 2 - 30), 44)];
25-
_nameLbl.textColor = [UIColor colorWithHexString:@"0x222222"];
26-
_nameLbl.font = [UIFont systemFontOfSize:16];
27-
[self.contentView addSubview:_nameLbl];
28-
}
23+
self.accessoryType = UITableViewCellAccessoryNone;
24+
self.backgroundColor = kColorTableBG;
25+
2926
if (!_selectBtn) {
3027
_selectBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreen_Width - kPaddingLeftWidth - 24, 10, 24, 24)];
3128
[_selectBtn setImage:[UIImage imageNamed:@"tag_select_no"] forState:UIControlStateNormal];
@@ -37,31 +34,15 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3734
return self;
3835
}
3936

40-
- (void)layoutSubviews
41-
{
42-
[super layoutSubviews];
43-
}
44-
45-
- (void)resetLbl
46-
{
47-
// _nameLbl.frame = CGRectMake(kPaddingLeftWidth, 0, (kScreen_Width - kPaddingLeftWidth * 2 - 30), 44);
48-
// _selectBtn.hidden = FALSE;
49-
}
50-
51-
- (void)showRightBtn:(BOOL)show
52-
{
53-
// if (show) {
54-
// _selectBtn.hidden = show;
55-
// [UIView animateWithDuration:0.1 animations:^{
56-
// _nameLbl.frame = CGRectMake(kPaddingLeftWidth + 88, 0, (kScreen_Width - kPaddingLeftWidth * 2 - 30 - 88), 44);
57-
// }];
58-
// } else {
59-
// [UIView animateWithDuration:0.1 animations:^{
60-
// _nameLbl.frame = CGRectMake(kPaddingLeftWidth, 0, (kScreen_Width - kPaddingLeftWidth * 2 - 30), 44);
61-
// } completion:^(BOOL finished) {
62-
// _selectBtn.hidden = show;
63-
// }];
64-
// }
37+
- (void)setTag:(ProjectTag *)curTag andSelected:(BOOL)selected{
38+
if (_nameLbl) {
39+
_nameLbl.curTag = curTag;
40+
}else{
41+
_nameLbl = [ProjectTagLabel labelWithRag:curTag font:[UIFont systemFontOfSize:12] height:20 widthPadding:10];
42+
[_nameLbl setOrigin:CGPointMake(kPaddingLeftWidth, ([EditLabelCell cellHeight] - 22)/2)];
43+
[self.contentView addSubview:_nameLbl];
44+
}
45+
_selectBtn.selected = selected;
6546
}
6647

6748
+ (CGFloat)cellHeight

Coding_iOS/Views/Cell/ProjectTopicCell.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@
1616

1717
+(CGFloat)cellHeightWithObj:(id)aObj;
1818
@end
19+
20+
21+
@interface ProjectTopicCellTagsView : UIView
22+
@property (strong, nonatomic) NSArray *tags;
23+
24+
- (instancetype)initWithTags:(NSArray *)tags;
25+
+ (instancetype)viewWithTags:(NSArray *)tags;
26+
+ (CGFloat)getHeightForTags:(NSArray *)tags;
27+
@end

0 commit comments

Comments
 (0)