RQSimulateExamSituationCell.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // RQSimulateExamSituationCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/2.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQSimulateExamSituationCell.h"
  9. @interface RQSimulateExamSituationCell ()
  10. @property (nonatomic, readwrite, strong) RQSimulateExamSituationItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIView *myContentView;
  12. @property (weak, nonatomic) IBOutlet QMUIButton *toDoExamBtn;
  13. @property (weak, nonatomic) IBOutlet QMUIButton *kuaiSuTiFenBtn;
  14. @property (nonatomic, readwrite, strong) ZHLineChartView *lineView;
  15. @property (weak, nonatomic) IBOutlet UIView *lineSuperView;
  16. @property (weak, nonatomic) IBOutlet UILabel *examNumLabel;
  17. @end
  18. @implementation RQSimulateExamSituationCell
  19. #pragma mark - PublicMethods
  20. + (instancetype)cellWithTableView:(UITableView *)tableView {
  21. static NSString *ID = @"RQSimulateExamSituationCell";
  22. RQSimulateExamSituationCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  23. if (!cell) {
  24. cell = [self rq_viewFromXib];
  25. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  26. }
  27. return cell;
  28. }
  29. - (void)bindViewModel:(RQSimulateExamSituationItemViewModel *)viewModel {
  30. _viewModel = viewModel;
  31. _examNumLabel.text = [NSString qmui_stringWithNSInteger:RQObjectIsNil(viewModel.examResultArr)? 0 : viewModel.examResultArr.count];
  32. NSMutableArray *arr = @[@0,@0,@0,@0,@0,@0,@0,@0,@0,@0].mutableCopy;
  33. NSArray *examResultModelArr = [[viewModel.examResultArr.rac_sequence.signal filter:^BOOL(RQExamResultModel * examResultModel) {
  34. return [viewModel.examResultArr indexOfObject:examResultModel] < 10;
  35. }].toArray.rac_sequence.signal map:^id _Nullable(RQExamResultModel * examResultModel) {
  36. return @(examResultModel.score.integerValue);
  37. }].toArray;
  38. examResultModelArr = [[examResultModelArr reverseObjectEnumerator] allObjects];
  39. if (!RQObjectIsNil(examResultModelArr)) {
  40. for (int i = 0; i < examResultModelArr.count; i ++) {
  41. [arr replaceObjectAtIndex:i withObject:examResultModelArr[i]];
  42. }
  43. _lineView.lineDataAry = arr.copy;
  44. [_lineView drawLineChart];
  45. }
  46. }
  47. - (void)awakeFromNib {
  48. [super awakeFromNib];
  49. // Initialization code
  50. _toDoExamBtn.imagePosition = QMUIButtonImagePositionRight;
  51. _myContentView.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
  52. _kuaiSuTiFenBtn.layer.borderColor = RQColorFromHexString(@"#01C18D").CGColor;
  53. [_lineSuperView addSubview:self.lineView];
  54. // [self.lineView drawLineChart];
  55. }
  56. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  57. [super setSelected:selected animated:animated];
  58. // Configure the view for the selected state
  59. }
  60. - (ZHLineChartView *)lineView {
  61. if (!_lineView) {
  62. _lineView = [[ZHLineChartView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 32.f - 32.f, (RQ_SCREEN_WIDTH - 64.f) * (246.f / 311.f))];
  63. _lineView.max = @100;
  64. _lineView.min = @0;
  65. _lineView.horizontalDataArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"];
  66. // _lineView.lineDataAry = @[@10, @100, @87, @55, @73, @46, @46, @60, @0, @89];
  67. _lineView.splitCount = 5;
  68. _lineView.angle = 0;
  69. _lineView.bottomOffset = 10;
  70. _lineView.dataTextWidth = 50.f;
  71. _lineView.edge = UIEdgeInsetsMake(0, 0, 44, 0);
  72. _lineView.horizontalBottomLineColor = RQ_MAIN_TEXT_COLOR_2;
  73. _lineView.lineColor = RQ_MAIN_TEXT_COLOR_GREEN;
  74. _lineView.dataTextColor = RQ_MAIN_TEXT_COLOR_GREEN;
  75. _lineView.circleStrokeColor = RQ_MAIN_TEXT_COLOR_GREEN;
  76. _lineView.circleFillColor = RQ_MAIN_TEXT_COLOR_GREEN;
  77. _lineView.colorArr = [NSArray arrayWithObjects:(id)[[RQ_MAIN_TEXT_COLOR_GREEN colorWithAlphaComponent:0.4] CGColor],(id)[[[UIColor whiteColor] colorWithAlphaComponent:0.1] CGColor], nil];
  78. _lineView.addCurve = NO;
  79. _lineView.toCenter = NO;
  80. _lineView.isShowHeadTail = NO;
  81. }
  82. return _lineView;
  83. }
  84. - (IBAction)toExamBtnAction:(id)sender {
  85. [RQ_APPDELEGATE.services popToRootViewModelAnimated:YES];
  86. }
  87. - (IBAction)fastToUpBtnAction:(id)sender {
  88. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  89. }
  90. @end