1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- //
- // RQExerciseToolBarCell.m
- // SDJK
- //
- // Created by 张嵘 on 2021/8/16.
- //
- #import "RQExerciseToolBarCell.h"
- @interface RQExerciseToolBarCell ()
- @property (nonatomic, readwrite, strong) RQExerciseToolBarItemViewModel *viewModel;
- @end
- @implementation RQExerciseToolBarCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *ID = @"RQExerciseToolBarCell";
- RQExerciseToolBarCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (!cell) {
- cell = [self rq_viewFromXib];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)bindViewModel:(RQExerciseToolBarItemViewModel *)viewModel {
- _viewModel = viewModel;
- RQCollectionModel *collectionModel = [[RQCollectionModel alloc] init];
- collectionModel.questionId = viewModel.exerciseModel._id;
- _collectBtn.selected = [RQ_SDJK_DB_MANAGER isExistWithRQCollectionModel:collectionModel];
-
- [_collectBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- if (!_collectBtn.selected) {
- [[RQ_HTTP_Service queryAddCollectionRecordWithQuestionId:viewModel.exerciseModel._id carType:viewModel.homePageCarType subject:viewModel.homePageSubjectType] subscribeNext:^(id _Nullable x) {
- [MBProgressHUD rq_showTips:@"收藏成功"];
- [RQ_SDJK_DB_MANAGER addCollectionRecordWithRQCollectionModel:collectionModel];
- _collectBtn.selected = [RQ_SDJK_DB_MANAGER isExistWithRQCollectionModel:collectionModel];
- NSLog(@"%@",x);
- } error:^(NSError * _Nullable error) {
- [MBProgressHUD rq_showErrorTips:error];
- }];
- } else {
- [[RQ_HTTP_Service queryCancleCollectionRecordWithQuestionIdArr:@[@(viewModel.exerciseModel._id)]] subscribeNext:^(id _Nullable x) {
- NSLog(@"%@" ,x);
- [MBProgressHUD rq_showTips:@"取消收藏成功"];
- [RQ_SDJK_DB_MANAGER deleteCollectionRecordWithQuestionId:collectionModel.questionId];
- _collectBtn.selected = [RQ_SDJK_DB_MANAGER isExistWithRQCollectionModel:collectionModel];
- } error:^(NSError * _Nullable error) {
- [MBProgressHUD rq_showErrorTips:error];
- }];
- }
- }];
-
- [_readingQuestionsAndAnswersBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- [viewModel.readingQuestionsAndAnswerCommand execute:nil];
- }];
-
- [_readingQuestionsBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- [RQ_MUSIC_MANAGER rq_resetStreamerWithURLString:viewModel.exerciseModel.issuemp3];
- }];
-
- [_skillExplanationBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- [viewModel.skillExplanationCommand execute:nil];
- }];
- }
- #pragma mark - SystemMethods
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|