Skip to content

Commit 7bfbda9

Browse files
张达棣张达棣
authored andcommitted
完成项目外任务的界面逻辑和业务逻辑
1 parent b90d169 commit 7bfbda9

6 files changed

Lines changed: 76 additions & 74 deletions

File tree

Coding_iOS/Controllers/RootControllers/MyTask_RootViewController.m

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ @interface MyTask_RootViewController ()
3131
@property (nonatomic, strong) NSString *keyword;
3232
@property (nonatomic, strong) NSString *status; //任务状态,进行中的为1,已完成的为2
3333
@property (nonatomic, strong) NSString *label; //任务标签
34-
@property (nonatomic, strong) Tasks *tasks;
35-
34+
@property (nonatomic, strong) NSString *project_id;
3635
@end
3736

3837
@implementation MyTask_RootViewController
@@ -105,7 +104,7 @@ - (void)viewDidLoad
105104
weakSelf.keyword = keyword;
106105
weakSelf.status = status;
107106
weakSelf.label = label;
108-
[weakSelf resetSearView];
107+
[weakSelf resetCurView];
109108
};
110109

111110

@@ -139,7 +138,6 @@ - (void)viewWillAppear:(BOOL)animated{
139138

140139

141140
- (void)resetCurView{
142-
_tasks = nil;
143141
if (!_myProjects.isLoading) {
144142
__weak typeof(self) weakSelf = self;
145143
[[Coding_NetAPIManager sharedManager] request_ProjectsHaveTasks_WithObj:_myProjects andBlock:^(id data, NSError *error) {
@@ -150,21 +148,6 @@ - (void)resetCurView{
150148
}
151149
}
152150

153-
- (void)resetSearView {
154-
__weak typeof(self) weakSelf = self;
155-
156-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:nil keyword:_keyword status:_status label:_label andBlock:^(Tasks *data, NSError *error) {
157-
weakSelf.tasks = data;
158-
[weakSelf configSearchControlWithData:data];
159-
160-
161-
// [weakSelf.myProjectList removeAllObjects];
162-
// [weakSelf.myProjectList addObjectsFromArray:_tasks.list];
163-
// [_myCarousel reloadData];
164-
165-
}];
166-
}
167-
168151
- (void)configSegmentControlWithData:(Projects *)freshProjects {
169152
[_myProTksDict removeAllObjects];
170153
[self.myProjectList removeAllObjects];
@@ -208,43 +191,6 @@ - (void)configSegmentControlWithData:(Projects *)freshProjects {
208191

209192
}
210193

211-
- (void)configSearchControlWithData:(Tasks *)tasks{
212-
213-
[_myProTksDict removeAllObjects];
214-
[self.myProjectList removeAllObjects];
215-
216-
BOOL dataHasChanged = NO;
217-
218-
if (!dataHasChanged) {
219-
self.myProjectList = [[NSMutableArray alloc] initWithObjects:[Project project_All], nil];
220-
221-
NSMutableDictionary *proDict = @{}.mutableCopy;
222-
for (Task *task in tasks.list) {
223-
NSLog(@"-----%@--%@", task.project.id, task.project.name);
224-
[proDict setObject:task.project forKey:task.project.id.stringValue];
225-
}
226-
[self.myProjectList addObjectsFromArray:proDict.allValues];
227-
228-
//重置滑块
229-
if (_mySegmentControl) {
230-
[_mySegmentControl removeFromSuperview];
231-
}
232-
__weak typeof(self) weakSelf = self;
233-
CGRect segmentFrame = CGRectMake(0, 0, kScreen_Width, kMySegmentControlIcon_Height);
234-
_mySegmentControl = [[XTSegmentControl alloc] initWithFrame:segmentFrame Items:_myProjectList selectedBlock:^(NSInteger index) {
235-
[weakSelf.myCarousel scrollToItemAtIndex:index animated:NO];
236-
}];
237-
[self.view addSubview:_mySegmentControl];
238-
239-
if (_myCarousel.currentItemIndex != 0) {
240-
_myCarousel.currentItemIndex = 0;
241-
}
242-
[_myCarousel reloadData];
243-
}
244-
245-
}
246-
247-
248194
#pragma mark iCarousel M
249195
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel{
250196
return [_myProjectList count];
@@ -256,15 +202,16 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
256202
curTasks = [Tasks tasksWithPro:curPro queryType:TaskQueryTypeAll];
257203
[_myProTksDict setObject:curTasks forKey:curPro.id];
258204
}
259-
if (_tasks != nil) {
260-
curTasks = _tasks;
261-
}
205+
262206
ProjectTaskListView *listView = (ProjectTaskListView *)view;
263207
if (listView) {
208+
listView.keyword = _keyword;
209+
listView.status = _status;
210+
listView.label = _label;
264211
[listView setTasks:curTasks];
265212
}else{
266213
__weak typeof(self) weakSelf = self;
267-
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks block:^(ProjectTaskListView *taskListView, Task *task) {
214+
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks project_id:_project_id keyword:_keyword status:_status label:_label block:^(ProjectTaskListView *taskListView, Task *task) {
268215
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
269216
vc.myTask = task;
270217
vc.taskChangedBlock = ^(){
@@ -274,9 +221,6 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
274221
} tabBarHeight:CGRectGetHeight(self.rdv_tabBarController.tabBar.frame)];
275222
}
276223
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
277-
listView.keyword = _keyword;
278-
listView.status = _status;
279-
listView.label = _label;
280224
return listView;
281225
}
282226

@@ -295,10 +239,11 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
295239
ProjectTaskListView *curView = (ProjectTaskListView *)carousel.currentItemView;
296240
NSInteger index = carousel.scrollOffset;
297241
if (index == 0) {
298-
curView.project_id = nil;
242+
_project_id = nil;
299243
} else {
300-
curView.project_id = ((Project *)_myProjectList[index - 1]).id.stringValue;
244+
_project_id = ((Project *)_myProjectList[index - 1]).id.stringValue;
301245
}
246+
curView.project_id = _project_id;
302247
[curView refreshToQueryData];
303248
[carousel.visibleItemViews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
304249
[obj setSubScrollsToTop:(obj == carousel.currentItemView)];

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ typedef NS_ENUM(NSInteger, PurposeType) {
165165
- (void)request_DeleteComment:(TaskComment *)comment ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
166166
- (void)request_ChangeWatcher:(User *)watcher ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
167167
- (void)request_Search_filtersAndBlock:(void (^)(id data, NSError *error))block; //任务标签
168-
- (void)request_tasks_searchWithOwner:(NSString *)owner project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label andBlock:(void (^)(id data, NSError *error))block;
168+
- (void)request_tasks_searchWithOwner:(NSString *)owner project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
169169

170170

171171
#pragma mark - User

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,8 @@ - (void)request_Search_filtersAndBlock:(void (^)(id data, NSError *error))block
14831483

14841484
}
14851485

1486-
- (void)request_tasks_searchWithOwner:(NSString *)owner project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label andBlock:(void (^)(id data, NSError *error))block {
1487-
NSMutableDictionary *param = @{}.mutableCopy;
1486+
- (void)request_tasks_searchWithOwner:(NSString *)owner project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block {
1487+
NSMutableDictionary *param = @{@"page": @(page)}.mutableCopy;
14881488
if (owner != nil) {
14891489
[param setValue:owner forKey:@"owner"];
14901490
}

Coding_iOS/Views/ScreenView.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ @interface ScreenView ()<UITableViewDataSource, UITableViewDelegate>
1616
@property (nonatomic, strong) NSArray *labels;
1717
@property (nonatomic, strong) UITableView *tableView;
1818
@property (nonatomic, assign) NSInteger selectNum; //选中数据
19-
19+
@property (nonatomic, strong) UISearchBar *searchBar;
2020
@end
2121

2222
@implementation ScreenView
@@ -115,7 +115,7 @@ - (void)creatView {
115115
UIView *mainView = [[UIView alloc] init];
116116
mainView.backgroundColor = [UIColor whiteColor];
117117
[self addSubview:mainView];
118-
mainView.sd_layout.leftSpaceToView(self, 80).topEqualToView(self).bottomEqualToView(self).rightEqualToView(self);
118+
mainView.sd_layout.leftSpaceToView(self, 80).topSpaceToView(self, 0).bottomEqualToView(self).rightEqualToView(self);
119119

120120
UISearchBar *searchBar = [[UISearchBar alloc] init];
121121
UITextField *searchField = [searchBar valueForKey:@"searchField"];
@@ -126,7 +126,8 @@ - (void)creatView {
126126
searchBar.cornerRadius = 4;
127127
searchBar.masksToBounds = YES;
128128
[mainView addSubview:searchBar];
129-
searchBar.sd_layout.leftSpaceToView(mainView, 15).topSpaceToView(mainView, 0).rightSpaceToView(mainView, 15).heightIs(31);
129+
searchBar.sd_layout.leftSpaceToView(mainView, 15).topSpaceToView(mainView, 15).rightSpaceToView(mainView, 15).heightIs(31);
130+
_searchBar = searchBar;
130131

131132
UITableView *tableView = [[UITableView alloc] init];
132133
tableView.backgroundColor = [UIColor clearColor];
@@ -155,6 +156,7 @@ - (void)creatData {
155156

156157
- (void)clickDis {
157158
self.hidden = YES;
159+
self.keyword = _searchBar.text;
158160
if (_selectBlock) {
159161
_selectBlock(_keyword, _status, _label);
160162
}

Coding_iOS/Views/TableListView/ProjectTaskListView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ typedef void(^ProjectTaskBlock)(ProjectTaskListView *taskListView, Task *task);
1919
@property (nonatomic, strong) NSString *project_id;
2020

2121
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
22+
23+
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight;
2224
- (void)setTasks:(Tasks *)tasks;
2325
- (void)refreshToQueryData;
2426
- (void)tabBarItemClicked;

Coding_iOS/Views/TableListView/ProjectTaskListView.m

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ @interface ProjectTaskListView ()
1818
@property (copy, nonatomic) ProjectTaskBlock block;
1919
@property (strong, nonatomic) UITableView *myTableView;
2020
@property (strong, nonatomic) ODRefreshControl *myRefreshControl;
21-
21+
@property (nonatomic, assign) NSInteger page;
2222
@end
2323

2424
@implementation ProjectTaskListView
@@ -45,6 +45,56 @@ - (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks block:(ProjectTaskBlock)b
4545
// Initialization code
4646
_myTasks = tasks;
4747
_block = block;
48+
_page = 1;
49+
50+
_myTableView = ({
51+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
52+
tableView.backgroundColor = [UIColor clearColor];
53+
tableView.delegate = self;
54+
tableView.dataSource = self;
55+
[tableView registerClass:[ProjectTaskListViewCell class] forCellReuseIdentifier:kCellIdentifier_ProjectTaskList];
56+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
57+
[self addSubview:tableView];
58+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
59+
make.edges.equalTo(self);
60+
}];
61+
if (tabBarHeight != 0) {
62+
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, tabBarHeight, 0);
63+
tableView.contentInset = insets;
64+
tableView.scrollIndicatorInsets = insets;
65+
}
66+
tableView;
67+
});
68+
69+
_myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
70+
[_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
71+
__weak typeof(self) weakSelf = self;
72+
[_myTableView addInfiniteScrollingWithActionHandler:^{
73+
[weakSelf refreshMore];
74+
}];
75+
if (_myTasks.list.count > 0) {
76+
[_myTableView reloadData];
77+
}else{
78+
[self sendRequest];
79+
}
80+
}
81+
return self;
82+
}
83+
84+
85+
- (id)initWithFrame:(CGRect)frame tasks:(Tasks *)tasks project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label block:(ProjectTaskBlock)block tabBarHeight:(CGFloat)tabBarHeight{
86+
self = [super initWithFrame:frame];
87+
if (self) {
88+
// Initialization code
89+
_myTasks = tasks;
90+
_block = block;
91+
_page = 1;
92+
93+
self.project_id = project_id;
94+
self.keyword = keyword;
95+
self.status = status;
96+
self.label = label;
97+
4898

4999
_myTableView = ({
50100
UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
@@ -106,6 +156,7 @@ - (void)refresh{
106156
if (_myTasks.isLoading) {
107157
return;
108158
}
159+
_page = 1;
109160
_myTasks.willLoadMore = NO;
110161
[self sendRequest];
111162
}
@@ -115,6 +166,7 @@ - (void)refreshMore{
115166
[_myTableView.infiniteScrollingView stopAnimating];
116167
return;
117168
}
169+
_page++;
118170
_myTasks.willLoadMore = YES;
119171
[self sendRequest];
120172
}
@@ -125,7 +177,7 @@ - (void)sendRequest{
125177
}
126178
__weak typeof(self) weakSelf = self;
127179

128-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:_project_id keyword:_keyword status:_status label:_label andBlock:^(Tasks *data, NSError *error) {
180+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithOwner:nil project_id:_project_id keyword:_keyword status:_status label:_label page:_page andBlock:^(Tasks *data, NSError *error) {
129181
[weakSelf endLoading];
130182
[weakSelf.myRefreshControl endRefreshing];
131183
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
@@ -141,7 +193,7 @@ - (void)sendRequest{
141193

142194

143195
}];
144-
return;
196+
/*
145197
[[Coding_NetAPIManager sharedManager] request_ProjectTaskList_WithObj:_myTasks andBlock:^(Tasks *data, NSError *error) {
146198
[weakSelf endLoading];
147199
[weakSelf.myRefreshControl endRefreshing];
@@ -155,6 +207,7 @@ - (void)sendRequest{
155207
[weakSelf refresh];
156208
}];
157209
}];
210+
*/
158211
}
159212

160213

0 commit comments

Comments
 (0)