1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // RQHomeSubPageListCell.m
- // SDJK
- //
- // Created by 张嵘 on 2021/8/4.
- //
- #import "RQHomeSubPageListCell.h"
- @interface RQHomeSubPageListCell ()
- @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
- @property (weak, nonatomic) IBOutlet UIButton *voiceExplanationBtn;
- @property (weak, nonatomic) IBOutlet UIButton *singleTestBtn;
- @property (weak, nonatomic) IBOutlet UIButton *specialExplanationBtn;
- @property (nonatomic, readwrite, strong) RQHomeSubPageListItemViewModel *viewModel;
- @property (nonatomic, readwrite, retain) FMDatabase *db;
- @property (nonatomic, readwrite, retain) FMDatabaseQueue *dbQueue;
- @end
- @implementation RQHomeSubPageListCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *ID = @"RQHomeSubPageListCell";
- RQHomeSubPageListCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (!cell) {
- cell = [self rq_viewFromXib];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)bindViewModel:(RQHomeSubPageListItemViewModel *)viewModel {
- _viewModel = viewModel;
- NSString *title = viewModel.title;
- if([title containsString:@","]){
- title = [[title componentsSeparatedByString:@","] firstObject];
- }
- _titleLabel.text = title;
- _specialExplanationBtn.hidden = ![viewModel.title isEqualToString:@"地方题"];
- [_specialExplanationBtn setTitleNormal:[NSString stringWithFormat:@"%@地方题专项讲解",(_viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectOne)? @"科目一" : (_viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectFour)? @"科目四" : @""]];
- _voiceExplanationBtn.hidden = !_specialExplanationBtn.hidden;
- _singleTestBtn.hidden = !_specialExplanationBtn.hidden;
- }
- #pragma mark - SystemMethods
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self rq_setViewAction];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- #pragma mark - PrivateMethods
- - (void)rq_setViewAction {
-
- }
- - (IBAction)voiceExplanationAction:(id)sender {
- RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQHomePageCarTypeKey : @(_viewModel.homePageCarType),
- RQHomePageSubjectTypeKey : @(_viewModel.homePageSubjectType),
- RQHomeSubPageTypeKey : @(_viewModel.homeSubPageType),
- RQViewModelIDKey : _viewModel.title,
- RQViewCommonValueKey : @(0),
- }];
- [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
- }
- - (IBAction)singleTestAction:(id)sender {
- RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQHomePageCarTypeKey : @(_viewModel.homePageCarType),
- RQHomePageSubjectTypeKey : @(_viewModel.homePageSubjectType),
- RQHomeSubPageTypeKey : @(_viewModel.homeSubPageType),
- RQViewModelIDKey : _viewModel.title,
- RQExerciseTypeKey : @(RQExerciseType_Test),
- RQViewCommonValueKey : @(0),
- }];
- [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
- }
- - (IBAction)localBtnAction:(id)sender {
- [self.viewModel.gotoLocalTopicsCommand execute:nil];
- }
- @end
|