Skip to content

Commit 30f2f8d

Browse files
committed
修改标签tab界面字体,修改查看模式下增减标签的问题
1 parent 5365dc3 commit 30f2f8d

8 files changed

Lines changed: 147 additions & 36 deletions

File tree

Coding_iOS/Controllers/EditLabelViewController.m

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ - (void)viewDidLoad {
4646
self.title = @"标签管理";
4747
self.navigationController.title = @"标签管理";
4848

49-
self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(okBtnClick)];
50-
self.navigationItem.rightBarButtonItem.enabled = FALSE;
49+
if (!_isSaveChange) {
50+
self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(okBtnClick)];
51+
self.navigationItem.rightBarButtonItem.enabled = FALSE;
52+
}
5153

5254
self.view.backgroundColor = kColorTableSectionBg;
5355

@@ -132,33 +134,38 @@ - (NSString *)toDelPath:(NSInteger)index
132134
return [NSString stringWithFormat:@"api/project/%d/topic/label/%lld", _curProTopic.project_id.intValue, ptLabel.id.longLongValue];
133135
}
134136

137+
- (NSString *)toMedifyPath:(NSNumber *)labelID
138+
{
139+
return [NSString stringWithFormat:@"api/topic/%d/label/%lld", _curProTopic.id.intValue, labelID.longLongValue];
140+
}
141+
135142
#pragma mark - click
136143
- (void)okBtnClick
137144
{
138145
_curProTopic.mdLabels = _tempArray;
139146
//_curProTopic.mdTitle = _tempArray;
140147
//_curProTopic.mdContent = _tempArray;
141148

142-
self.navigationItem.rightBarButtonItem.enabled = NO;
143-
if (_isSaveChange) {
144-
@weakify(self);
145-
[[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoic:self.curProTopic andBlock:^(id data, NSError *error) {
146-
@strongify(self);
147-
self.navigationItem.rightBarButtonItem.enabled = YES;
148-
if (data) {
149-
_curProTopic.labels = [NSMutableArray arrayWithArray:_curProTopic.mdLabels];
150-
if (self.topicChangedBlock) {
151-
self.topicChangedBlock();
152-
}
153-
[self.navigationController popViewControllerAnimated:YES];
154-
}
155-
}];
156-
} else {
149+
//self.navigationItem.rightBarButtonItem.enabled = NO;
150+
// if (_isSaveChange) {
151+
// @weakify(self);
152+
// [[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoic:self.curProTopic andBlock:^(id data, NSError *error) {
153+
// @strongify(self);
154+
// self.navigationItem.rightBarButtonItem.enabled = YES;
155+
// if (data) {
156+
// _curProTopic.labels = [NSMutableArray arrayWithArray:_curProTopic.mdLabels];
157+
// if (self.topicChangedBlock) {
158+
// self.topicChangedBlock();
159+
// }
160+
// [self.navigationController popViewControllerAnimated:YES];
161+
// }
162+
// }];
163+
// } else {
157164
if (self.topicChangedBlock) {
158165
self.topicChangedBlock();
159166
}
160167
[self.navigationController popViewControllerAnimated:YES];
161-
}
168+
//}
162169
}
163170

164171
- (void)addBtnClick:(UIButton *)sender
@@ -265,15 +272,40 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
265272
}
266273
}
267274
if (add) {
268-
[_tempArray addObject:lbl];
269-
self.navigationItem.rightBarButtonItem.enabled = YES;
275+
if (_isSaveChange) {
276+
__weak typeof(self) weakSelf = self;
277+
[[Coding_NetAPIManager sharedManager] request_ProjectTopic_AddLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
278+
if (!error) {
279+
[_tempArray addObject:lbl];
280+
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
281+
} else {
282+
cell.selectBtn.selected = FALSE;
283+
}
284+
}];
285+
[_tempArray addObject:lbl];
286+
self.navigationItem.rightBarButtonItem.enabled = YES;
287+
} else {
288+
[_tempArray addObject:lbl];
289+
self.navigationItem.rightBarButtonItem.enabled = YES;
290+
}
270291
}
271292
} else {
272293
for (ProjectTopicLabel *tempLbl in _tempArray) {
273294
if ([tempLbl.id integerValue] == [lbl.id integerValue]) {
274-
[_tempArray removeObject:tempLbl];
275-
self.navigationItem.rightBarButtonItem.enabled = YES;
276-
295+
if (_isSaveChange) {
296+
__weak typeof(self) weakSelf = self;
297+
[[Coding_NetAPIManager sharedManager] request_ProjectTopic_DelLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
298+
if (!error) {
299+
[_tempArray removeObject:tempLbl];
300+
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
301+
} else {
302+
cell.selectBtn.selected = TRUE;
303+
}
304+
}];
305+
} else {
306+
[_tempArray removeObject:tempLbl];
307+
self.navigationItem.rightBarButtonItem.enabled = YES;
308+
}
277309
break;
278310
}
279311
}

