123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // RQProfileVipCell.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/4/28.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "RQProfileVipCell.h"
- @interface RQProfileVipCell ()
- @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 UIImageView *subjectOneView;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectOneImageView;
- @property (weak, nonatomic) IBOutlet UILabel *subjectOneLabel;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelOneCenterX;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectTwoView;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectTwoImageView;
- @property (weak, nonatomic) IBOutlet UILabel *subjectTwoLabel;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelTwoCenterX;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectThreeView;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectThreeImageView;
- @property (weak, nonatomic) IBOutlet UILabel *subjectThreeLabel;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelThreeCenterX;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectFourView;
- @property (weak, nonatomic) IBOutlet UIImageView *subjectFourImageView;
- @property (weak, nonatomic) IBOutlet UILabel *subjectFourLabel;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelFourCenterX;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *iConToLabel;
- @end
- @implementation RQProfileVipCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"RQProfileVipCell";
- [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
- RQProfileVipCell *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)]];
-
- if(cell.leftVipBtn.currentBackgroundImage==nil){
- [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.labelOneCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
- [cell.subjectOneView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
-
- } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
-
-
- cell.labelTwoCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
- [cell.subjectTwoView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
- corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
- corner.borderWidth = 1;
- corner.fillColor = UIColor.clearColor;
- corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
- } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
-
- cell.labelThreeCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
- [cell.subjectThreeView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
- corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
- corner.borderWidth = 1;
- corner.fillColor = UIColor.clearColor;
- corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
- } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
-
- cell.labelFourCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
- [cell.subjectFourView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
- corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
- corner.borderWidth = 1;
- corner.fillColor = UIColor.clearColor;
- corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
- } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
-
- 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.isSubjectAllVip;
- _dateLabel.hidden = !_openVipBtn.hidden;
- _dateLabel.text = [NSString stringWithFormat:@"%@到期",RQ_VIP_Module.videoVipModel.subject4];
- _leftVipIconImg.image = [UIImage imageNamed:RQ_VIP_Module.isSubjectAllVip? @"钻石金黄色" : @"钻石灰"];
- [_leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
- graColor.fromColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#FFA316"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
- graColor.toColor = RQ_VIP_Module.isSubjectAllVip? [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];
- [_leftVipBtn setTitleNormal:@"全科目"];
- _leftVipNameLabel.textColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#DBA05C"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
- _leftVipNameLabel.text = RQ_VIP_Module.isSubjectAllVip? @"极享VIP" : @"未开通";
- }
- return @"";
- }] takeUntil:self.rac_prepareForReuseSignal];
- }
- @end
|