ASVipCenterViewController.m 7.5 KB

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