@@ -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)];
0 commit comments