RQProfileSubjectFourVipCell.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // RQProfileSubjectFourVipCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/4/28.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQProfileSubjectFourVipCell.h"
  9. @interface RQProfileSubjectFourVipCell ()
  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 NSLayoutConstraint *iConToLabel;
  18. @end
  19. @implementation RQProfileSubjectFourVipCell
  20. #pragma mark - PublicMethods
  21. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  22. static NSString *ID = @"RQProfileSubjectFourVipCell";
  23. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  24. RQProfileSubjectFourVipCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  25. if (!cell) cell = [self rq_viewFromXib];
  26. [cell.vipBgImageView setImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  27. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#3B3E51"];
  28. graColor.toColor = [UIColor qmui_colorWithHexString:@"#252531"];
  29. graColor.type = QQGradualChangeTypeLeftToRight;
  30. } size:cell.bounds.size cornerRadius:QQRadiusMakeSame(10.f)]];
  31. if(cell.leftVipBtn.currentBackgroundImage==nil){
  32. [cell.leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  33. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  34. graColor.toColor = [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  35. graColor.type = QQGradualChangeTypeLeftToRight;
  36. } 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];
  37. }
  38. [cell.openVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  39. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFA316"];
  40. graColor.toColor = [UIColor qmui_colorWithHexString:@"#FFC610"];
  41. graColor.type = QQGradualChangeTypeLeftToRight;
  42. } size:CGSizeMake(RQ_FIT_HORIZONTAL(85.f), RQ_FIT_HORIZONTAL(30.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(30.f) / 2.f)] forState:UIControlStateNormal];
  43. cell.iConToLabel.constant = - (RQ_FIT_HORIZONTAL(30.f) * 1.4 * (28.f / 25.f)) / 2.f;
  44. return cell;
  45. }
  46. - (void)bindViewModel:(RQProfileVipItemViewModel *)viewModel {
  47. self.viewModel = viewModel;
  48. [[self singnal] subscribeNext:^(id _Nullable x) {}];
  49. }
  50. #pragma mark - SystemMethods
  51. - (void)awakeFromNib {
  52. [super awakeFromNib];
  53. }
  54. - (void)layoutSubviews {
  55. [super layoutSubviews];
  56. }
  57. #pragma mark - PrivateMethods
  58. - (IBAction)openVipBtnAction:(id)sender {
  59. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  60. if (RQ_VIP_Module.isVip) {
  61. [RQ_VIP_Module gotoVipCenter];
  62. } else {
  63. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  64. }
  65. }];
  66. }
  67. #pragma mark - LazyLoad
  68. - (RACSignal *)singnal {
  69. @weakify(self)
  70. return [[RACSignal combineLatest:@[RACObserve(RQ_Profile_Module, profileSubject), RACObserve(RQ_VIP_Module, videoVipModel)] reduce:^id (id _Nullable x, id _Nullable y) {
  71. @strongify(self)
  72. if (RQ_Profile_Module.profileSubject == self.viewModel.profileSubject) {
  73. _openVipBtn.hidden = RQ_VIP_Module.isSubject4Vip;
  74. _dateLabel.hidden = !_openVipBtn.hidden;
  75. _dateLabel.text = [NSString stringWithFormat:@"%@到期",RQ_VIP_Module.videoVipModel.subject4];
  76. [_leftVipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  77. graColor.fromColor = RQ_VIP_Module.isSubject4Vip? [UIColor qmui_colorWithHexString:@"#FFA316"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  78. graColor.toColor = RQ_VIP_Module.isSubject4Vip? [UIColor qmui_colorWithHexString:@"#FFC610"] : [UIColor qmui_colorWithHexString:@"#F5F5F6"];
  79. graColor.type = QQGradualChangeTypeLeftToRight;
  80. } 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];
  81. _leftVipIconImg.image = [UIImage imageNamed:RQ_VIP_Module.isSubject4Vip? @"钻石金黄色" : @"钻石灰"];
  82. _leftVipNameLabel.textColor = RQ_VIP_Module.isSubject4Vip? [UIColor qmui_colorWithHexString:@"#DBA05C"] : [UIColor qmui_colorWithHexString:@"#ABAEB1"];
  83. _leftVipNameLabel.text = RQ_VIP_Module.isSubject4Vip? @"极享VIP" : @"未开通";
  84. }
  85. return @"";
  86. }] takeUntil:self.rac_prepareForReuseSignal];
  87. }
  88. @end