Skip to content

Commit 406114f

Browse files
committed
任务描述。
空白图片。
1 parent 92ee9d0 commit 406114f

20 files changed

Lines changed: 184 additions & 442 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 18 additions & 34 deletions
Large diffs are not rendered by default.

Coding_iOS/Controllers/ConversationViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ - (void)refreshLoadMore:(BOOL)willLoadMore{
159159
[weakSelf.myTableView setContentOffset:CGPointMake(0, (curContentHeight -_preContentHeight)+weakSelf.myTableView.contentOffset.y)];
160160
}
161161
}
162-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
162+
[weakSelf.view configBlankPage:EaseBlankPageTypePrivateMsg hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
163163
[weakSelf refreshLoadMore:NO];
164164
}];
165165
}];
@@ -323,7 +323,7 @@ - (void)sendPrivateMessageWithMsg:(PrivateMessage *)nextMsg{
323323
} progerssBlock:^(CGFloat progressValue) {
324324
DebugLog(@"\n%.2f", progressValue);
325325
}];
326-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:NO reloadButtonBlock:^(id sender) {
326+
[weakSelf.view configBlankPage:EaseBlankPageTypePrivateMsg hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:NO reloadButtonBlock:^(id sender) {
327327
[weakSelf refreshLoadMore:NO];
328328
}];
329329
}

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#import "TaskCommentTopCell.h"
2626
#import "TaskCommentBlankCell.h"
2727
#import "ActionSheetDatePicker.h"
28-
#import "TaskDescriptionCell.h"
2928
#import "TaskDescriptionViewController.h"
3029

3130
@interface EditTaskViewController ()
@@ -69,7 +68,7 @@ - (void)viewDidLoad
6968
_myMsgInputView.isAlwaysShow = YES;
7069
_myMsgInputView.delegate = self;
7170

