RQSimulateExamViewController.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // RQSimulateExamViewController.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/2.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQSimulateExamViewController.h"
  9. @interface RQSimulateExamViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) RQSimulateExamViewModel *viewModel;
  12. @property (nonatomic, readwrite, strong) QMUINavigationBarScrollingAnimator *navigationAnimator;
  13. @property (nonatomic, readwrite, strong) UIBarButtonItem *examResultListItem;
  14. @end
  15. @implementation RQSimulateExamViewController
  16. @dynamic viewModel;
  17. #pragma mark - SystemMethod
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. @weakify(self)
  21. [self.navigationItem setRightBarButtonItems:@[self.examResultListItem]];
  22. self.navigationAnimator = [[QMUINavigationBarScrollingAnimator alloc] init];
  23. self.navigationAnimator.scrollView = self.tableView;// 指定要关联的 scrollView
  24. self.navigationAnimator.offsetYToStartAnimation = 30;// 设置滚动的起点,值即表示在默认停靠的位置往下滚动多少距离后即触发动画,默认是 0
  25. self.navigationAnimator.distanceToStopAnimation = 64;// 设置从起点开始滚动多长的距离达到终点
  26. self.navigationAnimator.backgroundImageBlock = ^UIImage * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) {
  27. return [[UIImage qmui_imageWithColor:RQ_MAIN_COLOR size:CGSizeMake(RQ_SCREEN_WIDTH, RQ_APPLICATION_NAV_BAR_HEIGHT) cornerRadius:0] qmui_imageWithAlpha:progress];
  28. };
  29. self.navigationAnimator.shadowImageBlock = ^UIImage * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) {
  30. return [NavBarShadowImage qmui_imageWithAlpha:progress];
  31. };
  32. self.navigationAnimator.tintColorBlock = ^UIColor * _Nonnull(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) {
  33. return [UIColor qmui_colorFromColor:UIColorBlack toColor:NavBarTintColor progress:progress];
  34. };
  35. self.navigationAnimator.titleViewTintColorBlock = self.navigationAnimator.tintColorBlock;
  36. self.navigationAnimator.statusbarStyleBlock = ^UIStatusBarStyle(QMUINavigationBarScrollingAnimator * _Nonnull animator, float progress) {
  37. return progress < .25 ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
  38. };
  39. if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne && !RQ_VIP_Module.isSubject1Vip){
  40. [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告
  41. }
  42. if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour && !RQ_VIP_Module.isSubject4Vip){
  43. [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告
  44. }
  45. }
  46. - (UIStatusBarStyle)preferredStatusBarStyle {
  47. /// 需要手动调用 navigationAnimator.statusbarStyleBlock 来告诉系统状态栏的变化
  48. if (self.navigationAnimator) {
  49. return self.navigationAnimator.statusbarStyleBlock(self.navigationAnimator, self.navigationAnimator.progress);
  50. }
  51. return [super preferredStatusBarStyle];
  52. }
  53. #pragma mark - <QMUINavigationControllerAppearanceDelegate>
  54. - (UIImage *)qmui_navigationBarBackgroundImage {
  55. return self.navigationAnimator.backgroundImageBlock(self.navigationAnimator, self.navigationAnimator.progress);
  56. }
  57. - (UIImage *)qmui_navigationBarShadowImage {
  58. return self.navigationAnimator.shadowImageBlock(self.navigationAnimator, self.navigationAnimator.progress);
  59. }
  60. - (UIColor *)qmui_navigationBarTintColor {
  61. return self.navigationAnimator.tintColorBlock(self.navigationAnimator, self.navigationAnimator.progress);
  62. }
  63. - (UIColor *)qmui_titleViewTintColor {
  64. return [self qmui_navigationBarTintColor];
  65. }
  66. #pragma mark - <QMUICustomNavigationBarTransitionDelegate>
  67. /// 为了展示接口的使用,QMUI Demo 没有打开配置表的 AutomaticCustomNavigationBarTransitionStyle,因此当 navigationBar 样式与默认样式不同时,需要手动在 customNavigationBarTransitionKey 里返回一个与其他界面不相同的值,这样才能使用自定义的 navigationBar 转场样式
  68. - (NSString *)customNavigationBarTransitionKey {
  69. return self.navigationAnimator.progress >= 1 ? nil : @"progress";
  70. }
  71. #pragma mark - OverrideMethods
  72. /// 配置tableView的区域
  73. - (UIEdgeInsets)contentInset {
  74. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  75. }
  76. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  77. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  78. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  79. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  80. }
  81. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  82. [cell bindViewModel:object];
  83. }
  84. - (void)gotoExamResultList {
  85. NSArray *arr = @[];
  86. if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {
  87. arr = RQ_COMMON_MANAGER.examResultOneListArr;
  88. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) {
  89. arr = RQ_COMMON_MANAGER.examResultFourListArr;
  90. }
  91. RQExamProbabilityViewModel *examProbabilityViewModel = [[RQExamProbabilityViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  92. RQViewModelUtilKey : arr,
  93. }];
  94. [RQ_APPDELEGATE.services pushViewModel:examProbabilityViewModel animated:YES];
  95. }
  96. - (UIBarButtonItem *)examResultListItem {
  97. if (!_examResultListItem) {
  98. _examResultListItem = [UIBarButtonItem rq_systemItemWithTitle:@"成绩单" titleColor:RQ_MAIN_BACKGROUNDCOLOR imageName:nil target:self selector:@selector(gotoExamResultList) textType:YES];
  99. }
  100. return _examResultListItem;
  101. }
  102. @end