NYHomePageOneBigItemViewModel.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // NYHomePageOneBigItemViewModel.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/11/22.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. //
  8. #import "NYHomePageOneBigItemViewModel.h"
  9. @interface NYHomePageOneBigItemViewModel ()
  10. @property (nonatomic, readwrite, assign) RQHomePageCarType homePageCarType;
  11. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  12. @end
  13. @implementation NYHomePageOneBigItemViewModel
  14. - (instancetype)initWithNYHomePageCarType:(RQHomePageCarType)homePageCarType homePageSubjectType:(RQHomePageSubjectType)homePageSubjectType {
  15. if (self = [super init]) {
  16. @weakify(self)
  17. self.homePageCarType = homePageCarType;
  18. self.homePageSubjectType = homePageSubjectType;
  19. CGFloat width = RQ_SCREEN_WIDTH;
  20. CGFloat height = RQ_FIT_HORIZONTAL(363.f);
  21. self.itemSize = CGSizeMake(width, height);
  22. NSArray *readList = [NYTools readExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
  23. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  24. self.sxlxtStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",readList.count,allCount]];
  25. RAC(self, sxlxtStr) = [[RACSignal combineLatest:@[RACObserve(RQ_YDTQuestion_Module, subjectOneArr), RACObserve(RQ_YDTQuestion_Module, subjectFourArr)] reduce:^id (NSArray *subjectOneArr, NSArray *subjectFourArr) {
  26. @strongify(self)
  27. NSArray *readList = [NYTools readExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
  28. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  29. return [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",readList.count,allCount]];
  30. }] takeUntil:self.rac_willDeallocSignal];
  31. NSString *score = [NSString stringWithFormat:@"%@",@"0"];
  32. NSString *fen = [NSString stringWithFormat:@"分"];
  33. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  34. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  35. self.mnksStr = myScoreAttrStr;//模拟考试
  36. RAC(self, mnksStr) = [[RACSignal combineLatest:@[RACObserve(RQ_COMMON_MANAGER, examResultOneListArr), RACObserve(RQ_COMMON_MANAGER, examResultFourListArr)] reduce:^id (NSArray *examResultOneListArr, NSArray *examResultFourListArr) {
  37. @strongify(self)
  38. NSArray *arr;
  39. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectOne) {
  40. arr = examResultOneListArr;
  41. }
  42. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  43. arr = examResultFourListArr;
  44. }
  45. float max = [[[arr.rac_sequence.signal map:^id _Nullable(RQExamResultModel *examResultModel) {
  46. return examResultModel.score;
  47. }].toArray valueForKeyPath:@"@max.floatValue"] floatValue];
  48. NSString *score = [NSString qmui_stringWithCGFloat:max decimal:0];
  49. NSString *fen = [NSString stringWithFormat:@"分"];
  50. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  51. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  52. return myScoreAttrStr;
  53. }] takeUntil:self.rac_willDeallocSignal];
  54. }
  55. return self;
  56. }
  57. @end