|
@@ -37,23 +37,33 @@
|
|
|
#import "BookContentTopModel.h"
|
|
|
#import "BookContentModel.h"
|
|
|
#import "BookContentTopCell.h"
|
|
|
+#import "BookSelectCell.h"
|
|
|
+#import "BookSelectModel.h"
|
|
|
+#import "MOFSPickerManager.h"
|
|
|
|
|
|
@interface BookContentNavVC ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource>
|
|
|
@property (weak, nonatomic) IBOutlet UITableView *leftTableV;
|
|
|
@property (weak, nonatomic) IBOutlet UITableView *middleTableV;
|
|
|
@property (weak, nonatomic) IBOutlet UITableView *rightTableV;
|
|
|
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
|
|
|
-@property (weak, nonatomic) IBOutlet UIButton *showBtn;
|
|
|
+@property (weak, nonatomic) IBOutlet UIButton *showBtn;
|
|
|
@property (weak, nonatomic) IBOutlet UIView *HeadView;
|
|
|
@property (weak, nonatomic) IBOutlet UILabel *TitleL;
|
|
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftW;
|
|
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *middleW;
|
|
|
@property (strong, nonatomic) MyTDGroupView *SearchView;
|
|
|
@property (strong, nonatomic) NSMutableArray *dataArray;
|
|
|
+@property (strong, nonatomic) NSMutableArray *selectArray;
|
|
|
@property (assign, nonatomic) NSInteger leftRow;
|
|
|
@property (assign, nonatomic) NSInteger middleRow;
|
|
|
@property (assign, nonatomic) BOOL leftHidden;
|
|
|
@property (assign, nonatomic) BOOL middleHidden;
|
|
|
+@property (strong, nonatomic) UIView *selectView;
|
|
|
+@property (strong, nonatomic) UITableView *selectTableV;
|
|
|
+@property (strong, nonatomic) UIButton *reSetBtn;
|
|
|
+@property (strong, nonatomic) UIButton *doneBtn;
|
|
|
+@property (strong, nonatomic) UIButton *beginBtn;
|
|
|
+@property (strong, nonatomic) UIButton *endBtn;
|
|
|
@end
|
|
|
|
|
|
@implementation BookContentNavVC
|
|
@@ -69,14 +79,61 @@
|
|
|
}
|
|
|
return _SearchView;
|
|
|
}
|
|
|
-
|
|
|
--(NSMutableArray *)dataArray{
|
|
|
+- (UIView *)selectView
|
|
|
+{
|
|
|
+ if (!_selectView) {
|
|
|
+ _selectView = [UIView new];
|
|
|
+ _selectView.hidden = YES;
|
|
|
+ }
|
|
|
+ return _selectView;
|
|
|
+}
|
|
|
+- (UITableView *)selectTableV
|
|
|
+{
|
|
|
+ if (!_selectTableV) {
|
|
|
+ _selectTableV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
|
|
+ _selectTableV.backgroundColor = UIColorHex(0xFFFFFF);
|
|
|
+ _selectTableV.delegate = self;
|
|
|
+ _selectTableV.dataSource = self;
|
|
|
+ _selectTableV.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
+ }
|
|
|
+ return _selectTableV;
|
|
|
+}
|
|
|
+- (UIButton *)reSetBtn
|
|
|
+{
|
|
|
+ if (!_reSetBtn) {
|
|
|
+ _reSetBtn = [UIButton new];
|
|
|
+ [_reSetBtn setTitle:@"重置" forState:UIControlStateNormal];
|
|
|
+ _reSetBtn.titleLabel.font = [UIFont systemFontOfSize:17];
|
|
|
+ [_reSetBtn setTitleColor:UIColorHex(0x666666) forState:UIControlStateNormal];
|
|
|
+ _reSetBtn.backgroundColor = UIColorHex(0xF9F9F9);
|
|
|
+ }
|
|
|
+ return _reSetBtn;
|
|
|
+}
|
|
|
+- (UIButton *)doneBtn
|
|
|
+{
|
|
|
+ if (!_doneBtn) {
|
|
|
+ _doneBtn = [UIButton new];
|
|
|
+ [_doneBtn setTitle:@"完成" forState:UIControlStateNormal];
|
|
|
+ _doneBtn.titleLabel.font = [UIFont systemFontOfSize:17];
|
|
|
+ [_doneBtn setTitleColor:UIColorHex(0xFFFFFF) forState:UIControlStateNormal];
|
|
|
+ _doneBtn.backgroundColor = UIColorHex(0x3979D3);
|
|
|
+ }
|
|
|
+ return _doneBtn;
|
|
|
+}
|
|
|
+-(NSMutableArray *)dataArray
|
|
|
+{
|
|
|
if(!_dataArray){
|
|
|
_dataArray = [[NSMutableArray alloc] init];
|
|
|
}
|
|
|
return _dataArray;
|
|
|
}
|
|
|
-
|
|
|
+-(NSMutableArray *)selectArray
|
|
|
+{
|
|
|
+ if(!_selectArray){
|
|
|
+ _selectArray = [[NSMutableArray alloc] init];
|
|
|
+ }
|
|
|
+ return _selectArray;
|
|
|
+}
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
self.fd_prefersNavigationBarHidden = YES;
|
|
@@ -99,14 +156,21 @@
|
|
|
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
|
|
[self.collectionView setCollectionViewLayout:layout];
|
|
|
- [self.collectionView registerNib:[UINib nibWithNibName:@"BookContentTopCell" bundle:nil] forCellWithReuseIdentifier:@"BookContentTopCell"];
|
|
|
+ [self.collectionView registerNib:[UINib nibWithNibName:@"BookContentTopCell" bundle:nil] forCellWithReuseIdentifier:@"BookContentTopCell"];\
|
|
|
+
|
|
|
+ WS(weakSelf);
|
|
|
+ [self.view addSubview:self.selectView];
|
|
|
+ [self setSelectData];
|
|
|
+ [self.showBtn setAction:^{
|
|
|
+ weakSelf.selectView.hidden = NO;
|
|
|
+ }];
|
|
|
[self setDataModel];
|
|
|
}
|
|
|
|
|
|
- (void)setDataModel
|
|
|
{
|
|
|
[self.dataArray removeAllObjects];
|
|
|
- NSArray * array = @[@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒"];
|
|
|
+ NSArray * array = @[@"推荐",@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒",@"大众",@"教育",@"文化传媒"];
|
|
|
NSArray * subArray = @[@"时尚生活",@"财经商业",@"文化传媒",@"文学艺术"];
|
|
|
NSArray * topArray = @[@"全部",@"最热",@"最新",@"好评",@"全部",@"最热",@"最新",@"好评",@"全部",@"最热",@"最新",@"好评"];
|
|
|
for (NSInteger i= 0; i < array.count; i ++) {
|
|
@@ -132,7 +196,7 @@
|
|
|
BookContentModel * model = [[BookContentModel alloc] init];
|
|
|
model.title = @"翻转教学11法";
|
|
|
model.name = @"叶龙";
|
|
|
- model.subtitle = @"畅销书从优秀教师的改善学生课堂表及";
|
|
|
+ model.subtitle = @"我们看重的是教给学生多少知识。在教育者眼中,学生就是一个装知识的容器,那个时候教育的成…";
|
|
|
model.time = @"";
|
|
|
switch (k) {
|
|
|
case 0:
|
|
@@ -160,6 +224,9 @@
|
|
|
}
|
|
|
#pragma mark - UITableViewDelegate
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
|
+ if (tableView == self.selectTableV) {
|
|
|
+ return self.selectArray.count;
|
|
|
+ }
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -169,49 +236,42 @@
|
|
|
}else if(tableView == self.middleTableV){
|
|
|
BookContentLeftModel * model = [self.dataArray objectAtIndex:self.leftRow];
|
|
|
return model.dataArray.count;
|
|
|
- }else{
|
|
|
+ }else if(tableView == self.rightTableV){
|
|
|
BookContentLeftModel * model = [self.dataArray objectAtIndex:self.leftRow];
|
|
|
BookContentLeftModel * subModel = [model.dataArray objectAtIndex:self.middleRow];
|
|
|
return subModel.dataArray.count;
|
|
|
+ }else{
|
|
|
+ BookSelectModel * model = [self.selectArray objectAtIndex:section];
|
|
|
+ return model.isSelect ? 1 : 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
-// if (tableView == self.leftTableV) {
|
|
|
-// return UITableViewAutomaticDimension;
|
|
|
-// }else if(tableView == self.middleTableV){
|
|
|
-// return UITableViewAutomaticDimension;
|
|
|
-// }else{
|
|
|
-// BookContentLeftModel * model = [self.dataArray objectAtIndex:self.leftRow];
|
|
|
-// BookContentLeftModel * subModel = [model.dataArray objectAtIndex:self.middleRow];
|
|
|
-// BookContentModel * cModel = [subModel.dataArray objectAtIndex:indexPath.row];
|
|
|
-// switch (cModel.type) {
|
|
|
-// case BookContentBook:
|
|
|
-// return 120.f;
|
|
|
-// break;
|
|
|
-// case BookContentVideo:
|
|
|
-// return 110.f;
|
|
|
-// break;
|
|
|
-// case BookContentCourse:
|
|
|
-// return 110.f;
|
|
|
-// break;
|
|
|
-// case BookContentMusic:
|
|
|
-// return 88.f;
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// return UITableViewAutomaticDimension;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if (tableView == self.selectTableV) {
|
|
|
+ return 70 * 4 + 36;
|
|
|
+ }
|
|
|
return UITableViewAutomaticDimension;
|
|
|
}
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
|
{
|
|
|
if (tableView == self.leftTableV) {
|
|
|
- return 47.f;
|
|
|
+ return 0.01f;
|
|
|
}else if(tableView == self.middleTableV){
|
|
|
- return 47.f;
|
|
|
+ return 62.f;
|
|
|
+ }else if(tableView == self.selectTableV){
|
|
|
+ BookSelectModel * model = [self.selectArray objectAtIndex:section];
|
|
|
+ switch (model.type) {
|
|
|
+ case BookSelectCommon:
|
|
|
+ return 47.f;
|
|
|
+ break;
|
|
|
+ case BookSelectTime:
|
|
|
+ return 72.f;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return 220.f;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}else{
|
|
|
return 0.01f;
|
|
|
}
|
|
@@ -224,24 +284,25 @@
|
|
|
{
|
|
|
UIView * headerView = [[UIView alloc] init];
|
|
|
if (tableView == self.leftTableV) {
|
|
|
- [headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
|
|
|
- UILabel * label = [UILabel new];
|
|
|
- [headerView addSubview:label];
|
|
|
- label.font = [UIFont systemFontOfSize:16];
|
|
|
- label.textColor = UIColorHex(0x0A0A0A);
|
|
|
- [label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.center.mas_equalTo(headerView);
|
|
|
- }];
|
|
|
- label.text = @"推荐";
|
|
|
- headerView.backgroundColor = UIColorHex(0xEBEBEB);
|
|
|
+// [headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
|
|
|
+// UILabel * label = [UILabel new];
|
|
|
+// [headerView addSubview:label];
|
|
|
+// label.font = [UIFont systemFontOfSize:16];
|
|
|
+// label.textColor = UIColorHex(0x0A0A0A);
|
|
|
+// [label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.center.mas_equalTo(headerView);
|
|
|
+// }];
|
|
|
+// label.text = @"推荐";
|
|
|
+// headerView.backgroundColor = UIColorHex(0xEBEBEB);
|
|
|
}else if(tableView == self.middleTableV){
|
|
|
- [headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
|
|
|
+ [headerView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 62)];
|
|
|
UILabel * label = [UILabel new];
|
|
|
[headerView addSubview:label];
|
|
|
label.font = [UIFont systemFontOfSize:16];
|
|
|
label.textColor = UIColorHex(0x0A0A0A);
|
|
|
[label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.center.mas_equalTo(headerView);
|
|
|
+ make.centerX.mas_equalTo(headerView);
|
|
|
+ make.centerY.mas_equalTo(headerView);
|
|
|
}];
|
|
|
NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] init];
|
|
|
NSTextAttachment *attach = [[NSTextAttachment alloc] init];
|
|
@@ -249,7 +310,7 @@
|
|
|
attach.bounds = CGRectMake(0, 0, 11, 11);
|
|
|
NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
|
|
|
[attStr appendAttributedString:collegeStr];
|
|
|
- NSAttributedString *placeStr = [[NSAttributedString alloc] initWithString:@" 大众" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:UIColorHex(0x999999)}];
|
|
|
+ NSAttributedString *placeStr = [[NSAttributedString alloc] initWithString:@" 大众" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x999999)}];
|
|
|
[attStr appendAttributedString:placeStr];
|
|
|
label.attributedText = attStr;
|
|
|
headerView.backgroundColor = UIColorHex(0xFFFFFF);
|
|
@@ -259,15 +320,26 @@
|
|
|
[weakSelf reloadData];
|
|
|
}];
|
|
|
[headerView addGestureRecognizer:tap];
|
|
|
+ }else if(tableView == self.selectTableV){
|
|
|
+ return [self selectHeadViewSection:section];
|
|
|
}else{}
|
|
|
return headerView;
|
|
|
}
|
|
|
-
|
|
|
+- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
|
|
+{
|
|
|
+ return [UIView new];
|
|
|
+}
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
if (tableView == self.leftTableV) {
|
|
|
BookContentLeftModel * model = [self.dataArray objectAtIndex:indexPath.row];
|
|
|
BookContentLeftCell * cell = [BookContentLeftCell configCell:tableView indexPath:indexPath];
|
|
|
- [cell setDataWithModel:model middleHidden:self.middleHidden];
|
|
|
+// [cell setDataWithModel:model middleHidden:self.middleHidden];
|
|
|
+ [cell setDataModel:model];
|
|
|
+ if (indexPath.row == 0) {
|
|
|
+ cell.height.constant = 42.f;
|
|
|
+ }else{
|
|
|
+ cell.height.constant = 62.f;
|
|
|
+ }
|
|
|
return cell;
|
|
|
}else if(tableView == self.middleTableV){
|
|
|
BookContentLeftCell * cell = [BookContentLeftCell configCell:tableView indexPath:indexPath];
|
|
@@ -275,7 +347,7 @@
|
|
|
BookContentLeftModel * subModel = [model.dataArray objectAtIndex:indexPath.row];
|
|
|
[cell setDataWithsubModel:subModel leftHidden:self.leftHidden];
|
|
|
return cell;
|
|
|
- }else{
|
|
|
+ }else if(tableView == self.rightTableV){
|
|
|
BookContentLeftModel * model = [self.dataArray objectAtIndex:self.leftRow];
|
|
|
BookContentLeftModel * subModel = [model.dataArray objectAtIndex:self.middleRow];
|
|
|
BookContentModel * cModel = [subModel.dataArray objectAtIndex:indexPath.row];
|
|
@@ -310,6 +382,11 @@
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+ }else{
|
|
|
+ BookSelectCell * cell = [BookSelectCell configCell:tableView indexPath:indexPath];
|
|
|
+ BookSelectModel * model = [self.selectArray objectAtIndex:indexPath.section];
|
|
|
+ [cell setCollData:model.isSelect];
|
|
|
+ return cell;
|
|
|
}
|
|
|
}
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
@@ -417,4 +494,262 @@
|
|
|
[weakSelf.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark - SelectView
|
|
|
+- (void)setSelectData
|
|
|
+{
|
|
|
+ [self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.HeadView.mas_top);
|
|
|
+ if (@available(iOS 11.0, *)) {
|
|
|
+ make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
|
|
+ } else {
|
|
|
+ make.bottom.equalTo(self.view.mas_bottom);
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ UIView * view = [UIView new];
|
|
|
+ view.backgroundColor = UIColorHex(0x000000);
|
|
|
+ view.alpha = 0.5f;
|
|
|
+ [self.selectView addSubview:view];
|
|
|
+ [view mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_offset(80);
|
|
|
+ make.top.left.bottom.mas_equalTo(self.selectView);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.selectView addSubview:self.reSetBtn];
|
|
|
+ [self.selectView addSubview:self.doneBtn];
|
|
|
+ [self.selectView addSubview:self.selectTableV];
|
|
|
+ [self.reSetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(self.selectView);
|
|
|
+ make.left.mas_equalTo(view.mas_right);
|
|
|
+ make.width.mas_offset((SCREEN_WIDTH - 80) * 0.5);
|
|
|
+ make.height.mas_offset(50);
|
|
|
+ }];
|
|
|
+ [self.doneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.bottom.mas_equalTo(self.selectView);
|
|
|
+ make.width.mas_offset((SCREEN_WIDTH - 80) * 0.5);
|
|
|
+ make.height.mas_offset(50);
|
|
|
+ }];
|
|
|
+ [self.selectTableV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.right.mas_equalTo(self.selectView);
|
|
|
+ make.left.mas_equalTo(view.mas_right);
|
|
|
+ make.bottom.mas_equalTo(self.reSetBtn.mas_top);
|
|
|
+ }];
|
|
|
+ WS(weakSelf);
|
|
|
+ [self.reSetBtn setAction:^{
|
|
|
+ [weakSelf addSelectArray];
|
|
|
+ }];
|
|
|
+ [self.doneBtn setAction:^{
|
|
|
+ weakSelf.selectView.hidden = YES;
|
|
|
+ }];
|
|
|
+ [self addSelectArray];
|
|
|
+}
|
|
|
+- (void)addSelectArray
|
|
|
+{
|
|
|
+ [self.selectArray removeAllObjects];
|
|
|
+ NSArray * array = @[@"作者",@"作者单位",@"出版单位",@"关键词",@"基金",@"时间",@"排序方式"];
|
|
|
+ NSArray * sortArray = @[@"默认",@"学术性",@"相关性",@"出版时间降序",@"出版时间升序"];
|
|
|
+
|
|
|
+ for (NSInteger i = 0; i < array.count; i ++) {
|
|
|
+ BookSelectModel * model = [[BookSelectModel alloc] init];
|
|
|
+ model.title = array[i];
|
|
|
+ model.isSelect = i == 0 ? YES : NO;
|
|
|
+ if ([array[i] isEqualToString:@"时间"]) {
|
|
|
+ model.type = BookSelectTime;
|
|
|
+ model.isSelect = YES;
|
|
|
+ model.sortArray = [NSMutableArray array];
|
|
|
+ }else if ([array[i] isEqualToString:@"排序方式"]) {
|
|
|
+ model.type = BookSelectSort;
|
|
|
+ model.sortArray = [NSMutableArray array];
|
|
|
+ for (NSInteger j = 0; j < sortArray.count; j ++) {
|
|
|
+ BookSelectModel * smodel = [[BookSelectModel alloc] init];
|
|
|
+ smodel.title = sortArray[j];
|
|
|
+ smodel.isSelect = j == 0 ? YES : NO;
|
|
|
+ [model.sortArray addObject:smodel];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ model.type = BookSelectCommon;
|
|
|
+ model.sortArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ [self.selectArray addObject:model];
|
|
|
+ }
|
|
|
+ [self.selectTableV reloadData];
|
|
|
+}
|
|
|
+- (UIView *)selectHeadViewSection:(NSInteger)section
|
|
|
+{
|
|
|
+ BookSelectModel * model = [self.selectArray objectAtIndex:section];
|
|
|
+ UIView * view = [UIView new];
|
|
|
+ switch (model.type) {
|
|
|
+ case BookSelectCommon:
|
|
|
+ {
|
|
|
+ [view setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
|
|
|
+ view.backgroundColor = UIColorHex(0xFFFFFF);
|
|
|
+
|
|
|
+ UILabel * label = [UILabel new];
|
|
|
+ [view addSubview:label];
|
|
|
+ label.font = [UIFont systemFontOfSize:16];
|
|
|
+ label.textColor = UIColorHex(0x0A0A0A);
|
|
|
+ [label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.mas_equalTo(view);
|
|
|
+ make.left.mas_offset(20);
|
|
|
+ }];
|
|
|
+ label.text = model.title;
|
|
|
+ UIView * lineV = [UIView new];
|
|
|
+ [view addSubview:lineV];
|
|
|
+ lineV.backgroundColor = LINEBGCOLOR;
|
|
|
+ [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.bottom.mas_equalTo(view);
|
|
|
+ make.right.mas_offset(-15);
|
|
|
+ make.height.mas_offset(0.5);
|
|
|
+ }];
|
|
|
+ UIButton * btn = [UIButton new];
|
|
|
+ [view addSubview:btn];
|
|
|
+ [btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.right.bottom.mas_equalTo(view);
|
|
|
+ make.width.mas_offset(47);
|
|
|
+ }];
|
|
|
+ if (model.isSelect) {
|
|
|
+ [btn setImage:IMG(@"Book_jian_up") forState:UIControlStateNormal];
|
|
|
+ lineV.hidden = YES;
|
|
|
+ }else{
|
|
|
+ [btn setImage:IMG(@"Book_jian_down") forState:UIControlStateNormal];
|
|
|
+ lineV.hidden = NO;
|
|
|
+ }
|
|
|
+ WS(weakSelf);
|
|
|
+ [btn setAction:^{
|
|
|
+ model.isSelect = !model.isSelect;
|
|
|
+ NSIndexSet *set = [NSIndexSet indexSetWithIndex:section];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf.selectTableV reloadSections:set withRowAnimation:UITableViewRowAnimationAutomatic];//刷新某个section
|
|
|
+ });
|
|
|
+ }];
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case BookSelectTime:
|
|
|
+ {
|
|
|
+ [view setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 72)];
|
|
|
+ view.backgroundColor = UIColorHex(0xFFFFFF);
|
|
|
+ UILabel * label = [UILabel new];
|
|
|
+ [view addSubview:label];
|
|
|
+ label.font = [UIFont systemFontOfSize:16];
|
|
|
+ label.textColor = UIColorHex(0x0A0A0A);
|
|
|
+ [label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.mas_equalTo(view);
|
|
|
+ make.left.mas_offset(20);
|
|
|
+ }];
|
|
|
+ label.text = model.title;
|
|
|
+ self.beginBtn = [self setTimeButton];
|
|
|
+ [view addSubview:self.beginBtn];
|
|
|
+ [self.beginBtn setTitle:@"2018-01-01" forState:UIControlStateNormal];
|
|
|
+ [self.beginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_offset(60);
|
|
|
+ make.centerY.mas_equalTo(label);
|
|
|
+ make.size.mas_offset(CGSizeMake((SCREEN_WIDTH - 185) * 0.5, 32));
|
|
|
+ }];
|
|
|
+ UIView * lineV = [UIView new];
|
|
|
+ [view addSubview:lineV];
|
|
|
+ lineV.backgroundColor = LINEBGCOLOR;
|
|
|
+ [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(self.beginBtn.mas_right).offset(6.5);
|
|
|
+ make.centerY.mas_equalTo(label);
|
|
|
+ make.size.mas_offset(CGSizeMake(17, 0.5));
|
|
|
+ }];
|
|
|
+ self.endBtn = [self setTimeButton];
|
|
|
+ [view addSubview:self.endBtn];
|
|
|
+ [self.endBtn setTitle:@"2020-05-06" forState:UIControlStateNormal];
|
|
|
+ [self.endBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(lineV.mas_right).offset(6.5);
|
|
|
+ make.centerY.mas_equalTo(label);
|
|
|
+ make.size.mas_offset(CGSizeMake((SCREEN_WIDTH - 185) * 0.5, 32));
|
|
|
+ }];
|
|
|
+ WS(weakSelf);
|
|
|
+ [self.beginBtn setAction:^{
|
|
|
+ [[MOFSPickerManager shareManger] showDatePickerWithTag:2 commitBlock:^(NSDate *date) {
|
|
|
+ NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
|
|
|
+ dateformat.dateFormat = @"yyyy-MM-dd";
|
|
|
+ [weakSelf.beginBtn setTitle:[dateformat stringFromDate:date] forState:UIControlStateNormal];
|
|
|
+ } cancelBlock:^{
|
|
|
+ }];
|
|
|
+ }];
|
|
|
+ [self.endBtn setAction:^{
|
|
|
+ [[MOFSPickerManager shareManger] showDatePickerWithTag:2 commitBlock:^(NSDate *date) {
|
|
|
+ NSDateFormatter *dateformat = [[NSDateFormatter alloc]init];
|
|
|
+ dateformat.dateFormat = @"yyyy-MM-dd";
|
|
|
+ [weakSelf.endBtn setTitle:[dateformat stringFromDate:date] forState:UIControlStateNormal];
|
|
|
+ } cancelBlock:^{
|
|
|
+ }];
|
|
|
+ }];
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ [view setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 220)];
|
|
|
+ view.backgroundColor = UIColorHex(0xFFFFFF);
|
|
|
+ UILabel * label = [UILabel new];
|
|
|
+ [view addSubview:label];
|
|
|
+ label.font = [UIFont systemFontOfSize:16];
|
|
|
+ label.textColor = UIColorHex(0x0A0A0A);
|
|
|
+ label.text = model.title;
|
|
|
+ for (NSInteger i = 0; i < model.sortArray.count; i ++) {
|
|
|
+ BookSelectModel * sModel = model.sortArray[i];
|
|
|
+ UIButton * btn = [UIButton new];
|
|
|
+ btn.tag = i + 10000;
|
|
|
+ if (sModel.isSelect) {
|
|
|
+ [btn setImage:IMG(@"Book_Select_yes") forState:UIControlStateNormal];
|
|
|
+ }else{
|
|
|
+ [btn setImage:IMG(@"Book_Select_no") forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ [btn addTarget:self action:@selector(clickSelectBtn:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [view addSubview:btn];
|
|
|
+ UILabel * subtitleL = [UILabel new];
|
|
|
+ [view addSubview:subtitleL];
|
|
|
+ subtitleL.font = [UIFont systemFontOfSize:16];
|
|
|
+ subtitleL.textColor = UIColorHex(0x0A0A0A);
|
|
|
+ subtitleL.text = sModel.title;
|
|
|
+ [btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_offset(120);
|
|
|
+ make.top.mas_offset(i * 40 + 7.5);
|
|
|
+ make.size.mas_offset(CGSizeMake(40, 40));
|
|
|
+ }];
|
|
|
+ if (i == 0) {
|
|
|
+ [label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.mas_equalTo(btn);
|
|
|
+ make.left.mas_offset(20);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ [subtitleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.mas_equalTo(btn);
|
|
|
+ make.left.mas_equalTo(btn.mas_right).offset(5);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+- (UIButton *)setTimeButton
|
|
|
+{
|
|
|
+ UIButton * btn = [UIButton new];
|
|
|
+ btn.backgroundColor = UIColorHex(0xF9F9F9);
|
|
|
+ btn.layer.borderColor = UIColorHex(0xE5E5E5).CGColor;
|
|
|
+ btn.layer.cornerRadius = 2.f;
|
|
|
+ btn.layer.borderWidth = 0.5f;
|
|
|
+ btn.layer.masksToBounds = YES;
|
|
|
+ btn.titleLabel.font = [UIFont systemFontOfSize:13];
|
|
|
+ [btn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
|
|
|
+ return btn;
|
|
|
+}
|
|
|
+- (void)clickSelectBtn:(UIButton *)sender
|
|
|
+{
|
|
|
+ BookSelectModel * model = self.selectArray.lastObject;
|
|
|
+ BookSelectModel * sModel = model.sortArray[sender.tag - 10000];
|
|
|
+ for (NSInteger j = 0; j < model.sortArray.count; j ++) {
|
|
|
+ BookSelectModel * bModel = model.sortArray[j];
|
|
|
+ bModel.isSelect = NO;
|
|
|
+ }
|
|
|
+ sModel.isSelect = YES;
|
|
|
+ NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.selectArray.count - 1];
|
|
|
+ [self.selectTableV reloadSections:set withRowAnimation:UITableViewRowAnimationAutomatic];//刷新某个section
|
|
|
+}
|
|
|
@end
|