72-
if (_myCopyTask.needRefreshDetail) {// || _myCopyTask.has_description.boolValue
71+
if (_myCopyTask.needRefreshDetail || _myCopyTask.has_description.boolValue) {
7372
[self queryToRefreshTaskDetail];
7473
}else{
7574
_myMsgInputView.curProject = _myCopyTask.project;
@@ -92,7 +91,6 @@ - (void)viewDidLoad
9291
[tableView registerClass:[TaskCommentCell class] forCellReuseIdentifier:kCellIdentifier_TaskComment];
9392
[tableView registerClass:[TaskCommentBlankCell class] forCellReuseIdentifier:kCellIdentifier_TaskCommentBlank];
9493
[tableView registerClass:[TaskCommentTopCell class] forCellReuseIdentifier:kCellIdentifier_TaskCommentTop];
95-
[tableView registerClass:[TaskDescriptionCell class] forCellReuseIdentifier:kCellIdentifier_TaskDescription];
9694
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
9795
[self.view addSubview:tableView];
9896
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -192,7 +190,7 @@ - (void)queryToRefreshTaskDetail{
192190
weakSelf.myMsgInputView.commentOfId = weakSelf.myCopyTask.id;
193191
weakSelf.myMsgInputView.toUser = nil;
194192

195-
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationAutomatic];
193+
[weakSelf.myTableView reloadData];
196194
[weakSelf queryToRefreshCommentList];
197195
}
198196
}];
@@ -299,8 +297,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
299297
NSInteger row = 0;
300298
if (section == 0) {
301299
row = 1;
302-
// }else if (section == 2){
303-
// row = 1;
304300
}else if (section == 1){
305301
row = (self.myCopyTask.handleType == TaskHandleTypeAdd)? 3: 4;
306302
}else{
@@ -324,32 +320,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
324320
cell.textViewBecomeFirstResponderBlock = ^(){
325321
[weakSelf.myMsgInputView isAndResignFirstResponder];
326322
};
327-
if (_myCopyTask.handleType == TaskHandleTypeAdd) {
328-
cell.deleteBtnClickedBlock = nil;
329-
}else{
330-
cell.deleteBtnClickedBlock = ^(Task *toDelete){
331-
[weakSelf.view endEditing:YES];
332-
UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle:@"删除此任务" buttonTitles:nil destructiveTitle:@"确认删除" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
333-
if (index == 0) {
334-
[weakSelf deleteTask:toDelete];
335-
}
336-
}];
337-
[actionSheet showInView:kKeyWindow];
338-
};
339-
}
323+
cell.deleteBtnClickedBlock = ^(Task *toDelete){
324+
[weakSelf.view endEditing:YES];
325+
UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle:@"删除此任务" buttonTitles:nil destructiveTitle:@"确认删除" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
326+
if (index == 0) {
327+
[weakSelf deleteTask:toDelete];
328+
}
329+
}];
330+
[actionSheet showInView:kKeyWindow];
331+
};
332+
cell.descriptionBtnClickedBlock = ^(Task *toDelete){
333+
[weakSelf goToDescriptionVC];
334+
};
335+
340336
cell.backgroundColor = kColorTableBG;
341337
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:20];
342338
return cell;
343-
// }else if (indexPath.section == 2){
344-
// TaskDescriptionCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskDescription forIndexPath:indexPath];
345-
// if (_myCopyTask.has_description && !_myCopyTask.has_description.boolValue) {
346-
// //没有描述
347-
// [cell setDescriptionStr:@""];
348-
// }else{
349-
// [cell setDescriptionStr:_myCopyTask.task_description.description_mine];
350-
// }
351-
// [cell addLineUp:YES andDown:NO andColor:tableView.separatorColor];
352-
// return cell;
353339
}else if (indexPath.section == 1){
354340
LeftImage_LRTextCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_LeftImage_LRText forIndexPath:indexPath];
355341
[cell setObj:_myCopyTask type:indexPath.row];
@@ -386,8 +372,6 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
386372
CGFloat cellHeight = 0;
387373
if (indexPath.section == 0) {
388374
cellHeight = [TaskContentCell cellHeightWithObj:_myCopyTask];
389-
// }else if (indexPath.section == 2){
390-
// cellHeight = [TaskDescriptionCell cellHeight];
391375
}else if (indexPath.section == 1){
392376
cellHeight = [LeftImage_LRTextCell cellHeight];
393377
}else{
@@ -432,26 +416,11 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
432416
return headerView;
433417
}
434418

435-
//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
436-
// UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 1)];
437-
// footerView.backgroundColor = (section == 2)? [UIColor whiteColor]: [UIColor clearColor];
438-
// return footerView;
439-
//}
440-
441419
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
442420
[tableView deselectRowAtIndexPath:indexPath animated:YES];
443421
ESWeakSelf;
444422
if (indexPath.section == 0) {
445423

446-
// }else if (indexPath.section == 2) {
447-
// TaskDescriptionViewController *vc = [[TaskDescriptionViewController alloc] init];
448-
// vc.markdown = _myCopyTask.task_description.markdown;
449-
// vc.savedNewMDBlock = ^(NSString *mdStr, NSString *mdHtmlStr){
450-
// ESStrongSelf;
451-
// _self.myCopyTask.task_description.markdown = mdStr;
452-
// _self.myCopyTask.task_description.description_mine = mdHtmlStr;
453-
// };
454-
// [self.navigationController pushViewController:vc animated:YES];
455424
}else if (indexPath.section == 1){
456425
if (indexPath.row == LeftImage_LRTextCellTypeTaskOwner) {
457426
ProjectMemberListViewController *vc = [[ProjectMemberListViewController alloc] init];
@@ -502,7 +471,23 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
502471
[self doCommentToComment:curComment sender:[tableView cellForRowAtIndexPath:indexPath]];
503472
}
504473
}
474+
}
505475

