// // RQSimulateExamSituationCell.m // jiaPei // // Created by 张嵘 on 2022/8/2. // Copyright © 2022 JCZ. All rights reserved. // #import "RQSimulateExamSituationCell.h" @interface RQSimulateExamSituationCell () @property (nonatomic, readwrite, strong) RQSimulateExamSituationItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIView *myContentView; @property (weak, nonatomic) IBOutlet QMUIButton *toDoExamBtn; @property (weak, nonatomic) IBOutlet QMUIButton *kuaiSuTiFenBtn; @property (nonatomic, readwrite, strong) ZHLineChartView *lineView; @property (weak, nonatomic) IBOutlet UIView *lineSuperView; @property (weak, nonatomic) IBOutlet UILabel *examNumLabel; @end @implementation RQSimulateExamSituationCell #pragma mark - PublicMethods + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"RQSimulateExamSituationCell"; RQSimulateExamSituationCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [self rq_viewFromXib]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)bindViewModel:(RQSimulateExamSituationItemViewModel *)viewModel { _viewModel = viewModel; _examNumLabel.text = [NSString qmui_stringWithNSInteger:RQObjectIsNil(viewModel.examResultArr)? 0 : viewModel.examResultArr.count]; NSMutableArray *arr = @[@0,@0,@0,@0,@0,@0,@0,@0,@0,@0].mutableCopy; NSArray *examResultModelArr = [[viewModel.examResultArr.rac_sequence.signal filter:^BOOL(RQExamResultModel * examResultModel) { return [viewModel.examResultArr indexOfObject:examResultModel] < 10; }].toArray.rac_sequence.signal map:^id _Nullable(RQExamResultModel * examResultModel) { return @(examResultModel.score.integerValue); }].toArray; examResultModelArr = [[examResultModelArr reverseObjectEnumerator] allObjects]; if (!RQObjectIsNil(examResultModelArr)) { for (int i = 0; i < examResultModelArr.count; i ++) { [arr replaceObjectAtIndex:i withObject:examResultModelArr[i]]; } _lineView.lineDataAry = arr.copy; [_lineView drawLineChart]; } } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code _toDoExamBtn.imagePosition = QMUIButtonImagePositionRight; _myContentView.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor; _kuaiSuTiFenBtn.layer.borderColor = RQColorFromHexString(@"#01C18D").CGColor; [_lineSuperView addSubview:self.lineView]; // [self.lineView drawLineChart]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (ZHLineChartView *)lineView { if (!_lineView) { _lineView = [[ZHLineChartView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 32.f - 32.f, (RQ_SCREEN_WIDTH - 64.f) * (246.f / 311.f))]; _lineView.max = @100; _lineView.min = @0; _lineView.horizontalDataArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"]; // _lineView.lineDataAry = @[@10, @100, @87, @55, @73, @46, @46, @60, @0, @89]; _lineView.splitCount = 5; _lineView.angle = 0; _lineView.bottomOffset = 10; _lineView.dataTextWidth = 50.f; _lineView.edge = UIEdgeInsetsMake(0, 0, 44, 0); _lineView.horizontalBottomLineColor = RQ_MAIN_TEXT_COLOR_2; _lineView.lineColor = RQ_MAIN_TEXT_COLOR_GREEN; _lineView.dataTextColor = RQ_MAIN_TEXT_COLOR_GREEN; _lineView.circleStrokeColor = RQ_MAIN_TEXT_COLOR_GREEN; _lineView.circleFillColor = RQ_MAIN_TEXT_COLOR_GREEN; _lineView.colorArr = [NSArray arrayWithObjects:(id)[[RQ_MAIN_TEXT_COLOR_GREEN colorWithAlphaComponent:0.4] CGColor],(id)[[[UIColor whiteColor] colorWithAlphaComponent:0.1] CGColor], nil]; _lineView.addCurve = NO; _lineView.toCenter = NO; _lineView.isShowHeadTail = NO; } return _lineView; } - (IBAction)toExamBtnAction:(id)sender { [RQ_APPDELEGATE.services popToRootViewModelAnimated:YES]; } - (IBAction)fastToUpBtnAction:(id)sender { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } @end