NYHomePageOneBigItemViewModel.m 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  23. self.sxlxtStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",[RQ_YDT_USER_Question_Module getDoQuestionNum],allCount]];
  24. RAC(self, sxlxtStr) = [[RACSignal combineLatest:@[RACObserve(RQ_YDTQuestion_Module, subjectOneArr), RACObserve(RQ_YDTQuestion_Module, subjectFourArr)] reduce:^id (NSArray *subjectOneArr, NSArray *subjectFourArr) {
  25. @strongify(self)
  26. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  27. return [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",[RQ_YDT_USER_Question_Module getDoQuestionNum],allCount]];
  28. }] takeUntil:self.rac_willDeallocSignal];
  29. NSString *score = [NSString stringWithFormat:@"%@",@"0"];
  30. NSString *fen = [NSString stringWithFormat:@"分"];
  31. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  32. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  33. self.mnksStr = myScoreAttrStr;//模拟考试
  34. RAC(self, mnksStr) = [[RACSignal combineLatest:@[RACObserve(RQ_COMMON_MANAGER, examResultOneListArr), RACObserve(RQ_COMMON_MANAGER, examResultFourListArr)] reduce:^id (NSArray *examResultOneListArr, NSArray *examResultFourListArr) {
  35. @strongify(self)
  36. NSArray *arr;
  37. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectOne) {
  38. arr = examResultOneListArr;
  39. }
  40. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  41. arr = examResultFourListArr;
  42. }
  43. float max = [[[arr.rac_sequence.signal map:^id _Nullable(RQExamResultModel *examResultModel) {
  44. return examResultModel.score;
  45. }].toArray valueForKeyPath:@"@max.floatValue"] floatValue];
  46. NSString *score = [NSString qmui_stringWithCGFloat:max decimal:0];
  47. NSString *fen = [NSString stringWithFormat:@"分"];
  48. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  49. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  50. return myScoreAttrStr;
  51. }] takeUntil:self.rac_willDeallocSignal];
  52. }
  53. return self;
  54. }
  55. @end