476+
- (void)goToDescriptionVC{
477+
if (!_myCopyTask.task_description) {
478+
_myCopyTask.task_description = [Task_Description defaultDescription];
479+
}
480+
ESWeakSelf;
481+
TaskDescriptionViewController *vc = [[TaskDescriptionViewController alloc] init];
482+
vc.markdown = _myCopyTask.task_description.markdown;
483+
vc.savedNewMDBlock = ^(NSString *mdStr, NSString *mdHtmlStr){
484+
ESStrongSelf;
485+
_self.myCopyTask.has_description = [NSNumber numberWithBool:(mdStr.length > 0)];
486+
_self.myCopyTask.task_description.markdown = mdStr;
487+
_self.myCopyTask.task_description.description_mine = mdHtmlStr;
488+
[_self.myTableView reloadData];
489+
};
490+
[self.navigationController pushViewController:vc animated:YES];
506491
}
507492

508493
- (void)doCommentToComment:(TaskComment *)toComment sender:(id)sender{

Coding_iOS/Controllers/TaskDescriptionViewController.m

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "TaskDescriptionViewController.h"
1010
#import "Coding_NetAPIManager.h"
1111
#import "WebContentManager.h"
12-
#import <MMMarkdown/MMMarkdown.h>
12+
#import "EaseMarkdownTextView.h"
1313

1414
@interface TaskDescriptionViewController ()<UIWebViewDelegate>
1515
@property (strong, nonatomic) UISegmentedControl *segmentedControl;
@@ -18,7 +18,7 @@ @interface TaskDescriptionViewController ()<UIWebViewDelegate>
1818
@property (strong, nonatomic) UIWebView *preview;
1919
@property (strong, nonatomic) UIActivityIndicatorView *activityIndicator;
2020

21-
@property (strong, nonatomic) UITextView *editView;
21+
@property (strong, nonatomic) EaseMarkdownTextView *editView;
2222
@end
2323

2424
@implementation TaskDescriptionViewController
@@ -51,6 +51,14 @@ - (void)viewDidLoad {
5151

5252
[self.navigationItem setRightBarButtonItem:[UIBarButtonItem itemWithBtnTitle:@"保存" target:self action:@selector(saveBtnClicked)] animated:YES];
5353
self.navigationItem.rightBarButtonItem.enabled = NO;
54+
55+
[[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardWillChangeFrameNotification object:nil] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification *aNotification) {
56+
if (self.editView) {
57+
NSDictionary* userInfo = [aNotification userInfo];
58+
CGRect keyboardEndFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
59+
self.editView.contentInset = UIEdgeInsetsMake(0, 0, CGRectGetHeight(keyboardEndFrame), 0);
60+
}
61+
}];
5462
}
5563

