// // RQSimulateExamViewController.m // jiaPei // // Created by 张嵘 on 2022/8/2. // Copyright © 2022 JCZ. All rights reserved. // #import "RQSimulateExamViewController.h" @interface RQSimulateExamViewController () /// viewModel @property (nonatomic, readonly, strong) RQSimulateExamViewModel *viewModel; @property (nonatomic, readwrite, strong) QMUINavigationBarScrollingAnimator *navigationAnimator; @property (nonatomic, readwrite, strong) UIBarButtonItem *examResultListItem; @end @implementation RQSimulateExamViewController @dynamic viewModel; #pragma mark - SystemMethod - (void)viewDidLoad { [super viewDidLoad]; @weakify(self) [self.navigationItem setRightBarButtonItems:@[self.examResultListItem]]; self.navigationAnimator = [[QMUINavigationBarScrollingAnimator alloc] init]; self.navigationAnimator.scrollView = self.tableView;// 指定要关联的 scrollView self.navigationAnimator.offsetYToStartAnimation = 30;// 设置滚动的起点,值即表示在默认停靠的位置往下滚动多少距离后即触发动画,默认是 0 self.navigationAnimator.distanceToStopAnimation = 64;// 设置从起点开始滚动多长的距离达到终点 self.navigationAnimator.backgroundImageBlock = ^UIImage * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) { return [[UIImage qmui_imageWithColor:RQ_MAIN_COLOR size:CGSizeMake(RQ_SCREEN_WIDTH, RQ_APPLICATION_NAV_BAR_HEIGHT) cornerRadius:0] qmui_imageWithAlpha:progress]; }; self.navigationAnimator.shadowImageBlock = ^UIImage * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) { return [NavBarShadowImage qmui_imageWithAlpha:progress]; }; self.navigationAnimator.tintColorBlock = ^UIColor * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) { return [UIColor qmui_colorFromColor:UIColorBlack toColor:NavBarTintColor progress:progress]; }; self.navigationAnimator.titleViewTintColorBlock = self.navigationAnimator.tintColorBlock; self.navigationAnimator.statusbarStyleBlock = ^UIStatusBarStyle(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) { return progress < .25 ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; }; if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne && !RQ_VIP_Module.isSubject1Vip){ [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告 } if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour && !RQ_VIP_Module.isSubject4Vip){ [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告 } } - (UIStatusBarStyle)preferredStatusBarStyle { /// 需要手动调用 navigationAnimator.statusbarStyleBlock 来告诉系统状态栏的变化 if (self.navigationAnimator) { return self.navigationAnimator.statusbarStyleBlock(self.navigationAnimator, self.navigationAnimator.progress); } return [super preferredStatusBarStyle]; } #pragma mark - - (UIImage *)qmui_navigationBarBackgroundImage { return self.navigationAnimator.backgroundImageBlock(self.navigationAnimator, self.navigationAnimator.progress); } - (UIImage *)qmui_navigationBarShadowImage { return self.navigationAnimator.shadowImageBlock(self.navigationAnimator, self.navigationAnimator.progress); } - (UIColor *)qmui_navigationBarTintColor { return self.navigationAnimator.tintColorBlock(self.navigationAnimator, self.navigationAnimator.progress); } - (UIColor *)qmui_titleViewTintColor { return [self qmui_navigationBarTintColor]; } #pragma mark - /// 为了展示接口的使用,QMUI Demo 没有打开配置表的 AutomaticCustomNavigationBarTransitionStyle,因此当 navigationBar 样式与默认样式不同时,需要手动在 customNavigationBarTransitionKey 里返回一个与其他界面不相同的值,这样才能使用自定义的 navigationBar 转场样式 - (NSString *)customNavigationBarTransitionKey { return self.navigationAnimator.progress >= 1 ? nil : @"progress"; } #pragma mark - OverrideMethods /// 配置tableView的区域 - (UIEdgeInsets)contentInset { return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0); } - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath { RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section]; RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row]; return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView]; } - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object { [cell bindViewModel:object]; } - (void)gotoExamResultList { NSArray *arr = @[]; if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) { arr = RQ_COMMON_MANAGER.examResultOneListArr; } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) { arr = RQ_COMMON_MANAGER.examResultFourListArr; } RQExamProbabilityViewModel *examProbabilityViewModel = [[RQExamProbabilityViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQViewModelUtilKey : arr, }]; [RQ_APPDELEGATE.services pushViewModel:examProbabilityViewModel animated:YES]; } - (UIBarButtonItem *)examResultListItem { if (!_examResultListItem) { _examResultListItem = [UIBarButtonItem rq_systemItemWithTitle:@"成绩单" titleColor:RQ_MAIN_BACKGROUNDCOLOR imageName:nil target:self selector:@selector(gotoExamResultList) textType:YES]; } return _examResultListItem; } @end