Coding_iOS/Models/ProjectTopic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- (NSString *)toTopicPath;
4444

4545
- (NSDictionary *)toEditParams;
46+
- (NSDictionary *)toLabelParams;
4647

4748
- (NSString *)toAddTopicPath;
4849
- (NSDictionary *)toAddTopicParams;

Coding_iOS/Models/ProjectTopic.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ - (NSDictionary *)toEditParams
8181
@"label" : tempAry};
8282
}
8383

84+
- (NSDictionary *)toLabelParams
85+
{
86+
NSMutableArray *tempAry = [NSMutableArray arrayWithCapacity:_mdLabels.count];
87+
for (ProjectTopicLabel *lbl in _mdLabels) {
88+
[tempAry addObject:lbl.id];
89+
}
90+
return @{@"label" : tempAry};
91+
}
92+
8493
- (NSString *)toAddTopicPath
8594
{
8695
return [NSString stringWithFormat:@"api/project/%d/topic?parent=0", [self.project_id intValue]];

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696

9797
- (void)request_ProjectTopic_Count_WithPath:(NSString *)path
9898
andBlock:(void (^)(id data, NSError *error))block;
99+
- (void)request_ProjectTopic_AddLabel_WithPath:(NSString *)path
100+
andBlock:(void (^)(id data, NSError *error))block;
101+
- (void)request_ProjectTopic_DelLabel_WithPath:(NSString *)path
102+
andBlock:(void (^)(id data, NSError *error))block;
99103

100104
// Topic Label
101105
- (void)request_ProjectTopicLabel_WithPath:(NSString *)path

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,23 @@ - (void)request_ProjectTopic_WithObj:(ProjectTopic *)proTopic andBlock:(void (^)
802802
}
803803
}];
804804
}
805-
- (void)request_ModifyProjectTpoic:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block{
805+
- (void)request_ModifyProjectTpoicLabel:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block
806+
{
807+
[MobClick event:kUmeng_Event_Request label:@"项目讨论详情_修改标签"];
808+
proTopic.isTopicEditLoading = YES;
809+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[proTopic toTopicPath] withParams:[proTopic toLabelParams] withMethodType:Put andBlock:^(id data, NSError *error) {
810+
proTopic.isTopicEditLoading = NO;
811+
if (data) {
812+
id resultData = [data valueForKeyPath:@"data"];
813+
ProjectTopic *resultT = [NSObject objectOfClass:@"ProjectTopic" fromJSON:resultData];
814+
block(resultT, nil);
815+
} else {
816+
block(nil, error);
817+
}
818+
}];
819+
}
820+
- (void)request_ModifyProjectTpoic:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block
821+
{
806822
[MobClick event:kUmeng_Event_Request label:@"项目讨论详情_提交编辑"];
807823
proTopic.isTopicEditLoading = YES;
808824
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[proTopic toTopicPath] withParams:[proTopic toEditParams] withMethodType:Put andBlock:^(id data, NSError *error) {
@@ -889,6 +905,40 @@ - (void)request_ProjectTopic_Count_WithPath:(NSString *)path
889905
}];
890906
}
891907

