RQHomeSubPageListCell.m 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // RQHomeSubPageListCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/4.
  6. //
  7. #import "RQHomeSubPageListCell.h"
  8. @interface RQHomeSubPageListCell ()
  9. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  10. @property (weak, nonatomic) IBOutlet UIButton *voiceExplanationBtn;
  11. @property (weak, nonatomic) IBOutlet UIButton *singleTestBtn;
  12. @property (weak, nonatomic) IBOutlet UIButton *specialExplanationBtn;
  13. @property (nonatomic, readwrite, strong) RQHomeSubPageListItemViewModel *viewModel;
  14. @property (nonatomic, readwrite, retain) FMDatabase *db;
  15. @property (nonatomic, readwrite, retain) FMDatabaseQueue *dbQueue;
  16. @end
  17. @implementation RQHomeSubPageListCell
  18. #pragma mark - PublicMethods
  19. + (instancetype)cellWithTableView:(UITableView *)tableView {
  20. static NSString *ID = @"RQHomeSubPageListCell";
  21. RQHomeSubPageListCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  22. if (!cell) {
  23. cell = [self rq_viewFromXib];
  24. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  25. }
  26. return cell;
  27. }
  28. - (void)bindViewModel:(RQHomeSubPageListItemViewModel *)viewModel {
  29. _viewModel = viewModel;
  30. NSString *title = viewModel.title;
  31. if([title containsString:@","]){
  32. title = [[title componentsSeparatedByString:@","] firstObject];
  33. }
  34. _titleLabel.text = title;
  35. _specialExplanationBtn.hidden = ![viewModel.title isEqualToString:@"地方题"];
  36. [_specialExplanationBtn setTitleNormal:[NSString stringWithFormat:@"%@地方题专项讲解",(_viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectOne)? @"科目一" : (_viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectFour)? @"科目四" : @""]];
  37. _voiceExplanationBtn.hidden = !_specialExplanationBtn.hidden;
  38. _singleTestBtn.hidden = !_specialExplanationBtn.hidden;
  39. }
  40. #pragma mark - SystemMethods
  41. - (void)awakeFromNib {
  42. [super awakeFromNib];
  43. [self rq_setViewAction];
  44. }
  45. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  46. [super setSelected:selected animated:animated];
  47. // Configure the view for the selected state
  48. }
  49. #pragma mark - PrivateMethods
  50. - (void)rq_setViewAction {
  51. }
  52. - (IBAction)voiceExplanationAction:(id)sender {
  53. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  54. RQHomePageCarTypeKey : @(_viewModel.homePageCarType),
  55. RQHomePageSubjectTypeKey : @(_viewModel.homePageSubjectType),
  56. RQHomeSubPageTypeKey : @(_viewModel.homeSubPageType),
  57. RQViewModelIDKey : _viewModel.title,
  58. RQViewCommonValueKey : @(0),
  59. }];
  60. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  61. }
  62. - (IBAction)singleTestAction:(id)sender {
  63. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  64. RQHomePageCarTypeKey : @(_viewModel.homePageCarType),
  65. RQHomePageSubjectTypeKey : @(_viewModel.homePageSubjectType),
  66. RQHomeSubPageTypeKey : @(_viewModel.homeSubPageType),
  67. RQViewModelIDKey : _viewModel.title,
  68. RQExerciseTypeKey : @(RQExerciseType_Test),
  69. RQViewCommonValueKey : @(0),
  70. }];
  71. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  72. }
  73. - (IBAction)localBtnAction:(id)sender {
  74. [self.viewModel.gotoLocalTopicsCommand execute:nil];
  75. }
  76. @end