RQExerciseSituationCell.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // RQExerciseSituationCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/2.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQExerciseSituationCell.h"
  9. @interface RQExerciseSituationCell ()
  10. @property (nonatomic, readwrite, strong) RQExerciseSituationItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIView *myContentView;
  12. @property (weak, nonatomic) IBOutlet QMUIButton *toDoExerciseBtn;
  13. @property (weak, nonatomic) IBOutlet UIProgressView *rightProgress;
  14. @property (weak, nonatomic) IBOutlet UIProgressView *errorProgress;
  15. @property (weak, nonatomic) IBOutlet UILabel *hasDoneLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *errorLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *unDoLabel;
  18. @end
  19. @implementation RQExerciseSituationCell
  20. #pragma mark - PublicMethods
  21. + (instancetype)cellWithTableView:(UITableView *)tableView {
  22. static NSString *ID = @"RQExerciseSituationCell";
  23. RQExerciseSituationCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  24. if (!cell) {
  25. cell = [self rq_viewFromXib];
  26. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  27. }
  28. return cell;
  29. }
  30. - (void)bindViewModel:(RQExerciseSituationItemViewModel *)viewModel {
  31. _viewModel = viewModel;
  32. NSInteger allCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:viewModel.homePageSubjectType exerciseType:RQExerciseType_Sequential];
  33. NSInteger wrongCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:viewModel.homePageSubjectType exerciseType:RQExerciseType_Wrong];
  34. NSInteger doCount = [RQ_YDTQuestion_Module getQuestionNumWithWithSubject:viewModel.homePageSubjectType exerciseType:RQExerciseType_Do];
  35. _hasDoneLabel.text = [NSString qmui_stringWithNSInteger:doCount];
  36. _errorLabel.text = [NSString qmui_stringWithNSInteger:wrongCount];
  37. _unDoLabel.text = [NSString qmui_stringWithNSInteger:allCount - doCount];
  38. CGFloat error = (wrongCount * 1.f / allCount);
  39. CGFloat right = (doCount * 1.f / allCount);
  40. _errorProgress.progress = error;
  41. _rightProgress.progress = right;
  42. }
  43. - (void)awakeFromNib {
  44. [super awakeFromNib];
  45. _toDoExerciseBtn.imagePosition = QMUIButtonImagePositionRight;
  46. _myContentView.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
  47. _rightProgress.transform = CGAffineTransformMakeScale(1.0, 3.0);
  48. _errorProgress.transform = CGAffineTransformMakeScale(1.0, 3.0);
  49. }
  50. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  51. [super setSelected:selected animated:animated];
  52. // Configure the view for the selected state
  53. }
  54. - (IBAction)toDoExerciseBtnAction:(id)sender {
  55. [RQ_APPDELEGATE.services popToRootViewModelAnimated:YES];
  56. }
  57. @end