ASVipCenterViewController.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // ASVipCenterViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/26.
  6. //
  7. #import "ASVipCenterViewController.h"
  8. #import "ASUserBaseInfoView.h"
  9. #import "ASVipCenterLineItemView.h"
  10. #import "ASVipCenterCollectCell.h"
  11. #import "ASVipCouponsViewController.h"
  12. #import "ASBirthdayTreatViewController.h"
  13. @interface ASVipCenterViewController () <UICollectionViewDelegate,UICollectionViewDataSource>
  14. @property (nonatomic, strong) UIScrollView *scrollV;
  15. @property (nonatomic, strong) UIView *contentV;
  16. @property (nonatomic, strong) ASUserBaseInfoView *userInfoV;
  17. @property (nonatomic, strong) UICollectionView *collectV;
  18. @property (nonatomic, strong) UIPageControl *control;
  19. @property (nonatomic, strong) NSMutableArray <ASVipCenterLineItemView *>*bottomVArr;
  20. @property (nonatomic, strong) NSArray *bottomTitleArr;
  21. @property (nonatomic, strong) NSArray *vipImgArr;
  22. @end
  23. @implementation ASVipCenterViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [UIView viewAddHorColorBg:self.view colorArr:@[
  27. (id)_E0FFF5.CGColor,
  28. (id)Col_FFF.CGColor
  29. ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
  30. self.bottomTitleArr = @[@"EXCLUSIVE $100 COUPON", @"BIRTHDAY TREAT"];
  31. self.vipImgArr = @[@"vip_bg1",@"vip_bg2",@"vip_bg3",@"vip_bg4",@"vip_bg5"];
  32. [self loadSubVs];
  33. [self.view bringSubviewToFront:self.customNavBar];
  34. [self configSubVs];
  35. [self demoData];
  36. }
  37. - (void)demoData {
  38. self.userInfoV.usefualLb.text = @"Growth Value 7220/10000";
  39. self.control.numberOfPages = self.vipImgArr.count;
  40. self.control.currentPage = 0;
  41. }
  42. - (void)configSubVs {
  43. self.titleStr = @"VIP Center";
  44. [self setNavRightSearch:^{
  45. }];
  46. self.statusBgV.backgroundColor = _E0FFF5;
  47. self.customNavBar.backgroundColor = _F0FFFA;
  48. }
  49. // MARK: - loadSubVs
  50. - (void)loadSubVs {
  51. [self.view addSubview:self.scrollV];
  52. [self.scrollV addSubview:self.contentV];
  53. [self.contentV addSubview:self.userInfoV];
  54. [self.contentV addSubview:self.collectV];
  55. [self.contentV addSubview:self.control];
  56. UIStackView *stv = [self getBottomV];
  57. [self.contentV addSubview:stv];
  58. [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(self.customNavBar.mas_bottom);
  60. make.leading.trailing.bottom.equalTo(self.view);
  61. }];
  62. [self.contentV mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.edges.equalTo(self.scrollV);
  64. make.width.equalTo(self.view);
  65. }];
  66. [self.userInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.top.equalTo(self.contentV).offset(30);
  68. make.leading.equalTo(self.contentV).offset(20);
  69. make.trailing.equalTo(self.contentV).offset(-20);
  70. }];
  71. [self.collectV mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.top.equalTo(self.userInfoV.mas_bottom).offset(50);
  73. make.leading.trailing.equalTo(self.contentV);
  74. CGFloat collH = (KScreenWidth-40)/335*256;
  75. make.height.equalTo(@(collH));
  76. }];
  77. [self.control mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.height.equalTo(@10);
  79. make.leading.equalTo(self.contentV).offset(20);
  80. make.trailing.equalTo(self.contentV).offset(-20);
  81. make.top.equalTo(self.collectV.mas_bottom).offset(20);
  82. }];
  83. [stv mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.equalTo(self.control.mas_bottom).offset(20);
  85. make.leading.trailing.equalTo(self.contentV);
  86. make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
  87. }];
  88. }
  89. // MARK: - subvs
  90. - (ASUserBaseInfoView *)userInfoV {
  91. if (!_userInfoV) {
  92. ASUserBaseInfoView *v = [[ASUserBaseInfoView alloc] initWithFrame:CGRectZero];
  93. v.backgroundColor = UIColor.clearColor;
  94. v.usefualLb.font = [UIFont fontWithName:Rob_Regular size:14];
  95. v.usefualLb.textColor = Col_666;
  96. v.avaterV.layer.cornerRadius = 8;
  97. v.avaterV.layer.masksToBounds = true;
  98. _userInfoV = v;
  99. }
  100. return _userInfoV;
  101. }
  102. - (UIScrollView *)scrollV {
  103. if (!_scrollV) {
  104. UIScrollView *v = [[UIScrollView alloc] init];
  105. v.backgroundColor = UIColor.clearColor;
  106. v.showsVerticalScrollIndicator = false;
  107. v.alwaysBounceVertical = true;
  108. _scrollV = v;
  109. }
  110. return _scrollV;
  111. }
  112. - (UIView *)contentV {
  113. if (!_contentV) {
  114. UIView *v = [UIView baseV];
  115. v.backgroundColor = UIColor.clearColor;
  116. _contentV = v;
  117. }
  118. return _contentV;
  119. }
  120. - (UICollectionView *)collectV {
  121. if (!_collectV) {
  122. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  123. layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
  124. layout.minimumInteritemSpacing = 0;
  125. layout.minimumLineSpacing = 0;
  126. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  127. CGFloat collH = (KScreenWidth-40)/335*256;
  128. layout.itemSize = CGSizeMake(KScreenWidth, collH);
  129. UICollectionView *collV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, collH) collectionViewLayout:layout];
  130. collV.backgroundColor = [UIColor clearColor];
  131. collV.alwaysBounceHorizontal = true;
  132. collV.scrollEnabled = true;
  133. collV.pagingEnabled = true;
  134. collV.delegate = self;
  135. collV.dataSource = self;
  136. collV.showsHorizontalScrollIndicator = false;
  137. [collV registerClass:[ASVipCenterCollectCell class] forCellWithReuseIdentifier:@"ASVipCenterCollectCell"];
  138. _collectV = collV;
  139. }
  140. return _collectV;
  141. }
  142. -(UIPageControl *)control {
  143. if (!_control) {
  144. _control = [[UIPageControl alloc] init];
  145. [_control setTintColor:[UIColor colorWithHexString:@"#000000"]];
  146. [_control setPageIndicatorTintColor:[[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.3] ];
  147. [_control setCurrentPageIndicatorTintColor:[UIColor colorWithHexString:@"#000000"] ];
  148. _control.transform = CGAffineTransformScale(_control.transform, 1.15, 1.15);
  149. }
  150. return _control;
  151. }
  152. - (UIStackView *)getBottomV {
  153. UIStackView *stv = [UIStackView baseStackV:true];
  154. stv.spacing = 0;
  155. stv.distribution = UIStackViewDistributionFillEqually;
  156. self.bottomVArr = [NSMutableArray array];
  157. for (int i=0; i<self.bottomTitleArr.count; i++) {
  158. NSString *title = self.bottomTitleArr[i];
  159. ASVipCenterLineItemView *v = [[ASVipCenterLineItemView alloc] initWithFrame:CGRectZero];
  160. [v setData:title canGoNext:true];
  161. v.tag = 90000+i;
  162. __weak typeof(v) weakV = v;
  163. v.selectCallBack = ^{
  164. if (weakV.tag%100 == 0) {
  165. ASVipCouponsViewController *vc = [ASVipCouponsViewController new];
  166. [self.navigationController pushViewController:vc animated:true];
  167. } else {
  168. ASBirthdayTreatViewController *vc = [ASBirthdayTreatViewController new];
  169. vc.isBirthday = arc4random()%2 == 1;
  170. [self.navigationController pushViewController:vc animated:true];
  171. }
  172. };
  173. [self.bottomVArr addObject:v];
  174. [stv addArrangedSubview:v];
  175. }
  176. return stv;
  177. }
  178. // MARK: - collectV delegate datesource
  179. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  180. return self.vipImgArr.count;
  181. }
  182. - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  183. ASVipCenterCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASVipCenterCollectCell" forIndexPath:indexPath];
  184. [cell setData:self.vipImgArr[indexPath.row] desStr:@"INTEGRAL TO 0-1000"];
  185. cell.desLb.textColor = Col_000;
  186. if (indexPath.row == self.vipImgArr.count-1) {
  187. cell.desLb.textColor = _FFE797;
  188. }
  189. return cell;
  190. }
  191. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  192. NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
  193. self.control.currentPage = page;
  194. }
  195. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
  196. NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
  197. self.control.currentPage = page;
  198. }
  199. @end