Skip to content

Commit fceef6d

Browse files
committed
首页创建任务流程优化
1 parent 10efe2e commit fceef6d

5 files changed

+34
-11
lines changed

Coding_iOS/Controllers/EditTaskViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
@interface EditTaskViewController : BaseViewController<UITableViewDataSource, UITableViewDelegate, UIMessageInputViewDelegate>
1414
@property (strong, nonatomic) Task *myTask, *myCopyTask;
1515
@property (copy, nonatomic) void(^taskChangedBlock)();
16+
@property (copy, nonatomic) void(^doneBlock)(EditTaskViewController *vc);
1617
- (void)queryToRefreshTaskDetail;
1718
@end

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ - (void)doneBtnClicked{
216216
if (_taskChangedBlock) {
217217
_taskChangedBlock();
218218
}
219-
[self.navigationController popViewControllerAnimated:YES];
219+
[self handleDone];
220220
}
221221
}];
222222
}else{
@@ -232,14 +232,21 @@ - (void)doneBtnClicked{
232232
if (_taskChangedBlock) {
233233
_taskChangedBlock();
234234
}
235-
[self.navigationController popViewControllerAnimated:YES];
235+
[self handleDone];
236236
}else{
237237
[NSObject showStatusBarError:error];
238238
}
239239
}];
240240
}
241241
}
242242

243+
- (void)handleDone{
244+
if (self.doneBlock) {
245+
self.doneBlock(self);
246+
}else{
247+
[self.navigationController popViewControllerAnimated:YES];
248+
}
249+
}
243250
- (void)deleteTask:(Task *)toDelete{
244251
if (toDelete.isRequesting) {
245252
return;
@@ -460,16 +467,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
460467
LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1;
461468
if (cellType == LeftImage_LRTextCellTypeTaskProject) {
462469
ProjectToChooseListViewController *vc = [[ProjectToChooseListViewController alloc] init];
463-
vc.projectChoosedBlock = ^(Project *project){
470+
vc.projectChoosedBlock = ^(ProjectToChooseListViewController *blockChooseVC, Project *project){
464471
ESStrongSelf;
465472
_self.myCopyTask.project = project;
466473
_self.myCopyTask.owner = nil;//更换新的执行人
467474
[_self.myCopyTask.labels removeAllObjects];
468475
[_self.myTableView reloadData];
476+
[blockChooseVC.navigationController popViewControllerAnimated:YES];
469477
};
470478
[self.navigationController pushViewController:vc animated:YES];
471-
472-
NSLog(@"haimeizuo");
473479
}else if (cellType == LeftImage_LRTextCellTypeTaskOwner) {
474480
if (_myCopyTask.project == nil) {
475481
[NSObject showHudTipStr:@"需要选定所属项目先~"];

Coding_iOS/Controllers/ProjectToChooseListViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
#import "Project.h"
1111

1212
@interface ProjectToChooseListViewController : BaseViewController
13-
@property (copy, nonatomic) void(^projectChoosedBlock)(Project *project);
13+
@property (copy, nonatomic) void(^projectChoosedBlock)(ProjectToChooseListViewController *chooseVC, Project *project);
1414
@end

Coding_iOS/Controllers/ProjectToChooseListViewController.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ - (void)viewDidLoad {
2424
__weak typeof(self) weakSelf = self;
2525
ProjectListView *listView = [[ProjectListView alloc] initWithFrame:self.view.bounds projects:self.curPros block:^(Project *project) {
2626
if (weakSelf.projectChoosedBlock) {
27-
weakSelf.projectChoosedBlock(project);
27+
weakSelf.projectChoosedBlock(self, project);
2828
}
29-
[weakSelf.navigationController popViewControllerAnimated:YES];
3029
} tabBarHeight:0];
3130
[self.view addSubview:listView];
3231
[listView mas_makeConstraints:^(MASConstraintMaker *make) {

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#import "ZXScanCodeViewController.h"
3232
#import "OTPListViewController.h"
3333
#import "WebViewController.h"
34+
#import "ProjectToChooseListViewController.h"
35+
3436
@interface Project_RootViewController ()<UISearchBarDelegate, UITableViewDataSource, UITableViewDelegate>
3537
@property (strong, nonatomic) NSMutableDictionary *myProjectsDict;
3638
@property (strong, nonatomic) UISearchDisplayController *mySearchDisplayController;
@@ -376,10 +378,25 @@ - (void)goToNewProjectVC{
376378
[self.navigationController pushViewController:newProjectVC animated:YES];
377379
}
378380
- (void)goToNewTaskVC{
379-
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
380-
vc.myTask = [Task taskWithProject:nil andUser:nil];
381-
[self.navigationController pushViewController:vc animated:YES];
381+
__weak typeof(self) weakSelf = self;
382+
ProjectToChooseListViewController *chooseVC = [[ProjectToChooseListViewController alloc] init];
383+
chooseVC.projectChoosedBlock = ^(ProjectToChooseListViewController *blockChooseVC, Project *project){
384+
[weakSelf goToNewTaskFromVC:blockChooseVC withPro:project];
385+
};
386+
[self.navigationController pushViewController:chooseVC animated:YES];
387+
}
388+
389+
- (void)goToNewTaskFromVC:(ProjectToChooseListViewController *)proListVC withPro:(Project *)project{
390+
EditTaskViewController *taskVC = [EditTaskViewController new];
391+
taskVC.myTask = [Task taskWithProject:project andUser:[Login curLoginUser]];
392+
taskVC.myTask.handleType = TaskHandleTypeAddWithoutProject;
393+
__weak typeof(self) weakSelf = self;
394+
taskVC.doneBlock = ^(EditTaskViewController *vc){
395+
[vc.navigationController popToViewController:weakSelf animated:YES];
396+
};
397+
[proListVC.navigationController pushViewController:taskVC animated:YES];
382398
}
399+
383400
- (void)goToNewTweetVC{
384401
TweetSendViewController *vc = [[TweetSendViewController alloc] init];
385402
vc.sendNextTweet = ^(Tweet *nextTweet){

0 commit comments

Comments
 (0)