// // YOUPAIHRBillDetailVC.m // VQU // // Created by xiaohaoran on 2021/10/27. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRBillDetailVC.h" #import "JXCategoryView.h" #import "YOUPAIJXCategoryTitleBackgroundView.h" #import "JXPagerView.h" #import "YOUPAIHRBillSubDetailVC.h" #import "PGDatePickManager.h" #define LZCategoryViewHeight 44.0f //#define LZCategoryViewItemWidth 12.0f @interface YOUPAIHRBillDetailVC () @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView; @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView; @property (strong, nonatomic) NSArray *youpaiptitlesArr; @property (nonatomic, strong) NSMutableArray *youpaipdotStates; @property(nonatomic,strong)NSString *youpaipdate; @end @implementation YOUPAIHRBillDetailVC - (void)viewDidLoad { [super viewDidLoad]; self.title = LCStr(word5);//@"收支明细"; if ([LCSaveData getWhiteVersion]) { self.youpaiptitlesArr = @[@""]; }else{ self.youpaiptitlesArr = @[@"钻石",LCStr(word45)]; } [self youpaifsetupUI]; [self youpaifrightBtn]; self.view.backgroundColor = [UIColor whiteColor]; } -(void)youpaifrightBtn{ self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifselectDateAction) title:@"筛选" font:LCFont14 titleColor:LZA3AABEColor highlightedColor:LZA3AABEColor titleEdgeInsets:UIEdgeInsetsZero]; } - (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents{ NSLog(@"dateComponents = %@", dateComponents); NSInteger year=[dateComponents year]; NSInteger month=[dateComponents month]; self.youpaipdate = [NSString stringWithFormat:@"%ld-%ld",year,month]; [[NSNotificationCenter defaultCenter]postNotificationName:@"changSelectDate" object:nil userInfo:@{@"date":self.youpaipdate}]; } //选择时间 -(void)youpaifselectDateAction{ PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init]; datePickManager.isShadeBackground = true; datePickManager.cancelButtonFont = LCFont(15); datePickManager.confirmButtonFont = LCFont(15); datePickManager.cancelButtonTextColor = LZA3AABEColor; datePickManager.confirmButtonTextColor = LZ273145Color; datePickManager.headerViewBackgroundColor = [UIColor whiteColor]; datePickManager.headerHeight = 50; PGDatePicker *datePicker = datePickManager.datePicker; datePicker.backgroundColor = [UIColor whiteColor]; datePicker.rowHeight = 35; datePicker.middleTextColor = LZ273145Color; datePicker.textColorOfSelectedRow = LZ273145Color; datePicker.textColorOfOtherRow = LZD3D1D7Color; datePicker.textFontOfSelectedRow = LCFont(17); datePicker.textFontOfOtherRow = LCFont(17); datePicker.lineBackgroundColor = [UIColor clearColor]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSDate* currentDate = [NSDate date]; [dateFormatter setDateFormat:@"yyyy"]; NSString* currentYear=[dateFormatter stringFromDate:currentDate] ; [dateFormatter setDateFormat:@"MM"]; NSString* currentMonth=[dateFormatter stringFromDate:currentDate]; NSString* maxDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue],currentMonth]; NSString* minDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue]-50,currentMonth]; [dateFormatter setDateFormat:@"yyyy-MM"]; NSString* defaultDateStr; NSDate *date = [dateFormatter dateFromString:defaultDateStr];//上次设置的日期 [datePicker setDate:date]; datePicker.maximumDate = [dateFormatter dateFromString:maxDateStr]; datePicker.minimumDate = [dateFormatter dateFromString:minDateStr]; datePicker.delegate = self; datePicker.datePickerType = PGDatePickerTypeLine; datePicker.isHiddenMiddleText = false; datePicker.datePickerMode = PGDatePickerModeYearAndMonth; [self presentViewController:datePickManager animated:false completion:nil]; } -(void)youpaifsetupUI{ UIView *bgV = [[UIView alloc] init]; [self.view addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(NavBarHeight); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(LZCategoryViewHeight); }]; YOUPAIJXCategoryTitleBackgroundView *youpaipcategoryView = [[YOUPAIJXCategoryTitleBackgroundView alloc] init]; youpaipcategoryView.backgroundColor = [UIColor clearColor]; youpaipcategoryView.titles = self.youpaiptitlesArr; youpaipcategoryView.delegate = self; youpaipcategoryView.titleSelectedColor = [UIColor whiteColor]; youpaipcategoryView.titleColor = LZ273145Color; youpaipcategoryView.titleColorGradientEnabled = YES; youpaipcategoryView.titleFont = LCFont(12.0f); youpaipcategoryView.titleSelectedFont = LCBoldFont(12.0f); youpaipcategoryView.cellWidth = 65.0f; youpaipcategoryView.cellSpacing = 0.01f; youpaipcategoryView.normalBackgroundColor = [UIColor clearColor]; if ([LCSaveData getWhiteVersion]) { youpaipcategoryView.selectedBackgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(65.0f, 25.0f) FromColors:@[LCWhiteColor,LCWhiteColor] ByGradientType:GradientLeftToRight]]; }else{ youpaipcategoryView.selectedBackgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(65.0f, 25.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; } youpaipcategoryView.averageCellSpacingEnabled = NO; youpaipcategoryView.normalBorderColor = [UIColor clearColor]; youpaipcategoryView.selectedBorderColor = [UIColor clearColor]; youpaipcategoryView.borderLineWidth = 0; youpaipcategoryView.backgroundCornerRadius = 12.5f; youpaipcategoryView.backgroundWidth = 65.0f; youpaipcategoryView.backgroundHeight = 25.0f; [bgV addSubview:youpaipcategoryView]; self.youpaipcategoryView = youpaipcategoryView; [youpaipcategoryView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.centerX.equalTo(bgV); make.width.offset(65.0f * 2.0f + 40.0f); }]; JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self]; pagerView.listCellBackgroundColor = [UIColor clearColor]; [self.view addSubview:pagerView]; [pagerView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(bgV.mas_bottom).offset(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(-SafeHeight); }]; self.youpaippagerView = pagerView; self.youpaipcategoryView.listContainer = self.youpaippagerView; } // 返回列表的数量 - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { return self.youpaiptitlesArr.count; } // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例 - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { // 0:全部 1:收益 2:支出 3:其他 NSArray *typeArr = @[@"2",@"1"]; NSArray *newtypeArr = @[@"1",@"2"]; YOUPAIHRBillSubDetailVC *vc = [YOUPAIHRBillSubDetailVC new]; vc.youpaiptype = typeArr[index]; vc.newtype = newtypeArr[index]; vc.youpaipcate_id = self.youpaipcate_id; return vc; } @end