RQProfileSubjectOneVipCell.m 5.0 KB

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