908+
- (void)request_ProjectTopic_AddLabel_WithPath:(NSString *)path
909+
andBlock:(void (^)(id data, NSError *error))block
910+
{
911+
[MobClick event:kUmeng_Event_Request label:@"项目讨论增加标签"];
912+
913+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path
914+
withParams:nil
915+
withMethodType:Post
916+
andBlock:^(id data, NSError *error) {
917+
if (data) {
918+
block(nil, nil);
919+
} else {
920+
block(nil, error);
921+
}
922+
}];
923+
}
924+
925+
- (void)request_ProjectTopic_DelLabel_WithPath:(NSString *)path
926+
andBlock:(void (^)(id data, NSError *error))block
927+
{
928+
[MobClick event:kUmeng_Event_Request label:@"项目讨论删除标签"];
929+
930+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path
931+
withParams:nil
932+
withMethodType:Delete
933+
andBlock:^(id data, NSError *error) {
934+
if (data) {
935+
block(nil, nil);
936+
} else {
937+
block(nil, error);
938+
}
939+
}];
940+
}
941+
892942
#pragma mark - Topic Label
893943
- (void)request_ProjectTopicLabel_WithPath:(NSString *)path
894944
andBlock:(void (^)(id data, NSError *error))block
@@ -927,7 +977,7 @@ - (void)request_ProjectTopicLabel_Add_WithPath:(NSString *)path
927977
withParams:params
928978
andBlock:(void (^)(id data, NSError *error))block
929979
{
930-
[MobClick event:kUmeng_Event_Request label:@"项目讨论添加标签"];
980+
[MobClick event:kUmeng_Event_Request label:@"添加项目讨论标签"];
931981
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path
932982
withParams:params
933983
withMethodType:Post

Coding_iOS/Vendor/XTSegmentControl/XTSegmentControl.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ - (id)initWithFrame:(CGRect)frame title:(NSString *)title type:(XTSegmentControl
6262
{
6363
_titleLabel = ({
6464
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
65-
label.font = [UIFont systemFontOfSize:XTSegmentControlItemFont];
65+
label.font = [UIFont systemFontOfSize:XTSegmentControlItemFont - 2];
6666
label.textAlignment = NSTextAlignmentCenter;
6767
label.text = title;
6868
label.textColor = [UIColor colorWithHexString:@"0x222222"];
@@ -339,7 +339,7 @@ - (void)initItemsWithTitleArray:(NSArray *)titleArray withIcon:(BOOL)isIcon
339339
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(
340340
CGRectGetMinX(rect),
341341
(CGRectGetHeight(rect) - 14) * 0.5,
342-
0.6,
342+
1,
343343
14)];
344344
lineView.backgroundColor = [UIColor colorWithHexString:@"0xdddddd"];
345345
[self addSubview:lineView];

Coding_iOS/Views/Cell/TopicContentCell.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ @interface TopicContentCell () <UIWebViewDelegate>
2525

2626
@property (strong, nonatomic) ProjectTopicLabelView *labelView;
2727
@property (strong, nonatomic) UIButton *labelAddBtn;
28+
@property (strong, nonatomic) UIView *lineView;
2829

2930
@end
3031

@@ -42,7 +43,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4243
[_userIconView doCircleFrame];
4344
[self.contentView addSubview:_userIconView];
4445
}
45-
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth;
46+
CGFloat curWidth = kScreen_Width - 2 * kPaddingLeftWidth;
4647
if (!_titleLabel) {
4748
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 15, curWidth, 30)];
4849
_titleLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
@@ -62,7 +63,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
6263
[_labelAddBtn addTarget:self action:@selector(addtitleBtnClick) forControlEvents:UIControlEventTouchUpInside];
6364
[self.contentView addSubview:_labelAddBtn];
6465
}
65-
curWidth = kScreen_Width - 2*kPaddingLeftWidth;
66+
if (!_lineView) {
67+
_lineView = [[UIView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, curWidth, 1)];
68+
_lineView.backgroundColor = kColorTableSectionBg;
69+
[self.contentView addSubview:_lineView];
70+
}
6671
if (!self.webContentView) {
6772
self.webContentView = [[UIWebView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, curWidth, 1)];
6873
self.webContentView.delegate = self;
@@ -146,10 +151,13 @@ - (void)setCurTopic:(ProjectTopic *)curTopic
146151
[_labelView setY:curBottomY];
147152
[_labelView setHeight:_labelView.labelH];
148153
//_labelAddBtn.hidden = [_curTopic canEdit] ? FALSE : TRUE;
154+
155+
curBottomY += _labelView.labelH + 12;
156+
[_lineView setY:curBottomY];
149157

150-
curBottomY += _labelView.labelH + 5;
151158

152159
// 讨论的内容
160+
curBottomY += 12;
153161
[self.webContentView setY:curBottomY];
154162
[self.activityIndicator setCenter:CGPointMake(self.webContentView.center.x, curBottomY + 10)];
155163
[self.webContentView setHeight:_curTopic.contentHeight];
@@ -230,7 +238,7 @@ + (CGFloat)cellHeightWithObj:(id)obj
230238
}
231239
labelH = y + 20;
232240
}
233-
cellHeight += labelH + 5;
241+
cellHeight += labelH + 24;
234242
cellHeight += topic.contentHeight;
235243
cellHeight += 25 + 25 + 5;
236244
}

