RQExamSituationCell.m 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // RQExamSituationCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/7/27.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQExamSituationCell.h"
  9. @interface RQExamSituationCell ()
  10. @property (nonatomic, readwrite, strong) RQExamSituationItemViewModel *viewModel;
  11. @property (nonatomic, readwrite, strong) ZHLineChartView *lineView;
  12. @property (weak, nonatomic) IBOutlet UIView *lineSuperView;
  13. @property (weak, nonatomic) IBOutlet QMUIButton *historyExamResultBtn;
  14. @end
  15. @implementation RQExamSituationCell
  16. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  17. static NSString *ID = @"RQExamSituationCell";
  18. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  19. RQExamSituationCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  20. if (!cell) cell = [self rq_viewFromXib];
  21. return cell;
  22. }
  23. - (void)bindViewModel:(RQExamSituationItemViewModel *)viewModel {
  24. self.viewModel = viewModel;
  25. NSMutableArray *arr = @[@0,@0,@0,@0,@0,@0,@0,@0,@0,@0].mutableCopy;
  26. NSArray *examResultModelArr = [[viewModel.examResultArr.rac_sequence.signal filter:^BOOL(RQExamResultModel * examResultModel) {
  27. return [viewModel.examResultArr indexOfObject:examResultModel] < 10;
  28. }].toArray.rac_sequence.signal map:^id _Nullable(RQExamResultModel * examResultModel) {
  29. return @(examResultModel.score.integerValue);
  30. }].toArray;
  31. if (!RQObjectIsNil(examResultModelArr)) {
  32. for (int i = 0; i < examResultModelArr.count; i ++) {
  33. [arr replaceObjectAtIndex:i withObject:examResultModelArr[i]];
  34. }
  35. _lineView.lineDataAry = arr.copy;
  36. [_lineView drawLineChart];
  37. }
  38. }
  39. - (void)awakeFromNib {
  40. [super awakeFromNib];
  41. // Initialization code
  42. [_lineSuperView addSubview:self.lineView];
  43. // [self.lineView drawLineChart];
  44. _historyExamResultBtn.imagePosition = QMUIButtonImagePositionRight;
  45. }
  46. - (ZHLineChartView *)lineView {
  47. if (!_lineView) {
  48. _lineView = [[ZHLineChartView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 32.f, (RQ_SCREEN_WIDTH - 32.f) * (248.f / 343.f))];
  49. _lineView.max = @100;
  50. _lineView.min = @0;
  51. _lineView.horizontalDataArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"];
  52. _lineView.splitCount = 5;
  53. _lineView.angle = 0;
  54. _lineView.bottomOffset = 10;
  55. _lineView.dataTextWidth = 50.f;
  56. _lineView.edge = UIEdgeInsetsMake(0, 0, 44, 0);
  57. _lineView.horizontalBottomLineColor = RQ_MAIN_TEXT_COLOR_2;
  58. _lineView.lineColor = RQ_MAIN_TEXT_COLOR_GREEN;
  59. _lineView.dataTextColor = RQ_MAIN_TEXT_COLOR_GREEN;
  60. _lineView.circleStrokeColor = RQ_MAIN_TEXT_COLOR_GREEN;
  61. _lineView.circleFillColor = RQ_MAIN_TEXT_COLOR_GREEN;
  62. _lineView.colorArr = [NSArray arrayWithObjects:(id)[[RQ_MAIN_TEXT_COLOR_GREEN colorWithAlphaComponent:0.4] CGColor],(id)[[[UIColor whiteColor] colorWithAlphaComponent:0.1] CGColor], nil];
  63. _lineView.addCurve = NO;
  64. _lineView.toCenter = NO;
  65. _lineView.isShowHeadTail = NO;
  66. }
  67. return _lineView;
  68. }
  69. - (IBAction)historyExamResultBtnAction:(id)sender {
  70. RQExamProbabilityViewModel *examProbabilityViewModel = [[RQExamProbabilityViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  71. RQViewModelUtilKey : self.viewModel.examResultArr,
  72. }];
  73. [RQ_APPDELEGATE.services pushViewModel:examProbabilityViewModel animated:YES];
  74. }
  75. @end