Skip to content

Commit 9a1a2ea

Browse files
committed
done
1 parent d26be29 commit 9a1a2ea

25 files changed

Lines changed: 309 additions & 74 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 28 additions & 12 deletions
Large diffs are not rendered by default.

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define kCellIdentifier_TaskComment @"TaskCommentCell"
1212
#define kCellIdentifier_TaskCommentTop @"TaskCommentTopCell"
1313
#define kCellIdentifier_TaskCommentBlank @"TaskCommentBlankCell"
14+
#define kCellIdentifier_TaskDescription @"TaskDescriptionCell"
1415

1516
#import "EditTaskViewController.h"
1617
#import "TPKeyboardAvoidingTableView.h"
@@ -24,6 +25,7 @@
2425
#import "TaskCommentTopCell.h"
2526
#import "TaskCommentBlankCell.h"
2627
#import "ActionSheetDatePicker.h"
28+
#import "TaskDescriptionCell.h"
2729

2830
@interface EditTaskViewController ()
2931
@property (strong, nonatomic) UITableView *myTableView;
@@ -86,6 +88,7 @@ - (void)loadView{
8688
[tableView registerClass:[TaskCommentCell class] forCellReuseIdentifier:kCellIdentifier_TaskComment];
8789
[tableView registerClass:[TaskCommentBlankCell class] forCellReuseIdentifier:kCellIdentifier_TaskCommentBlank];
8890
[tableView registerClass:[TaskCommentTopCell class] forCellReuseIdentifier:kCellIdentifier_TaskCommentTop];
91+
[tableView registerClass:[TaskDescriptionCell class] forCellReuseIdentifier:kCellIdentifier_TaskDescription];
8992
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
9093
tableView;
9194
});
@@ -109,7 +112,7 @@ - (void)loadView{
109112
case TaskHandleTypeEdit:{
110113
self.title = @"任务详情";
111114
_myCopyTask = [Task taskWithTask:_myTask];
112-
if (_myCopyTask.needRefreshDetail) {
115+
if (_myCopyTask.needRefreshDetail || _myCopyTask.has_description.boolValue) {
113116
[self queryToRefreshTaskDetail];
114117
}else{
115118
_myMsgInputView.curProject = _myCopyTask.project;
@@ -172,7 +175,7 @@ - (void)queryToRefreshCommentList{
172175
[[Coding_NetAPIManager sharedManager] request_CommentListOfTask:_myCopyTask andBlock:^(id data, NSError *error) {
173176
if (data) {
174177
weakSelf.myCopyTask.commentList = data;
175-
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationAutomatic];
178+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationAutomatic];
176179
};
177180
}];
178181
}
@@ -184,7 +187,7 @@ - (void)queryToRefreshTaskDetail{
184187
weakSelf.myTask = data;
185188
weakSelf.myCopyTask = [Task taskWithTask:weakSelf.myTask];
186189
weakSelf.myMsgInputView.curProject = weakSelf.myCopyTask.project;
187-
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationAutomatic];
190+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)] withRowAnimation:UITableViewRowAnimationAutomatic];
188191
[weakSelf queryToRefreshCommentList];
189192
}
190193
}];
@@ -285,18 +288,16 @@ - (void)deleteComment:(TaskComment *)comment{
285288
}
286289
#pragma mark Table M
287290
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
288-
return self.myTask.handleType == TaskEditTypeAdd? 2:3;
291+
return (self.myCopyTask.handleType == TaskEditTypeAdd)? 2: 4;
289292
}
290293
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
291294
NSInteger row = 0;
292295
if (section == 0) {
293296
row = 1;
297+
}else if (section == 2){
298+
row = 1;
294299
}else if (section == 1){
295-
if (_myTask.handleType == TaskHandleTypeAdd) {
296-
row = 3;
297-
}else{
298-
row = 4;
299-
}
300+
row = (self.myCopyTask.handleType == TaskHandleTypeAdd)? 3: 4;
300301
}else{
301302
if ([self hasComment]) {
302303
row = self.myCopyTask.commentList.count +1;
@@ -340,6 +341,16 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
340341
}
341342
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:20];
342343
return cell;
344+
}else if (indexPath.section == 2){
345+
TaskDescriptionCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskDescription forIndexPath:indexPath];
346+
if (_myCopyTask.has_description && !_myCopyTask.has_description.boolValue) {
347+
//没有描述
348+
[cell setDescriptionStr:@""];
349+
}else{
350+
[cell setDescriptionStr:_myCopyTask.task_description.description_mine];
351+
}
352+
[cell addLineUp:YES andDown:NO andColor:tableView.separatorColor];
353+
return cell;
343354
}else if (indexPath.section == 1){
344355
LeftImage_LRTextCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_LeftImage_LRText forIndexPath:indexPath];
345356
[cell setObj:_myCopyTask type:indexPath.row];
@@ -349,7 +360,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
349360
if (indexPath.row == 0) {
350361
TaskCommentTopCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskCommentTop forIndexPath:indexPath];
351362
cell.commentNumStrLabel.text = [NSString stringWithFormat:@"%d 条评论", _myCopyTask.comments.intValue];
352-
[cell addLineUp:YES andDown:NO andColor:tableView.separatorColor];
353363
return cell;
354364
}else{
355365
if ([self hasComment]) {
@@ -372,6 +382,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
372382
CGFloat cellHeight = 0;
373383
if (indexPath.section == 0) {
374384
cellHeight = [TaskContentCell cellHeightWithObj:_myCopyTask];
385+
}else if (indexPath.section == 2){
386+
cellHeight = [TaskDescriptionCell cellHeight];
375387
}else if (indexPath.section == 1){
376388
cellHeight = [LeftImage_LRTextCell cellHeight];
377389
}else{
@@ -391,6 +403,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
391403
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
392404
if (section == 0) {
393405
return 30.0;
406+
}else if (section == 3){
407+
return 1.0;
394408
}else{
395409
return 20.0;
396410
}
@@ -405,16 +419,27 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
405419
headerView.backgroundColor = [UIColor colorWithHexString:@"0xe5e5e5"];
406420
if (section == 0) {
407421
[headerView setHeight:30.0];
422+
}else if (section == 3){
423+
headerView.backgroundColor = [UIColor whiteColor];
424+
[headerView setHeight:0.0];
408425
}else{
409426
[headerView setHeight:20];
410427
}
411428
return headerView;
412429
}
413430

431+
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
432+
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 1)];
433+
footerView.backgroundColor = (section == 2)? [UIColor whiteColor]: [UIColor clearColor];
434+
return footerView;
435+
}
436+
414437
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
415438
[tableView deselectRowAtIndexPath:indexPath animated:YES];
416439
ESWeakSelf;
417-
if (indexPath.section == 1) {
440+
if (indexPath.section == 2) {
441+
// [self showHudTipStr:@"现在还不能添加或编辑描述内容"];
442+
}else if (indexPath.section == 1){
418443
if (indexPath.row == LeftImage_LRTextCellTypeTaskOwner) {
419444
ProjectMemberListViewController *vc = [[ProjectMemberListViewController alloc] init];
420445
[vc setFrame:self.view.bounds project:_myCopyTask.project type:ProMemTypeTaskOwner refreshBlock:nil selectBlock:^(ProjectMember *member) {
@@ -458,7 +483,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
458483
}];
459484
[self.navigationController pushViewController:vc animated:YES];
460485
}
461-
}else if (indexPath.section == 2){
486+
}else if (indexPath.section == 3){
462487
if (indexPath.row > 0 && [self hasComment]) {
463488
TaskComment *curComment = [_myCopyTask.commentList objectAtIndex:indexPath.row-1];
464489
[self doCommentToComment:curComment sender:[tableView cellForRowAtIndexPath:indexPath]];
-238 Bytes
Loading

Coding_iOS/Images/[email protected]

100755100644
8 Bytes
Loading
1.43 KB
Loading

Coding_iOS/Images/[email protected]

100755100644
11 Bytes
Loading

Coding_iOS/Models/CodingTip.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ @implementation CodingTip
1212

1313
- (void)setContent:(NSString *)content{
1414
if (_content != content) {
15-
_htmlMedia = [HtmlMedia htmlMediaWithString:content trimWhitespaceAndNewline:YES];
15+
_htmlMedia = [HtmlMedia htmlMediaWithString:content trimWhitespaceAndNewline:YES showType:MediaShowTypeImageAndMonkey];
1616
_content = _htmlMedia.contentDisplay;
1717
}
1818
}

Coding_iOS/Models/Comment.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@implementation Comment
1212
- (void)setContent:(NSString *)content{
1313
if (_content != content) {
14-
_htmlMedia = [HtmlMedia htmlMediaWithString:content trimWhitespaceAndNewline:YES];
14+
_htmlMedia = [HtmlMedia htmlMediaWithString:content trimWhitespaceAndNewline:YES showType:MediaShowTypeAll];
1515
_content = _htmlMedia.contentDisplay;
1616
}
1717
}

Coding_iOS/Models/HtmlMedia.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ typedef NS_ENUM(NSInteger, HtmlMediaItemType) {
2020
HtmlMediaItemType_CustomLink
2121
};
2222

23+
typedef NS_ENUM(NSInteger, MediaShowType) {
24+
MediaShowTypeNone = 1,
25+
MediaShowTypeCode = 2,
26+
MediaShowTypeImage = 3,
27+
MediaShowTypeMonkey = 5,
28+
MediaShowTypeImageAndMonkey = 15,
29+
MediaShowTypeAll = 30
30+
};
31+
2332
@class HtmlMediaItem;
2433

2534
@interface HtmlMedia : NSObject
@@ -28,10 +37,12 @@ typedef NS_ENUM(NSInteger, HtmlMediaItemType) {
2837
@property (readwrite, nonatomic, strong) NSMutableArray *mediaItems;
2938
@property (strong, nonatomic) NSArray *imageItems;
3039

31-
+ (instancetype)htmlMediaWithString:(NSString *)htmlString;
32-
+ (instancetype)htmlMediaWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim;
33-
- (instancetype)initWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim;
40+
+ (instancetype)htmlMediaWithString:(NSString *)htmlString showType:(MediaShowType)showType;
41+
+ (instancetype)htmlMediaWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim showType:(MediaShowType)showType;
42+
- (instancetype)initWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim showType:(MediaShowType)showType;
43+
3444

45+
//在curString的末尾添加一个media元素
3546
+ (void)addMediaItem:(HtmlMediaItem *)curItem toString:(NSMutableString *)curString andMediaItems:(NSMutableArray *)itemList;
3647
+ (void)addLinkStr:(NSString *)linkStr type:(HtmlMediaItemType)type toString:(NSMutableString *)curString andMediaItems:(NSMutableArray *)itemList;
3748
+ (void)addMediaItemUser:(User *)curUser toString:(NSMutableString *)curString andMediaItems:(NSMutableArray *)itemList;
@@ -42,6 +53,7 @@ typedef NS_ENUM(NSInteger, HtmlMediaItemType) {
4253

4354
@interface HtmlMediaItem : NSObject
4455
@property (assign, nonatomic) HtmlMediaItemType type;
56+
@property (assign, nonatomic) MediaShowType showType;
4557
@property (readwrite, nonatomic, strong) NSString *src, *title, *href, *name, *code, *linkStr;
4658
@property (assign, nonatomic) NSRange range;
4759

Coding_iOS/Models/HtmlMedia.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "HtmlMedia.h"
1010
@implementation HtmlMedia
11-
- (instancetype)initWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim{
11+
- (instancetype)initWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim showType:(MediaShowType)showType{
1212
self = [super init];
1313
if (self) {
1414
_contentOrigional = htmlString;
@@ -30,14 +30,14 @@ - (instancetype)initWithString:(NSString *)htmlString trimWhitespaceAndNewline:(
3030
NSData *data=[htmlString dataUsingEncoding:NSUTF8StringEncoding];
3131
TFHpple *doc = [TFHpple hppleWithHTMLData:data];
3232
TFHppleElement *rootElement = [doc peekAtSearchWithXPathQuery:@"//body"];
33-
[self analyzeHtmlElement:rootElement];
33+
[self analyzeHtmlElement:rootElement withShowType:showType];
3434
_contentDisplay = [NSMutableString stringWithString:[_contentDisplay stringByTrimmingRightCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
3535
_imageItems = [_mediaItems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type == %d OR type == %d", HtmlMediaItemType_Image, HtmlMediaItemType_EmotionMonkey]];
3636
}
3737
return self;
3838
}
3939

40-
- (void)analyzeHtmlElement:(TFHppleElement* )element{
40+
- (void)analyzeHtmlElement:(TFHppleElement* )element withShowType:(MediaShowType)showType{
4141
HtmlMediaItem *item = nil;
4242
if (element.isTextNode) {
4343
[_contentDisplay appendString:element.content];
@@ -103,6 +103,7 @@ - (void)analyzeHtmlElement:(TFHppleElement* )element{
103103
}
104104
}
105105
if (item) {
106+
item.showType = showType;
106107
item.range = NSMakeRange(_contentDisplay.length, item.displayStr.length);
107108
[_mediaItems addObject:item];
108109
[_contentDisplay appendString:item.displayStr];
@@ -111,17 +112,17 @@ - (void)analyzeHtmlElement:(TFHppleElement* )element{
111112

112113
if (element.hasChildren) {
113114
for (TFHppleElement *child in [element children]) {
114-
[self analyzeHtmlElement:child];
115+
[self analyzeHtmlElement:child withShowType:showType];
115116
}
116117
}
117118
}
118119

119-
+ (instancetype)htmlMediaWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim{
120-
return [[[self class] alloc] initWithString:htmlString trimWhitespaceAndNewline:isTrim];
120+
+ (instancetype)htmlMediaWithString:(NSString *)htmlString trimWhitespaceAndNewline:(BOOL)isTrim showType:(MediaShowType)showType{
121+
return [[[self class] alloc] initWithString:htmlString trimWhitespaceAndNewline:isTrim showType:showType];
121122
}
122123

123-
+ (instancetype)htmlMediaWithString:(NSString *)htmlString{
124-
return [[[self class] alloc] initWithString:htmlString trimWhitespaceAndNewline:NO];
124+
+ (instancetype)htmlMediaWithString:(NSString *)htmlString showType:(MediaShowType)showType{
125+
return [[[self class] alloc] initWithString:htmlString trimWhitespaceAndNewline:NO showType:showType];
125126
}
126127

127128
+ (void)addMediaItem:(HtmlMediaItem *)curItem toString:(NSMutableString *)curString andMediaItems:(NSMutableArray *)itemList{
@@ -170,16 +171,16 @@ - (NSString *)displayStr{
170171
NSString *displayStr;
171172
switch (_type) {
172173
case HtmlMediaItemType_Image:
173-
displayStr = @"";
174+
displayStr = (_showType % MediaShowTypeImage == 0)? @"[图片]" :@"";
174175
break;
175176
case HtmlMediaItemType_Code:
176-
displayStr = @"[code]";
177+
displayStr = (_showType % MediaShowTypeCode == 0)? _code :@"[code]";
177178
break;
178179
case HtmlMediaItemType_EmotionEmoji:
179180
displayStr = [NSString stringWithFormat:@"[%@]", _title];
180181
break;
181182
case HtmlMediaItemType_EmotionMonkey:
182-
displayStr = @"";
183+
displayStr = (_showType % MediaShowTypeMonkey == 0)? @"洋葱猴": @"";
183184
break;
184185
case HtmlMediaItemType_ATUser:
185186
displayStr = _name;

0 commit comments

Comments
 (0)