5664
- (void)didReceiveMemoryWarning {
@@ -93,23 +101,19 @@ - (void)setCurIndex:(NSInteger)curIndex{
93101

94102
- (void)loadEditView{
95103
if (!_editView) {
96-
_editView = [[UITextView alloc] initWithFrame:self.view.bounds];
97-
_editView.backgroundColor = [UIColor clearColor];
98-
104+
_editView = [[EaseMarkdownTextView alloc] initWithFrame:self.view.bounds];
99105
_editView.textColor = [UIColor colorWithHexString:@"0x999999"];
100106
_editView.font = [UIFont systemFontOfSize:16];
101-
102107
_editView.text = _markdown;
103108
[self.view addSubview:_editView];
104109
[_editView mas_makeConstraints:^(MASConstraintMaker *make) {
105110
make.edges.equalTo(self.view);
106111
}];
107-
108112
@weakify(self);
109-
RAC(self.navigationItem.rightBarButtonItem, enabled) = [RACSignal combineLatest:@[self.editView.rac_textSignal] reduce:^id (NSString *mdStr){
113+
114+
[_editView.rac_textSignal subscribeNext:^(NSString *mdStr) {
110115
@strongify(self);
111-
BOOL saveEnabled = ![mdStr isEqualToString:self.markdown];
112-
return @(saveEnabled);
116+
self.navigationItem.rightBarButtonItem.enabled = ![mdStr isEqualToString:self.markdown];
113117
}];
114118
}
115119
_editView.hidden = NO;
@@ -147,19 +151,15 @@ - (void)loadPreview{
147151

148152
- (void)previewLoadMDData{
149153
NSString *mdStr = self.editView? self.editView.text : _markdown;
150-
NSError *error = nil;
151-
NSString *htmlStr;
152-
@try {
153-
htmlStr = [MMMarkdown HTMLStringWithMarkdown:mdStr error:&error];
154-
}
155-
@catch (NSException *exception) {
156-
htmlStr = @"加载失败!";
157-
}
158-
if (error) {
159-
htmlStr = @"加载失败!";
160-
}
161-
NSString *contentStr = [WebContentManager markdownPatternedWithContent:htmlStr];
162-
[self.preview loadHTMLString:contentStr baseURL:nil];
154+
[_activityIndicator startAnimating];
155+
156+
@weakify(self);
157+
[[Coding_NetAPIManager sharedManager] request_MDHtmlStr_WithMDStr:mdStr andBlock:^(id data, NSError *error) {
158+
@strongify(self);
159+
NSString *htmlStr = data? data : error.description;
160+
NSString *contentStr = [WebContentManager markdownPatternedWithContent:htmlStr];
161+
[self.preview loadHTMLString:contentStr baseURL:nil];
162+
}];
163163
}
164164

165165
#pragma mark UIWebViewDelegate
@@ -183,4 +183,8 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
183183
}
184184
}
185185

186+
#pragma mark UITextViewDelegate
187+
- (void)textViewDidChange:(UITextView *)textView{
188+
189+
}
186190
@end
-504 Bytes
Loading
1.12 KB
Loading
1.12 KB
Loading

Coding_iOS/Images/textBg@2x.png

-1.43 KB
Binary file not shown.

Coding_iOS/Models/Task.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ + (Task *)taskWithProject:(Project *)project{
5151
curTask.handleType = TaskHandleTypeAdd;
5252
curTask.priority = [NSNumber numberWithInt:1];
5353
curTask.content = @"";
54-
curTask.has_description = [NSNumber numberWithBool:YES];
54+
curTask.has_description = [NSNumber numberWithBool:NO];
5555
curTask.task_description = [Task_Description defaultDescription];
5656
return curTask;
5757
}
@@ -150,12 +150,12 @@ -(NSDictionary *)toUpdateParamsWithOld:(Task *)oldTask{
150150
[params setObject:self.content forKey:@"content"];
151151
}
152152
//描述
153-
if (self.has_description.boolValue) {
154-
NSString *newMD = self.task_description.markdown;
155-
if (newMD && ![newMD isEqualToString:oldTask.task_description.markdown]) {
156-
[params setObject:[newMD aliasedString] forKey:@"description"];
157-
}
153+
NSString *newMD = self.task_description.markdown;
154+
155+
if (newMD && ![newMD isEqualToString:oldTask.task_description.markdown] ) {
156+
[params setObject:[newMD aliasedString] forKey:@"description"];
158157
}
158+
159159
//执行者
160160
if (self.owner_id && self.owner_id.integerValue != oldTask.owner_id.integerValue) {
161161
[params setObject:self.owner_id forKey:@"owner_id"];

Coding_iOS/Util/OC_Category/UIView+Common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ typedef NS_ENUM(NSInteger, EaseBlankPageType)
2222
EaseBlankPageTypeTweetOther,
2323
EaseBlankPageTypeProject,
2424
EaseBlankPageTypeFileDleted,
25-
EaseBlankPageTypeFolderDleted
25+
EaseBlankPageTypeFolderDleted,
26+
EaseBlankPageTypePrivateMsg
2627
};
2728

2829
@interface UIView (Common)

0 commit comments

Comments
 (0)