// // YOUPAIHRDatePickerView.m // VQU // // Created by xiaohaoran on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRDatePickerView.h" #import "JXCategoryView.h" #import "YOUPAIJXCategoryTitleBackgroundView.h" #import "JXPagerView.h" #import "YOUPAIHRMonthDateVC.h" #import "YOUPAIHRSelectDayDateVC.h" #define LZCategoryViewHeight 49.0f #define LZCategoryViewItemWidth 65.0f @interface YOUPAIHRDatePickerView () @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView; @property (nonatomic, weak) JXCategoryTitleView *youpaipcategoryView; @property (nonatomic, weak) UIView *youpaipcategoryBgV; /* titlearr */ @property (strong, nonatomic) NSArray *youpaiptitlesArr; @end @implementation YOUPAIHRDatePickerView - (void)viewDidLoad { [super viewDidLoad]; self.baseView.hidden = YES; [self youpaifsetupUI]; } -(void)youpaifsetupUI{ UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 324+SafeHeight)]; bgV.backgroundColor = LCBkgColor; [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)]; [self.view addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.offset(0.0f); make.height.offset(324+SafeHeight); }]; UIView *youpaipcategoryBgV = [[UIView alloc] init]; youpaipcategoryBgV.backgroundColor = [UIColor clearColor];//LCBkgColor; YOUPAIJXCategoryTitleBackgroundView *youpaipcategoryView = [[YOUPAIJXCategoryTitleBackgroundView alloc] init]; youpaipcategoryView.backgroundColor = [UIColor clearColor]; youpaipcategoryView.titles = @[@"按月筛选",@"按日筛选"]; youpaipcategoryView.delegate = self; youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xffffff); youpaipcategoryView.titleColor = HexColorFromRGB(0xffffff); youpaipcategoryView.titleColorGradientEnabled = YES; youpaipcategoryView.titleFont = LCFont(12.0f); youpaipcategoryView.titleSelectedFont = LCBoldFont(12.0f); youpaipcategoryView.cellWidth = LZCategoryViewItemWidth; youpaipcategoryView.cellSpacing = 8.0f; youpaipcategoryView.normalBackgroundColor = HexColorFromRGB(0x4F4B5B); youpaipcategoryView.selectedBackgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(64.0f, 27.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientTopToBottom]]; youpaipcategoryView.averageCellSpacingEnabled = NO; youpaipcategoryView.normalBorderColor = [UIColor clearColor]; youpaipcategoryView.selectedBorderColor = [UIColor clearColor]; youpaipcategoryView.borderLineWidth = 0; youpaipcategoryView.backgroundCornerRadius = 13.0f; youpaipcategoryView.backgroundWidth = JXCategoryViewAutomaticDimension; youpaipcategoryView.backgroundHeight = 26.0f; [youpaipcategoryBgV addSubview:youpaipcategoryView]; self.youpaipcategoryView = youpaipcategoryView; //取消 UIButton* cancelBtn = [[UIButton alloc]init]; [cancelBtn addTarget:self action:@selector(youpaifcancelBtnClick) forControlEvents:(UIControlEventTouchUpInside)]; [youpaipcategoryBgV addSubview:cancelBtn]; [cancelBtn setTitle:@"取消" forState:UIControlStateNormal]; [cancelBtn setTitleColor:HexColorFromRGB(0x9F9DA5) forState:UIControlStateNormal]; cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15]; JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; lineView.verticalMargin = 4.0f; lineView.indicatorHeight = 2.5f; lineView.indicatorWidth = 8; lineView.layer.cornerRadius = 1.25; lineView.layer.masksToBounds = YES; [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] gradientType:GradientLeftToRight]]; youpaipcategoryView.indicators = @[lineView]; JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self]; pagerView.listCellBackgroundColor = LCBkgColor; // pagerView.frame = CGRectMake(0.0f, youpaipcategoryBgV.mj_h, KScreenWidth, KScreenHeight - youpaipcategoryBgV.mj_h - TabbarHeight); [bgV addSubview:pagerView]; self.youpaippagerView = pagerView; self.youpaipcategoryView.listContainer = self.youpaippagerView; [bgV addSubview:youpaipcategoryBgV]; self.youpaipcategoryBgV = youpaipcategoryBgV; [youpaipcategoryBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.offset(0.0f); make.height.offset(LZCategoryViewHeight); }]; [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(34.0f); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(40.0f, 15.0f)); }]; [youpaipcategoryView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(cancelBtn.mas_right).offset(45); make.top.offset(0); make.height.offset(LZCategoryViewHeight); make.right.equalTo(0); }]; [pagerView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.offset(0.0f); make.top.equalTo(youpaipcategoryBgV.mas_bottom).offset(0); }]; } -(void)youpaifcancelBtnClick{ [self dismissViewControllerAnimated:YES completion:^{ }]; } #pragma mark - JXCategoryListContainerViewDelegate - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{ return 2; } - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ if (index == 0) { YOUPAIHRMonthDateVC *vc = [YOUPAIHRMonthDateVC new]; @weakify(self); [vc setYoupaipdidSelectMonthTimeBlock:^(NSString * _Nonnull DateStr) { @strongify(self); if (self.youpaipselectMonthDate) { self.youpaipselectMonthDate(DateStr); } }]; return vc; }else{ YOUPAIHRSelectDayDateVC *vc = [YOUPAIHRSelectDayDateVC new]; @weakify(self); [vc setYoupaipdidSelectTimeBlock:^(NSString * _Nonnull starDate, NSString * _Nonnull endDate) { @strongify(self); if (self.youpaipselectDayDate) { self.youpaipselectDayDate(starDate, endDate); } }]; return vc; } } @end