RQProfileVipCell.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. [cell.leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  48. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  49. graColor.toColor = [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  50. graColor.type = QQGradualChangeTypeLeftToRight;
  51. } 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];
  52. [cell.openVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  53. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFA316"];
  54. graColor.toColor = [UIColor qmui_colorWithHexString:@"#FFC610"];
  55. graColor.type = QQGradualChangeTypeLeftToRight;
  56. } size:CGSizeMake(RQ_FIT_HORIZONTAL(85.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal];
  57. cell.labelOneCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  58. [cell.subjectOneView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  59. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  60. cell.labelTwoCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  61. [cell.subjectTwoView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  62. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  63. corner.borderWidth = 1;
  64. corner.fillColor = UIColor.clearColor;
  65. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  66. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  67. cell.labelThreeCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  68. [cell.subjectThreeView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  69. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  70. corner.borderWidth = 1;
  71. corner.fillColor = UIColor.clearColor;
  72. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  73. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  74. cell.labelFourCenterX.constant = (RQ_FIT_HORIZONTAL(17.24f) / 2.f) + 2;
  75. [cell.subjectFourView setImage:[UIImage imageWithQQCorner:^(QQCorner *corner) {
  76. corner.borderColor = [UIColor qmui_colorWithHexString:@"#7A6751"];
  77. corner.borderWidth = 1;
  78. corner.fillColor = UIColor.clearColor;
  79. corner.radius = QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f);
  80. } size:CGSizeMake((RQ_SCREEN_WIDTH - 32.f - 32.f - 24.f) / 4.f, RQ_FIT_HORIZONTAL(30.f))]];
  81. cell.iConToLabel.constant = - (RQ_FIT_HORIZONTAL(30.f) * 1.4 * (28.f / 25.f)) / 2.f;
  82. return cell;
  83. }
  84. - (void)bindViewModel:(RQProfileVipItemViewModel *)viewModel {
  85. self.viewModel = viewModel;
  86. [[self singnal] subscribeNext:^(id _Nullable x) {}];
  87. }
  88. #pragma mark - SystemMethods
  89. - (void)awakeFromNib {
  90. [super awakeFromNib];
  91. }
  92. - (void)layoutSubviews {
  93. [super layoutSubviews];
  94. }
  95. #pragma mark - PrivateMethods
  96. - (IBAction)openVipBtnAction:(id)sender {
  97. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  98. if (RQ_VIP_Module.isVip) {
  99. [RQ_VIP_Module gotoVipCenter];
  100. } else {
  101. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  102. }
  103. }];
  104. }
  105. #pragma mark - LazyLoad
  106. - (RACSignal *)singnal {
  107. @weakify(self)
  108. return [[RACSignal combineLatest:@[RACObserve(RQ_Profile_Module, profileSubject), RACObserve(RQ_VIP_Module, videoVipModel)] reduce:^id (id _Nullable x, id _Nullable y) {
  109. @strongify(self)
  110. if (RQ_Profile_Module.profileSubject == self.viewModel.profileSubject) {
  111. _openVipBtn.hidden = RQ_VIP_Module.isSubjectAllVip;
  112. _dateLabel.hidden = !_openVipBtn.hidden;
  113. _dateLabel.text = [NSString stringWithFormat:@"%@到期",RQ_VIP_Module.videoVipModel.subject4];
  114. _leftVipIconImg.image = [UIImage imageNamed:RQ_VIP_Module.isSubjectAllVip? @"钻石金黄色" : @"钻石灰"];
  115. [_leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  116. graColor.fromColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#FFA316"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  117. graColor.toColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#FFC610"] : [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  118. graColor.type = QQGradualChangeTypeLeftToRight;
  119. } 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];
  120. [_leftVipBtn setTitleNormal:@"全科目"];
  121. _leftVipNameLabel.textColor = RQ_VIP_Module.isSubjectAllVip? [UIColor qmui_colorWithHexString:@"#DBA05C"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  122. _leftVipNameLabel.text = RQ_VIP_Module.isSubjectAllVip? @"极享VIP" : @"未开通";
  123. }
  124. return @"";
  125. }] takeUntil:self.rac_prepareForReuseSignal];
  126. }
  127. @end