Coding_iOS/Views/Cell/TopicPreviewCell.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ @interface TopicPreviewCell () <UIWebViewDelegate>
2424

2525
@property (strong, nonatomic) ProjectTopicLabelView *labelView;
2626
@property (strong, nonatomic) UIButton *labelAddBtn;
27+
@property (strong, nonatomic) UIView *lineView;
2728

2829
@end
2930

@@ -41,7 +42,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4142
[_userIconView doCircleFrame];
4243
[self.contentView addSubview:_userIconView];
4344
}
44-
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth;
45+
CGFloat curWidth = kScreen_Width - 2 * kPaddingLeftWidth;
4546
if (!_titleLabel) {
4647
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 15, curWidth, 30)];
4748
_titleLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
@@ -61,7 +62,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
6162
[_labelAddBtn addTarget:self action:@selector(addtitleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
6263
[self.contentView addSubview:_labelAddBtn];
6364
}
64-
curWidth = kScreen_Width - 2*kPaddingLeftWidth;
65+
if (!_lineView) {
66+
_lineView = [[UIView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, curWidth, 1)];
67+
_lineView.backgroundColor = kColorTableSectionBg;
68+
[self.contentView addSubview:_lineView];
69+
}
6570
if (!self.webContentView) {
6671
self.webContentView = [[UIWebView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, curWidth, 1)];
6772
self.webContentView.delegate = self;
@@ -144,9 +149,11 @@ - (void)setCurTopic:(ProjectTopic *)curTopic
144149
[_labelView setY:curBottomY];
145150
[_labelView setHeight:_labelView.labelH];
146151

147-
curBottomY += _labelView.labelH + 5;
148-
152+
curBottomY += _labelView.labelH + 12;
153+
[_lineView setY:curBottomY];
154+
149155
// 讨论的内容
156+
curBottomY += 12;
150157
[self.webContentView setY:curBottomY];
151158
[self.activityIndicator setCenter:CGPointMake(self.webContentView.center.x, curBottomY + 10)];
152159
[self.webContentView setHeight:_curTopic.contentHeight];
@@ -229,7 +236,7 @@ + (CGFloat)cellHeightWithObjWithLabel:(id)obj
229236
}
230237
labelH = y + 20;
231238
}
232-
cellHeight += labelH + 5;
239+
cellHeight += labelH + 24;
233240
cellHeight += topic.contentHeight + 5;
234241
}
235242
return cellHeight;

0 commit comments

Comments
 (0)