// // RQProfileSubjectOneVipCell.m // jiaPei // // Created by 张嵘 on 2022/4/28. // Copyright © 2022 JCZ. All rights reserved. // #import "RQProfileSubjectOneVipCell.h" @interface RQProfileSubjectOneVipCell () @property (nonatomic, readwrite, strong) RQProfileVipItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIImageView *vipBgImageView; @property (weak, nonatomic) IBOutlet UIButton *openVipBtn; @property (weak, nonatomic) IBOutlet UILabel *dateLabel; @property (weak, nonatomic) IBOutlet UIButton *leftVipBtn; @property (weak, nonatomic) IBOutlet UIImageView *leftVipIconImg; @property (weak, nonatomic) IBOutlet UILabel *leftVipNameLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *iConToLabel; @end @implementation RQProfileSubjectOneVipCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQProfileSubjectOneVipCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQProfileSubjectOneVipCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; [cell.vipBgImageView setImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#3B3E51"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"#252531"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:cell.bounds.size cornerRadius:QQRadiusMakeSame(10.f)]]; [cell.leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#ABAEB1"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"#F5F5F6"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(110.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMake(0, RQ_FIT_HORIZONTAL(30.f) / 2.f, 0, RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal]; [cell.openVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFA316"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"#FFC610"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(85.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal]; cell.iConToLabel.constant = - (RQ_FIT_HORIZONTAL(30.f) * 1.4 * (28.f / 25.f)) / 2.f; return cell; } - (void)bindViewModel:(RQProfileVipItemViewModel *)viewModel { self.viewModel = viewModel; [[self singnal] subscribeNext:^(id _Nullable x) {}]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; } - (void)layoutSubviews { [super layoutSubviews]; } #pragma mark - PrivateMethods - (IBAction)openVipBtnAction:(id)sender { [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) { if (RQ_VIP_Module.isVip) { [RQ_VIP_Module gotoVipCenter]; } else { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } }]; } #pragma mark - LazyLoad - (RACSignal *)singnal { @weakify(self) return [[RACSignal combineLatest:@[RACObserve(RQ_Profile_Module, profileSubject), RACObserve(RQ_VIP_Module, videoVipModel)] reduce:^id (id _Nullable x, id _Nullable y) { @strongify(self) if (RQ_Profile_Module.profileSubject == self.viewModel.profileSubject) { _openVipBtn.hidden = RQ_VIP_Module.isSubject1Vip; _dateLabel.hidden = !_openVipBtn.hidden; _dateLabel.text = [NSString stringWithFormat:@"%@到期",RQ_VIP_Module.videoVipModel.subject1]; [_leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = RQ_VIP_Module.isSubject1Vip? [UIColor qmui_colorWithHexString:@"#FFA316"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"]; graColor.toColor = RQ_VIP_Module.isSubject1Vip? [UIColor qmui_colorWithHexString:@"#FFC610"] : [UIColor qmui_colorWithHexString:@"#F5F5F6"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(110.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMake(0, RQ_FIT_HORIZONTAL(30.f) / 2.f, 0, RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal]; _leftVipIconImg.image = [UIImage imageNamed:RQ_VIP_Module.isSubject1Vip? @"钻石金黄色" : @"钻石灰"]; _leftVipNameLabel.textColor = RQ_VIP_Module.isSubject1Vip? [UIColor qmui_colorWithHexString:@"#DBA05C"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"]; _leftVipNameLabel.text = RQ_VIP_Module.isSubject1Vip? @"极享VIP" : @"未开通"; } return @""; }] takeUntil:self.rac_prepareForReuseSignal]; } @end