YMInvitingPrizesViewController.m 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. self.title = @"邀请有礼";
  37. }
  38. - (void)viewWillAppear:(BOOL)animated {
  39. [super viewWillAppear:animated];
  40. }
  41. - (void)viewDidLayoutSubviews {
  42. [super viewDidLayoutSubviews];
  43. }
  44. - (void)ym_setupViews{
  45. [self.view addSubview:self.contentScrollView];
  46. [self.view sendSubviewToBack:self.contentScrollView];
  47. [self.contentScrollView addSubview:self.contentView];
  48. [self.contentView addSubview:self.invitationBgView];
  49. [self.invitationBgView addSubview:self.invitationNowBtn];
  50. [self.contentView addSubview:self.myInvitationView];
  51. [self.contentView addSubview:self.incentivesNotesView];
  52. [self.contentView addSubview:self.hingeImgv];
  53. self.contentView.backgroundColor = rgba(255, 82, 112, 1);
  54. [self.view setNeedsUpdateConstraints];
  55. [self.view updateConstraintsIfNeeded];
  56. }
  57. - (void)updateViewConstraints{
  58. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(self.view);
  60. make.left.equalTo(self.view);
  61. make.right.equalTo(self.view);
  62. make.bottom.equalTo(self.view);
  63. }];
  64. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.edges.equalTo(self.contentScrollView);
  66. make.width.equalTo(self.contentScrollView.mas_width);
  67. }];
  68. [self.invitationBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.equalTo(self.contentView);
  70. make.left.equalTo(self.contentView);
  71. make.right.equalTo(self.contentView);
  72. make.height.mas_equalTo(adapt(666));
  73. }];
  74. // UIImageView *bgv = [[UIImageView alloc] init];
  75. // bgv.image = ImageByName(@"ym_inviting_prizes_bg");
  76. // bgv.layer.zPosition = -1;
  77. // [self.contentView insertSubview:bgv atIndex:0];
  78. //
  79. // [bgv mas_updateConstraints:^(MASConstraintMaker *make) {
  80. // make.top.equalTo(self.invitationBgView.mas_bottom).offset(adapt(-60));
  81. // make.bottom.equalTo(self.contentView).offset(adapt(-0));
  82. // make.left.right.equalTo(self.contentView);
  83. // }];
  84. [self.invitationNowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.centerX.equalTo(self.invitationBgView.mas_centerX);
  86. make.centerY.equalTo(self.invitationBgView.mas_bottom).offset(adapt(-250));
  87. make.width.mas_equalTo(adapt(289));
  88. make.height.mas_equalTo(adapt(75));
  89. }];
  90. [self.myInvitationView mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.equalTo(self.invitationNowBtn.mas_bottom).offset(adapt(13));
  92. make.left.equalTo(self.contentView);
  93. make.right.equalTo(self.contentView);
  94. }];
  95. [self.incentivesNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.top.equalTo(self.myInvitationView.mas_bottom).offset(adapt(12));
  97. make.left.equalTo(self.contentView);
  98. make.right.equalTo(self.contentView);
  99. make.bottom.equalTo(self.contentView).offset(adapt(-56));
  100. }];
  101. [self.hingeImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.top.equalTo(self.myInvitationView.mas_bottom).offset(adapt(-26));
  103. make.left.equalTo(self.contentView).offset(adapt(40));
  104. make.right.equalTo(self.contentView).offset(adapt(-40));
  105. make.height.mas_equalTo(adapt(66));
  106. }];
  107. //CGRect rect = CGRectMake(0, 0, self.contentScrollView.contentSize.height, self.contentScrollView.contentSize.height);
  108. UIView *gradientView = [[UIView alloc] initWithFrame:CGRectZero];
  109. [gradientView ym_setGradientBackgroundWithColors:@[HexColorFromRGB(0xFCE3C4), HexColorFromRGB(0xF7891B)] locations:@[@(0),@(1)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1)];
  110. [self.contentScrollView insertSubview:gradientView atIndex:0];
  111. [gradientView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.top.equalTo(self.invitationBgView.mas_bottom).offset(adapt(-23));
  113. make.left.right.bottom.equalTo(self.contentScrollView);
  114. }];
  115. [super updateViewConstraints];
  116. }
  117. - (void)ym_bindViewModel{
  118. [self.myInvitationView ym_bindViewModel:self.viewModel];
  119. [self.incentivesNotesView ym_bindViewModel:self.viewModel];
  120. [self.viewModel getInvitingPrizesInfoData];
  121. }
  122. - (void)openSharePosterPopupView{
  123. YMInvitingPrizesSharePosterPopupView *customView = [[YMInvitingPrizesSharePosterPopupView alloc]init];
  124. [customView ym_bindViewModel:self.viewModel];
  125. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  126. popupView.priority = 999;
  127. popupView.positionStyle = YMPositionStyleBottom;
  128. popupView.isClickBgDismiss = YES;
  129. popupView.isHideBg = NO;
  130. popupView.bgAlpha = 0.5;
  131. popupView.popDuration = 0.3;
  132. [popupView pop];
  133. @weakify(popupView)
  134. customView.dismissBlock = ^{
  135. @strongify(popupView)
  136. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  137. };
  138. }
  139. - (UIScrollView *)contentScrollView{
  140. if (!_contentScrollView) {
  141. _contentScrollView = [[UIScrollView alloc]init];
  142. _contentScrollView.bounces = NO;
  143. _contentScrollView.alwaysBounceVertical = YES;
  144. _contentScrollView.showsVerticalScrollIndicator = NO;
  145. _contentScrollView.showsHorizontalScrollIndicator = NO;
  146. _contentScrollView.backgroundColor = UIColor.clearColor;
  147. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  148. }
  149. return _contentScrollView;
  150. }
  151. - (UIView *)contentView{
  152. if (!_contentView) {
  153. _contentView = [[UIView alloc]init];
  154. }
  155. return _contentView;
  156. }
  157. - (UIImageView *)invitationBgView{
  158. if (!_invitationBgView) {
  159. _invitationBgView = [[UIImageView alloc]init];
  160. _invitationBgView.contentMode = UIViewContentModeScaleAspectFill;
  161. _invitationBgView.image = ImageByName(@"ym_inviting_prizes_invitation_bg");
  162. _invitationBgView.userInteractionEnabled = YES;
  163. UILabel * titleL = [UILabel new];
  164. titleL.text=@"邀请好友的奖励";
  165. titleL.textColor=UIColor.whiteColor;
  166. titleL.font=LCBoldFont(44);
  167. titleL.textAlignment=NSTextAlignmentCenter;
  168. [_invitationBgView addSubview:titleL];
  169. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.centerX.equalTo(_invitationBgView);
  171. make.top.equalTo(_invitationBgView.top).offset(100);
  172. }];
  173. UIButton * remarkL = [UIButton new];
  174. [_invitationBgView addSubview:remarkL];
  175. [remarkL setBackgroundImage:ImageByName(@"ym_inviting_prizes_remark_bar") forState:UIControlStateNormal];
  176. [remarkL setTitle:@"— 超多福利拿到手软 —" forState:0];
  177. [remarkL setTitleColor:rgba(235, 75, 75, 1) forState:0];
  178. remarkL.titleLabel.font = LCBoldFont(16);
  179. [remarkL mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.centerX.equalTo(_invitationBgView);
  181. make.top.equalTo(titleL.bottom).offset(10);
  182. make.size.equalTo(CGSizeMake(226, 34));
  183. }];
  184. }
  185. return _invitationBgView;
  186. }
  187. - (UIButton *)invitationNowBtn{
  188. if (!_invitationNowBtn) {
  189. _invitationNowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  190. [_invitationNowBtn setBackgroundImage:ImageByName(@"ym_inviting_prizes_invitation_now") forState:UIControlStateNormal];
  191. [_invitationNowBtn setTitle:@"立即邀请好友" forState:0];
  192. [_invitationNowBtn setTitleColor:[UIColor whiteColor] forState:0];
  193. _invitationNowBtn.titleLabel.font = LCBoldFont(26);
  194. WS(weakSelf)
  195. [[[_invitationNowBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  196. [weakSelf openSharePosterPopupView];
  197. }];
  198. }
  199. return _invitationNowBtn;
  200. }
  201. - (YMInvitingPrizesMyInvitationView *)myInvitationView{
  202. if (!_myInvitationView) {
  203. _myInvitationView = [[YMInvitingPrizesMyInvitationView alloc]init];
  204. }
  205. return _myInvitationView;
  206. }
  207. - (YMInvitingPrizesIncentivesNotesView *)incentivesNotesView{
  208. if (!_incentivesNotesView) {
  209. _incentivesNotesView = [[YMInvitingPrizesIncentivesNotesView alloc]init];
  210. }
  211. return _incentivesNotesView;
  212. }
  213. - (UIImageView *)hingeImgv {
  214. if (!_hingeImgv) {
  215. _hingeImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_inviting_prizes_lian_jie"]];
  216. _hingeImgv.contentMode = UIViewContentModeScaleToFill;
  217. _hingeImgv.layer.zPosition = 1;
  218. _hingeImgv.hidden = YES;
  219. }
  220. return _hingeImgv;
  221. }
  222. @end