YMInvitingPrizesViewController.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // YMInvitingPrizesViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/5.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMInvitingPrizesViewController.h"
  9. #import "YMInvitingPrizesViewModel.h"
  10. #import "YMInvitingPrizesMyInvitationView.h"
  11. #import "YMInvitingPrizesIncentivesNotesView.h"
  12. #import "YMInvitingPrizesSharePosterPopupView.h"
  13. @interface YMInvitingPrizesViewController ()
  14. /// 邀请有奖VM
  15. @property (nonatomic, strong) YMInvitingPrizesViewModel *viewModel;
  16. /// 容器滚动视图
  17. @property (nonatomic, strong) UIScrollView *contentScrollView;
  18. /// 容器视图
  19. @property (nonatomic, strong) UIView *contentView;
  20. /// 邀请背景视图
  21. @property (nonatomic, strong) UIImageView *invitationBgView;
  22. /// 立即邀请按钮
  23. @property (nonatomic, strong) UIButton *invitationNowBtn;
  24. /// 我的邀请视图
  25. @property (nonatomic, strong) YMInvitingPrizesMyInvitationView *myInvitationView;
  26. /// 奖励说明视图
  27. @property (nonatomic, strong) YMInvitingPrizesIncentivesNotesView *incentivesNotesView;
  28. ///
  29. @property (nonatomic, strong) UIImageView *hingeImgv;
  30. @end
  31. @implementation YMInvitingPrizesViewController
  32. @dynamic viewModel;
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.ym_navigationStyle = YMBaseNavigationStyleClearBgBlackBackArrow;
  36. }
  37. - (void)ym_setupViews{
  38. [self.view addSubview:self.contentScrollView];
  39. [self.view sendSubviewToBack:self.contentScrollView];
  40. [self.contentScrollView addSubview:self.contentView];
  41. [self.contentView addSubview:self.invitationBgView];
  42. [self.invitationBgView addSubview:self.invitationNowBtn];
  43. [self.contentView addSubview:self.myInvitationView];
  44. [self.contentView addSubview:self.incentivesNotesView];
  45. [self.contentView addSubview:self.hingeImgv];
  46. [self.view setNeedsUpdateConstraints];
  47. [self.view updateConstraintsIfNeeded];
  48. }
  49. - (void)updateViewConstraints{
  50. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.equalTo(self.view);
  52. make.left.equalTo(self.view);
  53. make.right.equalTo(self.view);
  54. make.bottom.equalTo(self.view);
  55. }];
  56. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.edges.equalTo(self.contentScrollView);
  58. make.width.equalTo(self.contentScrollView.mas_width);
  59. }];
  60. [self.invitationBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.equalTo(self.contentView);
  62. make.left.equalTo(self.contentView);
  63. make.right.equalTo(self.contentView);
  64. make.height.mas_equalTo(adapt(526));
  65. }];
  66. UIImageView *bgv = [[UIImageView alloc] init];
  67. bgv.image = ImageByName(@"ym_inviting_prizes_bg");
  68. bgv.layer.zPosition = -1;
  69. [self.contentView insertSubview:bgv atIndex:0];
  70. [bgv mas_updateConstraints:^(MASConstraintMaker *make) {
  71. make.top.equalTo(self.invitationBgView.mas_bottom).offset(adapt(-60));
  72. make.bottom.equalTo(self.contentView).offset(adapt(-0));
  73. make.left.right.equalTo(self.contentView);
  74. }];
  75. [self.invitationNowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.centerX.equalTo(self.invitationBgView.mas_centerX);
  77. make.bottom.equalTo(self.invitationBgView).offset(adapt(-15));
  78. make.width.mas_equalTo(adapt(323));
  79. make.height.mas_equalTo(adapt(68));
  80. }];
  81. [self.myInvitationView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.top.equalTo(self.invitationBgView.mas_bottom).offset(adapt(7));
  83. make.left.equalTo(self.contentView);
  84. make.right.equalTo(self.contentView);
  85. }];
  86. [self.incentivesNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(self.myInvitationView.mas_bottom).offset(adapt(12));
  88. make.left.equalTo(self.contentView);
  89. make.right.equalTo(self.contentView);
  90. make.bottom.equalTo(self.contentView).offset(adapt(-56));
  91. }];
  92. [self.hingeImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.equalTo(self.myInvitationView.mas_bottom).offset(adapt(-26));
  94. make.left.equalTo(self.contentView).offset(adapt(40));
  95. make.right.equalTo(self.contentView).offset(adapt(-40));
  96. make.height.mas_equalTo(adapt(66));
  97. }];
  98. [super updateViewConstraints];
  99. }
  100. - (void)ym_bindViewModel{
  101. [self.myInvitationView ym_bindViewModel:self.viewModel];
  102. [self.incentivesNotesView ym_bindViewModel:self.viewModel];
  103. [self.viewModel getInvitingPrizesInfoData];
  104. }
  105. - (void)openSharePosterPopupView{
  106. YMInvitingPrizesSharePosterPopupView *customView = [[YMInvitingPrizesSharePosterPopupView alloc]init];
  107. [customView ym_bindViewModel:self.viewModel];
  108. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  109. popupView.priority = 999;
  110. popupView.positionStyle = YMPositionStyleBottom;
  111. popupView.isClickBgDismiss = YES;
  112. popupView.isHideBg = NO;
  113. popupView.bgAlpha = 0.5;
  114. [popupView pop];
  115. @weakify(popupView)
  116. customView.dismissBlock = ^{
  117. @strongify(popupView)
  118. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  119. };
  120. }
  121. - (UIScrollView *)contentScrollView{
  122. if (!_contentScrollView) {
  123. _contentScrollView = [[UIScrollView alloc]init];
  124. _contentScrollView.bounces = NO;
  125. _contentScrollView.alwaysBounceVertical = YES;
  126. _contentScrollView.showsVerticalScrollIndicator = NO;
  127. _contentScrollView.showsHorizontalScrollIndicator = NO;
  128. _contentScrollView.backgroundColor = UIColor.clearColor;
  129. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  130. }
  131. return _contentScrollView;
  132. }
  133. - (UIView *)contentView{
  134. if (!_contentView) {
  135. _contentView = [[UIView alloc]init];
  136. }
  137. return _contentView;
  138. }
  139. - (UIImageView *)invitationBgView{
  140. if (!_invitationBgView) {
  141. _invitationBgView = [[UIImageView alloc]init];
  142. _invitationBgView.contentMode = UIViewContentModeScaleAspectFill;
  143. _invitationBgView.image = ImageByName(@"ym_inviting_prizes_invitation_bg");
  144. _invitationBgView.userInteractionEnabled = YES;
  145. }
  146. return _invitationBgView;
  147. }
  148. - (UIButton *)invitationNowBtn{
  149. if (!_invitationNowBtn) {
  150. _invitationNowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  151. [_invitationNowBtn setBackgroundImage:ImageByName(@"ym_inviting_prizes_invitation_now") forState:UIControlStateNormal];
  152. WS(weakSelf)
  153. [[[_invitationNowBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  154. [weakSelf openSharePosterPopupView];
  155. }];
  156. }
  157. return _invitationNowBtn;
  158. }
  159. - (YMInvitingPrizesMyInvitationView *)myInvitationView{
  160. if (!_myInvitationView) {
  161. _myInvitationView = [[YMInvitingPrizesMyInvitationView alloc]init];
  162. }
  163. return _myInvitationView;
  164. }
  165. - (YMInvitingPrizesIncentivesNotesView *)incentivesNotesView{
  166. if (!_incentivesNotesView) {
  167. _incentivesNotesView = [[YMInvitingPrizesIncentivesNotesView alloc]init];
  168. }
  169. return _incentivesNotesView;
  170. }
  171. - (UIImageView *)hingeImgv {
  172. if (!_hingeImgv) {
  173. _hingeImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_inviting_prizes_lian_jie"]];
  174. _hingeImgv.contentMode = UIViewContentModeScaleToFill;
  175. _hingeImgv.layer.zPosition = 1;
  176. }
  177. return _hingeImgv;
  178. }
  179. @end