// // YMGuildManagementViewController.m // MSYOUPAI // // Created by YoMi on 2024/3/26. // Copyright © 2024 MS. All rights reserved. // #import "YMGuildManagementViewController.h" #import "GHTabViewCell.h" #import "YMGuildManagementViewModel.h" #import "YMGuildManagementMyEarningsInfoView.h" #import #import "YMGuildManagementDatePickerViewController.h" @interface YMGuildManagementViewController () /// 公会管理VM @property (nonatomic, strong) YMGuildManagementViewModel *viewModel; @property (nonatomic, strong) UIImageView *bgImgv; @property (nonatomic, strong) UITableView *contentTableView; @property (nonatomic, strong) YMGuildManagementMyEarningsInfoView *infoView; @property (nonatomic, strong) YMGuildManagementDatePickerViewController *datePickManager; @end @implementation YMGuildManagementViewController @dynamic viewModel; - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } - (void)viewDidLoad { [super viewDidLoad]; self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow; [self.view addSubview:self.bgImgv]; [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) { make.top.leading.trailing.equalTo(self.view); make.height.equalTo(adapt(256)); }]; [self.view bringSubviewToFront:self.contentTableView]; [self.view bringSubviewToFront:self.ym_customNavView]; self.bgImgv.layer.zPosition = 1; self.contentTableView.layer.zPosition = 2; self.ym_customNavView.layer.zPosition = 3; } - (void)ym_setupViews{ [self.view insertSubview:self.contentTableView atIndex:0]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; } //- (void)updateViewConstraints{ // [super updateViewConstraints]; //} - (void)ym_bindViewModel{ [self.viewModel getGongHuiData]; [self.infoView ym_bindViewModel:self.viewModel]; @weakify(self) [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) { @strongify(self) [self.contentTableView reloadData]; }]; } - (UITableView *)contentTableView{ if (!_contentTableView) { _contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain]; _contentTableView.delegate = self; _contentTableView.dataSource = self; _contentTableView.showsVerticalScrollIndicator = NO; _contentTableView.showsHorizontalScrollIndicator = NO; _contentTableView.separatorColor = UIColor.clearColor; _contentTableView.backgroundColor = UIColor.clearColor; _contentTableView.estimatedRowHeight = 0; _contentTableView.estimatedSectionHeaderHeight = 0; _contentTableView.estimatedSectionFooterHeight = 0; [_contentTableView registerNib:[UINib nibWithNibName:@"GHTabViewCell" bundle:[NSBundle bundleForClass:[GHTabViewCell class]]] forCellReuseIdentifier:@"GHTabViewCell"]; _contentTableView.tableHeaderView = self.infoView; //_contentTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } return _contentTableView; } - (UIImageView *)bgImgv { if (!_bgImgv) { _bgImgv = [[UIImageView alloc] init]; _bgImgv.image = [UIImage imageNamed:@""]; _bgImgv.backgroundColor = HexColorFromRGB(0xFE57B1); } return _bgImgv; } - (YMGuildManagementMyEarningsInfoView *)infoView{ if (!_infoView) { _infoView = [[YMGuildManagementMyEarningsInfoView alloc]init]; _infoView.frame = CGRectMake(0, 0, kScreenWidth, adapt(316)); WS(weakSelf) // [[[_infoView.timeBtn1 rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { // weakSelf.isStart = YES; // weakSelf.isEnd = NO; // [weakSelf openDatePickerPopupView]; // }]; // [[[_infoView.timeBtn2 rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { // weakSelf.isStart = NO; // weakSelf.isEnd = YES; // [weakSelf openDatePickerPopupView]; // }]; [[[_infoView.btnView rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { // weakSelf.isStart = YES; // weakSelf.isEnd = NO; [weakSelf openDatePickerPopupView]; }]; [[[_infoView.sortBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel showBottomSort]; }]; } return _infoView; } //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ // self.infoView.backgroundColor = UIColor.whiteColor; // return self.infoView; //} // // //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ // return adapt(256); //} //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ // return 40; //} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 358; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.viewModel.mangeModel.list.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ GHTabViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GHTabViewCell"]; cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell ym_bindViewModel:self.viewModel.mangeModel.list[indexPath.item]]; return cell; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (scrollView.contentOffset.y > (adapt(256) - kYMNavHeight)) { self.ym_customNavView.backgroundColor = HexColorFromRGBA(0xFF76C0, 1); } else { self.ym_customNavView.backgroundColor = UIColor.clearColor; } } - (void)openDatePickerPopupView{ self.datePickManager = [[YMGuildManagementDatePickerViewController alloc] init]; self.datePickManager.isStart = YES; self.datePickManager.isEnd = NO; // self.datePickManager.isShadeBackground = true; // self.datePickManager.cancelButtonFont = LCFont(15); // self.datePickManager.confirmButtonFont = LCFont(15); // self.datePickManager.cancelButtonTextColor = LZA3AABEColor; // self.datePickManager.confirmButtonTextColor = LZ273145Color; // self.datePickManager.headerViewBackgroundColor = [UIColor whiteColor]; // self.datePickManager.headerHeight = 50; UIDatePicker *datePicker = self.datePickManager.datePicker; // datePicker.rowHeight = 35; // datePicker.middleTextColor = LZ273145Color; // datePicker.textColorOfSelectedRow = LZ273145Color; // datePicker.textColorOfOtherRow = LZD3D1D7Color; // datePicker.textFontOfSelectedRow = LCFont(17); // datePicker.textFontOfOtherRow = LCFont(17); // datePicker.lineBackgroundColor = [UIColor clearColor]; NSDate *currentDate = [NSDate date]; NSString *currentYear = [[YMCalendarUtils shareCalender] dateStrWithDate:currentDate dateStrFormatterStr:@"yyyy"]; NSString *currentMonth = [[YMCalendarUtils shareCalender] dateStrWithDate:currentDate dateStrFormatterStr:@"MM"]; NSString *currentDay = [[YMCalendarUtils shareCalender] dateStrWithDate:currentDate dateStrFormatterStr:@"dd"]; NSString *maxDateStr = stringFormat(@"%zd-%@-%@",[currentYear integerValue], currentMonth,currentDay); NSString *minDateStr = stringFormat(@"%zd-%@-%@",[currentYear integerValue] - 1, currentMonth,currentDay); datePicker.maximumDate = [[YMCalendarUtils shareCalender] dateWithDateStr:maxDateStr dateStrFormatterStr:@"yyyy-MM-dd"]; datePicker.minimumDate = [[YMCalendarUtils shareCalender] dateWithDateStr:minDateStr dateStrFormatterStr:@"yyyy-MM-dd"]; // datePicker.delegate = self; // datePicker.datePickerType = PGDatePickerTypeLine; // datePicker.isHiddenMiddleText = false; // datePicker.datePickerMode = PGDatePickerModeDate; WS(weakSelf) [[[self.datePickManager.confirmButn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf dismissViewControllerAnimated:false completion:nil]; NSDate *selectedDate = weakSelf.datePickManager.datePicker.date; NSCalendar *calder = [NSCalendar currentCalendar]; NSDateComponents *dateComponents = [calder components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:selectedDate]; NSString *endTimeStr = [weakSelf endTimeStr:[dateComponents year] :[dateComponents month] :[dateComponents day]]; if (weakSelf.datePickManager.isStart) { weakSelf.viewModel.startTime = endTimeStr; [weakSelf.datePickManager setStartTime:weakSelf.viewModel.startTime]; } if (weakSelf.datePickManager.isEnd) { weakSelf.viewModel.endTime = endTimeStr; [weakSelf.datePickManager setEndTime:weakSelf.viewModel.endTime]; } [weakSelf.viewModel getGongHuiData]; }]; self.datePickManager.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self presentViewController:self.datePickManager animated:false completion:nil]; } //- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents{ // NSString *time = [self endTimeStr:[dateComponents year] :[dateComponents month] :[dateComponents day]]; // if (self.isStart) { // self.viewModel.startTime = time; // [self.datePickManager setStartTime:time]; // } // if (self.isEnd) { // self.viewModel.endTime = time; // [self.datePickManager setEndTime:time]; // } // [self.viewModel getGongHuiData]; //} // - (NSString*)endTimeStr:(NSInteger)year :(NSInteger)month :(NSInteger)day{ NSString *dayStr = [NSString stringWithFormat:@"%ld",day]; NSString *monthStr = [NSString stringWithFormat:@"%ld",month]; if(day< 10){ dayStr = [NSString stringWithFormat:@"0%ld",day]; } if(month < 10){ monthStr = [NSString stringWithFormat:@"0%ld",month]; } return [NSString stringWithFormat:@"%ld-%@-%@",year,monthStr,dayStr]; } @end