RQHomeSubPageToolBarView.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // RQHomeSubPageToolBarView.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2021/12/10.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "RQHomeSubPageToolBarView.h"
  9. #import "TRListVC.h"
  10. #import "MyGradeVC.h"
  11. #import "ScoreRankVC.h"
  12. @interface RQHomeSubPageToolBarView ()
  13. @property (nonatomic, readwrite, strong) RQHomeSubPageToolBarGroupViewModel *viewModel;
  14. @end
  15. @implementation RQHomeSubPageToolBarView
  16. + (instancetype)reusableViewWithCollectionView:(UICollectionView *)collectionView OfKind:(NSString *)elementKind forIndexPath:(NSIndexPath *)indexPath {
  17. NSString *ID = [NSString stringWithFormat:@"%@%@", @"RQHomeSubPageToolBarView",elementKind];
  18. [collectionView registerNib:[UINib nibWithNibName:@"RQHomeSubPageToolBarView" bundle:nil] forSupplementaryViewOfKind:elementKind withReuseIdentifier:ID];
  19. RQHomeSubPageToolBarView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:elementKind withReuseIdentifier:ID forIndexPath:indexPath];
  20. if (!reusableView) reusableView = [self rq_viewFromXib];
  21. return reusableView;
  22. }
  23. - (void)bindViewModel:(RQHomeSubPageToolBarGroupViewModel *)viewModel {
  24. @weakify(self)
  25. self.viewModel = viewModel;
  26. [self.drivingTestRegulationsBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  27. @strongify(self)
  28. // TRListVC* vc = [[TRListVC alloc] init];
  29. // NSArray* arr = @[@"2016《机动车驾驶证申领和使用规定》",
  30. // @"中华人民共和国道路交通安全法",
  31. // @"道路交通安全违法行为处理程序规定",
  32. // @"道路交通事故处理程序规定",
  33. // @"酒驾新规"];
  34. //
  35. // [vc setModels:arr];
  36. // [vc setTitle:@"驾考法规"];
  37. // [self navPushHideTabbarToVC:vc];
  38. [self gotoMyGradeVC];
  39. }];
  40. [self.examinationSkillsBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  41. @strongify(self)
  42. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  43. [myDelegate setType:@"6"];
  44. [self gotoExerVC];
  45. } else {
  46. [self gotoScoreRank];
  47. }
  48. // TRListVC* vc = [[TRListVC alloc] init];
  49. // NSArray* arr = @[@"科目一考试技巧记忆口诀",
  50. // @"科目一考试应试必备技巧",
  51. // @"科目一到科目四,超牛的驾考经验技巧,科科必过!",
  52. // @"理论考试知识汇总",
  53. // @"【科目一】交规巧记十三条!",
  54. // @"3分钟,快速掌握考试车内提示灯如何操作",
  55. // @"日期类题目最头痛,来看看我们总结的快速学习方法!",
  56. // @"帮您快速巧记交规秘诀,看完想不过都难!",
  57. // @"交规理论考试十大“给力”攻略"];
  58. //
  59. // [vc setModels:arr];
  60. // [vc setTitle:@"考试技巧"];
  61. // [self navPushHideTabbarToVC:vc];
  62. }];
  63. [self.noQuestionsBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  64. @strongify(self)
  65. [myDelegate setType:@"10"];
  66. [self gotoExerVC];
  67. }];
  68. [self.myMistakeBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  69. @strongify(self)
  70. [myDelegate setType:@"4"];
  71. [self gotoExerVC];
  72. }];
  73. [self.myCollectionBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  74. @strongify(self)
  75. [myDelegate setType:@"7"];
  76. [self gotoExerVC];
  77. }];
  78. [[RACObserve(RQ_SHARE_FUNCTION, myErorNum) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  79. @strongify(self)
  80. self.myMistakeBtn.imageView.clipsToBounds = NO;
  81. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  82. [self.myMistakeBtn.imageView showBadgeWithStyle:WBadgeStyleNumber value:[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count animationType:WBadgeAnimTypeNone];
  83. } else {
  84. if ([defUser.car_type isEqualToString:@"2"]) {
  85. [self.myMistakeBtn.imageView showBadgeWithStyle:WBadgeStyleNumber value:[DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithMarkType:@"1"] animationType:WBadgeAnimTypeNone];
  86. } else {
  87. [self.myMistakeBtn.imageView showBadgeWithStyle:WBadgeStyleNumber value:[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count animationType:WBadgeAnimTypeNone];
  88. }
  89. }
  90. }];
  91. }
  92. - (void)navPushHideTabbarToVC:(UIViewController *)vc {
  93. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  94. [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
  95. } else {
  96. vc.hidesBottomBarWhenPushed = YES;
  97. [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
  98. vc.hidesBottomBarWhenPushed = NO;
  99. }
  100. }
  101. - (void)gotoExerVC {
  102. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  103. } else {
  104. if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
  105. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
  106. return;
  107. }
  108. }
  109. ExerciseVC *vc = [[ExerciseVC alloc] init];
  110. [self navPushHideTabbarToVC:vc];
  111. }
  112. - (void)gotoScoreRank {
  113. ScoreRankVC* vc = [[ScoreRankVC alloc] init];
  114. [self navPushHideTabbarToVC:vc];
  115. }
  116. - (void)gotoMyGradeVC {
  117. MyGradeVC* vc = [[MyGradeVC alloc] init];
  118. [self navPushHideTabbarToVC:vc];
  119. }
  120. - (void)awakeFromNib {
  121. [super awakeFromNib];
  122. self.drivingTestRegulationsBtn.imagePosition = QMUIButtonImagePositionTop;
  123. self.examinationSkillsBtn.imagePosition = QMUIButtonImagePositionTop;
  124. self.noQuestionsBtn.imagePosition = QMUIButtonImagePositionTop;
  125. self.myMistakeBtn.imagePosition = QMUIButtonImagePositionTop;
  126. self.myCollectionBtn.imagePosition = QMUIButtonImagePositionTop;
  127. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  128. self.drivingTestRegulationsBtn.hidden = YES;
  129. [self.examinationSkillsBtn setImage:[UIImage imageNamed:@"question_submit_exam_press_icon"] forState:UIControlStateNormal];
  130. [self.examinationSkillsBtn setTitleNormal:@"排除的题"];
  131. } else {
  132. [self.examinationSkillsBtn setImage:[UIImage imageNamed:@"subject1_rating_board_icon"] forState:UIControlStateNormal];
  133. [self.examinationSkillsBtn setTitleNormal:@"排行榜"];
  134. }
  135. }
  136. @end