Skip to content

Commit cb0f796

Browse files
committed
筛选~
1 parent 639c165 commit cb0f796

File tree

6 files changed

+60
-9
lines changed

6 files changed

+60
-9
lines changed

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

+12-5
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@ - (void)viewDidLoad
103103
});
104104
[self.navigationController.navigationBar addSubview:_mySearchBar];
105105

106+
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
106107
//初始化过滤目录并加载数据
107108
_myFliterMenu = [[PopFliterMenu alloc] initWithFrame:kScreen_Bounds items:nil];
109+
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
110+
[weakCarousel scrollToItemAtIndex:pageIndex animated:NO];
111+
};
112+
108113
[_myFliterMenu refreshMenuDate];
109114

110115
//添加滑块
111-
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
112116
_mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:_segmentItems selectedBlock:^(NSInteger index) {
113117
if (index == _oldSelectedIndex) {
114118
return;
@@ -276,7 +280,6 @@ - (void)goToNewTweetVC{
276280
[Tweet deleteSendData];//发送成功后删除草稿
277281
}
278282
}];
279-
280283
};
281284
UINavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
282285
[self.parentViewController presentViewController:nav animated:YES completion:nil];
@@ -307,9 +310,13 @@ - (void)goToMessageVC{
307310

308311
#pragma mark fliter
309312
-(void)fliterClicked:(id)sender{
310-
NSLog(@"show fliter");
311-
[_myFliterMenu showMenuAtView:self.view];
312-
313+
// NSLog(@"show fliter:%d",_myFliterMenu.showStatus);
314+
if (_myFliterMenu.showStatus) {
315+
[_myFliterMenu dismissMenu];
316+
}else
317+
{
318+
[_myFliterMenu showMenuAtView:self.view];
319+
}
313320
}
314321

315322

Coding_iOS/Launch Screen.xib

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
66
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
77
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
88
</dependencies>

Coding_iOS/Models/Projects.h

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef NS_ENUM(NSInteger, ProjectsType)
3333

3434
ProjectsTypeTaProject,
3535
ProjectsTypeTaStared,
36+
ProjectsTypeWatched,
3637

3738
};
3839

Coding_iOS/Models/Projects.m

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ - (NSString *)typeStr{
5353
case ProjectsTypeTaStared:
5454
typeStr = @"stared";
5555
break;
56+
case ProjectsTypeWatched:
57+
typeStr = @"watched";
58+
break;
5659
default:
5760
typeStr = @"all";
5861
break;

Coding_iOS/Views/PopFliterMenu.h

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#import <UIKit/UIKit.h>
1010

1111
@interface PopFliterMenu : UIView
12+
@property (assign) BOOL showStatus;
13+
@property (nonatomic , copy) void (^clickBlock)(NSInteger selectNum);
14+
@property (nonatomic,assign) NSInteger selectNum; //选中数据
1215
- (instancetype)initWithFrame:(CGRect)frame items:(NSArray *)items;
1316
//将菜单显示到某个视图上
1417
- (void)showMenuAtView:(UIView *)containerView;

Coding_iOS/Views/PopFliterMenu.m

+39-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "XHRealTimeBlur.h"
1111
#import "Coding_NetAPIManager.h"
1212
#import "ProjectCount.h"
13+
#import "Projects.h"
1314

1415
@interface PopFliterMenu()<UITableViewDataSource,UITableViewDelegate>
1516
@property (nonatomic, strong) NSMutableArray *items;
@@ -26,6 +27,7 @@ - (id)initWithFrame:(CGRect)frame items:(NSArray *)items {
2627
// Initialization code
2728
self.items = @[@{@"all":@""},@{@"created":@""},@{@"joined":@""},@{@"watched":@""},@{@"stared":@""}];
2829
self.pCount=[ProjectCount new];
30+
self.showStatus=FALSE;
2931
[self setup];
3032
}
3133
return self;
@@ -80,19 +82,20 @@ - (void)setup {
8082
tableview;
8183
});
8284
[self addSubview:_tableview];
83-
_tableview.contentOffset=CGPointMake(0, 100);
85+
_tableview.contentInset=UIEdgeInsetsMake(15, 0,0,0);
8486

8587
}
8688

87-
8889
#pragma mark -- event & action
8990
- (void)showMenuAtView:(UIView *)containerView {
91+
_showStatus=TRUE;
9092
[containerView addSubview:self];
9193
[_realTimeBlur showBlurViewAtView:self];
9294
}
9395

9496
- (void)dismissMenu
9597
{
98+
_showStatus=FALSE;
9699
[self removeFromSuperview];
97100
}
98101

@@ -128,6 +131,33 @@ -(void)updateDateSource:(ProjectCount*)pCount
128131
}
129132

130133

134+
//转化为Projects类对应类型
135+
-(NSInteger)convertToProjectType
136+
{
137+
switch (_selectNum) {
138+
case 0:
139+
return ProjectsTypeAll;
140+
break;
141+
case 1:
142+
return ProjectsTypeCreated;
143+
break;
144+
case 2:
145+
return ProjectsTypeJoined;
146+
break;
147+
case 3:
148+
return ProjectsTypeWatched;
149+
break;
150+
case 4:
151+
return ProjectsTypeTaStared;
152+
break;
153+
default:
154+
NSLog(@"type error");
155+
return ProjectsTypeAll;
156+
break;
157+
}
158+
}
159+
160+
131161
#pragma mark -- uitableviewdelegate & datasource
132162
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
133163
return [_items count];
@@ -143,4 +173,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
143173
return cell;
144174
}
145175

176+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
177+
{
178+
_selectNum=indexPath.row;
179+
[self dismissMenu];
180+
_clickBlock([self convertToProjectType]);
181+
}
182+
146183
@end

0 commit comments

Comments
 (0)