RQSimulateExamViewController.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];
  40. }
  41. - (UIStatusBarStyle)preferredStatusBarStyle {
  42. /// 需要手动调用 navigationAnimator.statusbarStyleBlock 来告诉系统状态栏的变化
  43. if (self.navigationAnimator) {
  44. return self.navigationAnimator.statusbarStyleBlock(self.navigationAnimator, self.navigationAnimator.progress);
  45. }
  46. return [super preferredStatusBarStyle];
  47. }
  48. #pragma mark - <QMUINavigationControllerAppearanceDelegate>
  49. - (UIImage *)qmui_navigationBarBackgroundImage {
  50. return self.navigationAnimator.backgroundImageBlock(self.navigationAnimator, self.navigationAnimator.progress);
  51. }
  52. - (UIImage *)qmui_navigationBarShadowImage {
  53. return self.navigationAnimator.shadowImageBlock(self.navigationAnimator, self.navigationAnimator.progress);
  54. }
  55. - (UIColor *)qmui_navigationBarTintColor {
  56. return self.navigationAnimator.tintColorBlock(self.navigationAnimator, self.navigationAnimator.progress);
  57. }
  58. - (UIColor *)qmui_titleViewTintColor {
  59. return [self qmui_navigationBarTintColor];
  60. }
  61. #pragma mark - <QMUICustomNavigationBarTransitionDelegate>
  62. /// 为了展示接口的使用,QMUI Demo 没有打开配置表的 AutomaticCustomNavigationBarTransitionStyle,因此当 navigationBar 样式与默认样式不同时,需要手动在 customNavigationBarTransitionKey 里返回一个与其他界面不相同的值,这样才能使用自定义的 navigationBar 转场样式
  63. - (NSString *)customNavigationBarTransitionKey {
  64. return self.navigationAnimator.progress >= 1 ? nil : @"progress";
  65. }
  66. #pragma mark - OverrideMethods
  67. /// 配置tableView的区域
  68. - (UIEdgeInsets)contentInset {
  69. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  70. }
  71. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  72. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  73. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  74. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  75. }
  76. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  77. [cell bindViewModel:object];
  78. }
  79. - (void)gotoExamResultList {
  80. NSArray *arr = @[];
  81. if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {
  82. arr = RQ_COMMON_MANAGER.examResultOneListArr;
  83. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) {
  84. arr = RQ_COMMON_MANAGER.examResultFourListArr;
  85. }
  86. RQExamProbabilityViewModel *examProbabilityViewModel = [[RQExamProbabilityViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  87. RQViewModelUtilKey : arr,
  88. }];
  89. [RQ_APPDELEGATE.services pushViewModel:examProbabilityViewModel animated:YES];
  90. }
  91. - (UIBarButtonItem *)examResultListItem {
  92. if (!_examResultListItem) {
  93. _examResultListItem = [UIBarButtonItem rq_systemItemWithTitle:@"成绩单" titleColor:RQ_MAIN_BACKGROUNDCOLOR imageName:nil target:self selector:@selector(gotoExamResultList) textType:YES];
  94. }
  95. return _examResultListItem;
  96. }
  97. @end