RQProfileVipCell.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // RQProfileVipCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/4/28.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQProfileVipCell.h"
  9. @interface RQProfileVipCell ()
  10. @property (nonatomic, readwrite, strong) RQProfileVipItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *vipBgImageView;
  12. @property (weak, nonatomic) IBOutlet UIButton *openVipBtn;
  13. @property (weak, nonatomic) IBOutlet UILabel *dateLabel;
  14. @property (weak, nonatomic) IBOutlet UIButton *leftVipBtn;
  15. @property (weak, nonatomic) IBOutlet UIImageView *leftVipIconImg;
  16. @property (weak, nonatomic) IBOutlet UILabel *leftVipNameLabel;
  17. @property (weak, nonatomic) IBOutlet UIImageView *subjectOneView;
  18. @property (weak, nonatomic) IBOutlet UIImageView *subjectOneImageView;
  19. @property (weak, nonatomic) IBOutlet UILabel *subjectOneLabel;
  20. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelOneCenterX;
  21. @property (weak, nonatomic) IBOutlet UIImageView *subjectTwoView;
  22. @property (weak, nonatomic) IBOutlet UIImageView *subjectTwoImageView;
  23. @property (weak, nonatomic) IBOutlet UILabel *subjectTwoLabel;
  24. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelTwoCenterX;
  25. @property (weak, nonatomic) IBOutlet UIImageView *subjectThreeView;
  26. @property (weak, nonatomic) IBOutlet UIImageView *subjectThreeImageView;
  27. @property (weak, nonatomic) IBOutlet UILabel *subjectThreeLabel;
  28. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelThreeCenterX;
  29. @property (weak, nonatomic) IBOutlet UIImageView *subjectFourView;
  30. @property (weak, nonatomic) IBOutlet UIImageView *subjectFourImageView;
  31. @property (weak, nonatomic) IBOutlet UILabel *subjectFourLabel;
  32. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelFourCenterX;
  33. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *iConToLabel;
  34. @end
  35. @implementation RQProfileVipCell
  36. #pragma mark - PublicMethods
  37. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  38. static NSString *ID = @"RQProfileVipCell";
  39. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  40. RQProfileVipCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  41. if (!cell) cell = [self rq_viewFromXib];
  42. [cell.vipBgImageView setImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  43. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#3B3E51"];
  44. graColor.toColor = [UIColor qmui_colorWithHexString:@"#252531"];
  45. graColor.type = QQGradualChangeTypeLeftToRight;
  46. } size:cell.bounds.size cornerRadius:QQRadiusMakeSame(10.f)]];
  47. if(cell.leftVipBtn.currentBackgroundImage==nil){
  48. [cell.leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  49. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  50. graColor.toColor = [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  51. graColor.type = QQGradualChangeTypeLeftToRight;
  52. } 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];
  53. }
  54. [cell.openVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  55. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFA316"];
  56. graColor.toColor = [UIColor qmui_colorWithHexString:@"#FFC610"];
  57. graColor.type = QQGradualChangeTypeLeftToRight;
  58. } size:CGSizeMake(RQ_FIT_HORIZONTAL(85.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal];
  59. cell.labelOneCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  60. [cell.subjectOneView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  61. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  62. cell.labelTwoCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  63. [cell.subjectTwoView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  64. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  65. corner.borderWidth = 1;
  66. corner.fillColor = UIColor.clearColor;
  67. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  68. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  69. cell.labelThreeCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  70. [cell.subjectThreeView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  71. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  72. corner.borderWidth = 1;
  73. corner.fillColor = UIColor.clearColor;
  74. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  75. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  76. cell.labelFourCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  77. [cell.subjectFourView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  78. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  79. corner.borderWidth = 1;
  80. corner.fillColor = UIColor.clearColor;
  81. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  82. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  83. cell.iConToLabel.constant = - (RQ_FIT_HORIZONTAL(30.f) * 1.4 * (28.f / 25.f)) / 2.f;
  84. return cell;
  85. }
  86. - (void)bindViewModel:(RQProfileVipItemViewModel *)viewModel {
  87. self.viewModel = viewModel;
  88. [[self singnal] subscribeNext:^(id _Nullable x) {}];
  89. }
  90. #pragma mark - SystemMethods
  91. - (void)awakeFromNib {
  92. [super awakeFromNib];
  93. }
  94. - (void)layoutSubviews {
  95. [super layoutSubviews];
  96. }
  97. #pragma mark - PrivateMethods
  98. - (IBAction)openVipBtnAction:(id)sender {
  99. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  100. if (RQ_VIP_Module.isVip) {
  101. [RQ_VIP_Module gotoVipCenter];
  102. } else {
  103. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  104. }
  105. }];
  106. }
  107. #pragma mark - LazyLoad
  108. - (RACSignal *)singnal {
  109. @weakify(self)
  110. return [[RACSignal combineLatest:@[RACObserve(RQ_Profile_Module, profileSubject), RACObserve(RQ_VIP_Module, videoVipModel)] reduce:^id (id _Nullable x, id _Nullable y) {
  111. @strongify(self)
  112. if (RQ_Profile_Module.profileSubject == self.viewModel.profileSubject) {
  113. _openVipBtn.hidden = RQ_VIP_Module.isSubjectAllVip;
  114. _dateLabel.hidden = !_openVipBtn.hidden;
  115. _dateLabel.text = [NSString stringWithFormat:@"%@到期",RQ_VIP_Module.videoVipModel.subject4];
  116. _leftVipIconImg.image = [UIImage imageNamed:RQ_VIP_Module.isSubjectAllVip? @"钻石金黄色" : @"钻石灰"];
  117. [_leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  118. graColor.fromColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#FFA316"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  119. graColor.toColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#FFC610"] : [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  120. graColor.type = QQGradualChangeTypeLeftToRight;
  121. } 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];
  122. [_leftVipBtn setTitleNormal:@"全科目"];
  123. _leftVipNameLabel.textColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#DBA05C"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  124. _leftVipNameLabel.text = RQ_VIP_Module.isSubjectAllVip? @"极享VIP" : @"未开通";
  125. }
  126. return @"";
  127. }] takeUntil:self.rac_prepareForReuseSignal];
  128. }
  129. @end