12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // RQExamSituationCell.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/7/27.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "RQExamSituationCell.h"
- @interface RQExamSituationCell ()
- @property (nonatomic, readwrite, strong) RQExamSituationItemViewModel *viewModel;
- @property (nonatomic, readwrite, strong) ZHLineChartView *lineView;
- @property (weak, nonatomic) IBOutlet UIView *lineSuperView;
- @property (weak, nonatomic) IBOutlet QMUIButton *historyExamResultBtn;
- @end
- @implementation RQExamSituationCell
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"RQExamSituationCell";
- [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
- RQExamSituationCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
- if (!cell) cell = [self rq_viewFromXib];
- return cell;
- }
- - (void)bindViewModel:(RQExamSituationItemViewModel *)viewModel {
- self.viewModel = viewModel;
- 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;
- 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
- [_lineSuperView addSubview:self.lineView];
- // [self.lineView drawLineChart];
- _historyExamResultBtn.imagePosition = QMUIButtonImagePositionRight;
- }
- - (ZHLineChartView *)lineView {
- if (!_lineView) {
- _lineView = [[ZHLineChartView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 32.f, (RQ_SCREEN_WIDTH - 32.f) * (248.f / 343.f))];
- _lineView.max = @100;
- _lineView.min = @0;
- _lineView.horizontalDataArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"];
- _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)historyExamResultBtnAction:(id)sender {
- RQExamProbabilityViewModel *examProbabilityViewModel = [[RQExamProbabilityViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQViewModelUtilKey : self.viewModel.examResultArr,
- }];
- [RQ_APPDELEGATE.services pushViewModel:examProbabilityViewModel animated:YES];
- }
- @end
|