123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- //
- // RQExerciseAnswerCell.m
- // JSJP
- //
- // Created by 张嵘 on 2021/8/16.
- //
- #import "RQExerciseAnswerCell.h"
- @interface RQExerciseAnswerCell ()
- @property (nonatomic, readwrite, strong) RQExerciseAnswerItemViewModel *viewModel;
- @property (weak, nonatomic) IBOutlet UILabel *answerLabel;
- @property (weak, nonatomic) IBOutlet QMUIButton *lookSkillBtn;
- @property (weak, nonatomic) IBOutlet YYLabel *skillLabel;
- @property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
- @end
- @implementation RQExerciseAnswerCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *ID = @"RQExerciseAnswerCell";
- RQExerciseAnswerCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (!cell) {
- cell = [self rq_viewFromXib];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)bindViewModel:(RQExerciseAnswerItemViewModel *)viewModel {
- _viewModel = viewModel;
- @weakify(self)
-
- RAC(self.answerLabel, text) = [[RACObserve(viewModel, answerString) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
-
- [[[[RACObserve(viewModel, skillHeight) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread] distinctUntilChanged] subscribeNext:^(id _Nullable x) {
- @strongify(self)
- self.coverImageView.image = [UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
- graColor.fromColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:0.2];
- graColor.toColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:1.f];
- graColor.type = QQGradualChangeTypeLeftToRight;
- } size:CGSizeMake(RQ_SCREEN_WIDTH - 32.f - 16.f - RQ_FIT_HORIZONTAL(128.f) + 30.f, viewModel.skillHeight) cornerRadius:QQRadiusZero];
- }];
-
- RAC(self.skillLabel, attributedText) = [[RACObserve(viewModel, skillString) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
-
- [[[[RACObserve(viewModel, ydtJSModel) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread] distinctUntilChanged] subscribeNext:^(RQYDTJSModel *ydtJSModel) {
- @strongify(self)
- if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {
- if (RQ_VIP_Module.isSubject1Vip) {
- self.coverImageView.hidden = YES;
- self.lookSkillBtn.hidden = YES;
- } else {
- self.coverImageView.hidden = RQObjectIsNil(ydtJSModel);
- self.lookSkillBtn.hidden = RQObjectIsNil(ydtJSModel);
- }
- } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) {
- if (RQ_VIP_Module.isSubject4Vip) {
- self.coverImageView.hidden = YES;
- self.lookSkillBtn.hidden = YES;
- } else {
- self.coverImageView.hidden = RQObjectIsNil(ydtJSModel);
- self.lookSkillBtn.hidden = RQObjectIsNil(ydtJSModel);
- }
- } else {
- self.coverImageView.hidden = YES;
- self.lookSkillBtn.hidden = YES;
- }
- self.skillLabel.hidden = RQObjectIsNil(ydtJSModel);
- }];
-
-
-
-
-
-
- }
- #pragma mark - SystemMethods
- - (void)awakeFromNib {
- [super awakeFromNib];
- @weakify(self)
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self)
- self.lookSkillBtn.imagePosition = QMUIButtonImagePositionRight;
- [self.lookSkillBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
- graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FF7E4D"];
- graColor.toColor = [UIColor qmui_colorWithHexString:@"#FF4D53"];
- graColor.type = QQGradualChangeTypeLeftToRight;
- } size:CGSizeMake(RQ_FIT_HORIZONTAL(128.f), RQ_FIT_HORIZONTAL(34.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(34.f) / 2.f)] forState:UIControlStateNormal];
-
- NSInteger line = RQ_COMMON_MANAGER.APP_SWITCH? 0 : ((RQ_VIP_Module.isSubject1Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne)? 0 : ((RQ_VIP_Module.isSubject4Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour)? 0 : 1));
- self.skillLabel.numberOfLines = line;
-
- });
-
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (IBAction)showSkillAction:(id)sender {
- [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
- }
- @end
|