NYHomePageOneBigItemViewModel.m 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 treeListModel:(nonnull RQTreeListModel *)treeListModel {
  15. if (self = [super init]) {
  16. @weakify(self)
  17. self.homePageCarType = homePageCarType;
  18. self.homePageSubjectType = homePageSubjectType;
  19. self.treeListModel = treeListModel;
  20. CGFloat width = RQ_SCREEN_WIDTH;
  21. CGFloat height = RQ_FIT_HORIZONTAL(363.f);
  22. self.itemSize = CGSizeMake(width, height);
  23. NSArray *readList = [NYTools readExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
  24. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  25. self.sxlxtStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",readList.count,allCount]];
  26. RAC(self, sxlxtStr) = [[RACSignal combineLatest:@[RACObserve(RQ_YDTQuestion_Module, subjectOneArr), RACObserve(RQ_YDTQuestion_Module, subjectFourArr)] reduce:^id (NSArray *subjectOneArr, NSArray *subjectFourArr) {
  27. @strongify(self)
  28. NSArray *readList = [NYTools readExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
  29. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:self.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  30. return [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld/%ld",readList.count,allCount]];
  31. }] takeUntil:self.rac_willDeallocSignal];
  32. NSString *score = [NSString stringWithFormat:@"%@",@"0"];
  33. NSString *fen = [NSString stringWithFormat:@"分"];
  34. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  35. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  36. self.mnksStr = myScoreAttrStr;//模拟考试
  37. RAC(self, mnksStr) = [[RACSignal combineLatest:@[RACObserve(RQ_COMMON_MANAGER, examResultOneListArr), RACObserve(RQ_COMMON_MANAGER, examResultFourListArr)] reduce:^id (NSArray *examResultOneListArr, NSArray *examResultFourListArr) {
  38. @strongify(self)
  39. NSArray *arr;
  40. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectOne) {
  41. arr = examResultOneListArr;
  42. }
  43. if (self.homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  44. arr = examResultFourListArr;
  45. }
  46. float max = [[[arr.rac_sequence.signal map:^id _Nullable(RQExamResultModel *examResultModel) {
  47. return examResultModel.score;
  48. }].toArray valueForKeyPath:@"@max.floatValue"] floatValue];
  49. NSString *score = [NSString qmui_stringWithCGFloat:max decimal:0];
  50. NSString *fen = [NSString stringWithFormat:@"分"];
  51. NSString *myScore = [NSString stringWithFormat:@"%@%@",score,fen];
  52. NSMutableAttributedString *myScoreAttrStr = [[NSMutableAttributedString alloc] initWithString:myScore];
  53. return myScoreAttrStr;
  54. }] takeUntil:self.rac_willDeallocSignal];
  55. }
  56. return self;
  57. }
  58. @end