|
@@ -0,0 +1,227 @@
|
|
|
+//
|
|
|
+// ASVipCenterViewController.m
|
|
|
+// Asteria
|
|
|
+//
|
|
|
+// Created by iOS on 2023/6/26.
|
|
|
+//
|
|
|
+
|
|
|
+#import "ASVipCenterViewController.h"
|
|
|
+#import "ASUserBaseInfoView.h"
|
|
|
+#import "ASVipCenterLineItemView.h"
|
|
|
+#import "ASVipCenterCollectCell.h"
|
|
|
+
|
|
|
+@interface ASVipCenterViewController () <UICollectionViewDelegate,UICollectionViewDataSource>
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIScrollView *scrollV;
|
|
|
+@property (nonatomic, strong) UIView *contentV;
|
|
|
+@property (nonatomic, strong) ASUserBaseInfoView *userInfoV;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UICollectionView *collectV;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIPageControl *control;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSMutableArray <ASVipCenterLineItemView *>*bottomVArr;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSArray *bottomTitleArr;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSArray *vipImgArr;
|
|
|
+
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation ASVipCenterViewController
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+
|
|
|
+ [UIView viewAddHorColorBg:self.view colorArr:@[
|
|
|
+ (id)_E0FFF5.CGColor,
|
|
|
+ (id)Col_FFF.CGColor
|
|
|
+ ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
|
|
|
+
|
|
|
+ self.bottomTitleArr = @[@"EXCLUSIVE $100 COUPON", @"BIRTHDAY TREAT"];
|
|
|
+ self.vipImgArr = @[@"vip_bg1",@"vip_bg2",@"vip_bg3",@"vip_bg4",@"vip_bg5"];
|
|
|
+ [self loadSubVs];
|
|
|
+ [self.view bringSubviewToFront:self.customNavBar];
|
|
|
+ [self configSubVs];
|
|
|
+ [self demoData];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)demoData {
|
|
|
+ self.userInfoV.usefualLb.text = @"Growth Value 7220/10000";
|
|
|
+ self.control.numberOfPages = self.vipImgArr.count;
|
|
|
+ self.control.currentPage = 0;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)configSubVs {
|
|
|
+ self.titleStr = @"VIP Center";
|
|
|
+ [self setNavRightSearch:^{
|
|
|
+
|
|
|
+ }];
|
|
|
+ self.statusBgV.backgroundColor = _E0FFF5;
|
|
|
+ self.customNavBar.backgroundColor = _F0FFFA;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - loadSubVs
|
|
|
+- (void)loadSubVs {
|
|
|
+ [self.view addSubview:self.scrollV];
|
|
|
+ [self.scrollV addSubview:self.contentV];
|
|
|
+ [self.contentV addSubview:self.userInfoV];
|
|
|
+ [self.contentV addSubview:self.collectV];
|
|
|
+ [self.contentV addSubview:self.control];
|
|
|
+ UIStackView *stv = [self getBottomV];
|
|
|
+ [self.contentV addSubview:stv];
|
|
|
+
|
|
|
+ [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.customNavBar.mas_bottom);
|
|
|
+ make.leading.trailing.bottom.equalTo(self.view);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.contentV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.scrollV);
|
|
|
+ make.width.equalTo(self.view);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.userInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.contentV).offset(30);
|
|
|
+ make.leading.equalTo(self.contentV).offset(20);
|
|
|
+ make.trailing.equalTo(self.contentV).offset(-20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.collectV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.userInfoV.mas_bottom).offset(50);
|
|
|
+ make.leading.trailing.equalTo(self.contentV);
|
|
|
+ CGFloat collH = (KScreenWidth-40)/335*256;
|
|
|
+ make.height.equalTo(@(collH));
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.control mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@10);
|
|
|
+ make.leading.equalTo(self.contentV).offset(20);
|
|
|
+ make.trailing.equalTo(self.contentV).offset(-20);
|
|
|
+ make.top.equalTo(self.collectV.mas_bottom).offset(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [stv mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.control.mas_bottom).offset(20);
|
|
|
+ make.leading.trailing.equalTo(self.contentV);
|
|
|
+ make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - subvs
|
|
|
+- (ASUserBaseInfoView *)userInfoV {
|
|
|
+ if (!_userInfoV) {
|
|
|
+ ASUserBaseInfoView *v = [[ASUserBaseInfoView alloc] initWithFrame:CGRectZero];
|
|
|
+ v.backgroundColor = UIColor.clearColor;
|
|
|
+ v.usefualLb.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ v.usefualLb.textColor = Col_666;
|
|
|
+ v.avaterV.layer.cornerRadius = 8;
|
|
|
+ v.avaterV.layer.masksToBounds = true;
|
|
|
+ _userInfoV = v;
|
|
|
+ }
|
|
|
+ return _userInfoV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIScrollView *)scrollV {
|
|
|
+ if (!_scrollV) {
|
|
|
+ UIScrollView *v = [[UIScrollView alloc] init];
|
|
|
+ v.backgroundColor = UIColor.clearColor;
|
|
|
+ v.showsVerticalScrollIndicator = false;
|
|
|
+ v.alwaysBounceVertical = true;
|
|
|
+ _scrollV = v;
|
|
|
+ }
|
|
|
+ return _scrollV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)contentV {
|
|
|
+ if (!_contentV) {
|
|
|
+ UIView *v = [UIView baseV];
|
|
|
+ v.backgroundColor = UIColor.clearColor;
|
|
|
+ _contentV = v;
|
|
|
+ }
|
|
|
+ return _contentV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UICollectionView *)collectV {
|
|
|
+ if (!_collectV) {
|
|
|
+ UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
|
+ layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
|
|
+ layout.minimumInteritemSpacing = 0;
|
|
|
+ layout.minimumLineSpacing = 0;
|
|
|
+ layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
+ CGFloat collH = (KScreenWidth-40)/335*256;
|
|
|
+ layout.itemSize = CGSizeMake(KScreenWidth, collH);
|
|
|
+ UICollectionView *collV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, collH) collectionViewLayout:layout];
|
|
|
+ collV.backgroundColor = [UIColor clearColor];
|
|
|
+ collV.alwaysBounceHorizontal = true;
|
|
|
+ collV.scrollEnabled = true;
|
|
|
+ collV.pagingEnabled = true;
|
|
|
+ collV.delegate = self;
|
|
|
+ collV.dataSource = self;
|
|
|
+ collV.showsHorizontalScrollIndicator = false;
|
|
|
+ [collV registerClass:[ASVipCenterCollectCell class] forCellWithReuseIdentifier:@"ASVipCenterCollectCell"];
|
|
|
+ _collectV = collV;
|
|
|
+ }
|
|
|
+ return _collectV;
|
|
|
+}
|
|
|
+
|
|
|
+-(UIPageControl *)control {
|
|
|
+ if (!_control) {
|
|
|
+ _control = [[UIPageControl alloc] init];
|
|
|
+ [_control setTintColor:[UIColor colorWithHexString:@"#000000"]];
|
|
|
+ [_control setPageIndicatorTintColor:[[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.3] ];
|
|
|
+ [_control setCurrentPageIndicatorTintColor:[UIColor colorWithHexString:@"#000000"] ];
|
|
|
+ _control.transform = CGAffineTransformScale(_control.transform, 1.15, 1.15);
|
|
|
+ }
|
|
|
+ return _control;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIStackView *)getBottomV {
|
|
|
+ UIStackView *stv = [UIStackView baseStackV:true];
|
|
|
+ stv.spacing = 0;
|
|
|
+ stv.distribution = UIStackViewDistributionFillEqually;
|
|
|
+
|
|
|
+ self.bottomVArr = [NSMutableArray array];
|
|
|
+ for (int i=0; i<self.bottomTitleArr.count; i++) {
|
|
|
+ NSString *title = self.bottomTitleArr[i];
|
|
|
+ ASVipCenterLineItemView *v = [[ASVipCenterLineItemView alloc] initWithFrame:CGRectZero];
|
|
|
+ [v setData:title canGoNext:true];
|
|
|
+ v.tag = 90000+i;
|
|
|
+ [self.bottomVArr addObject:v];
|
|
|
+ [stv addArrangedSubview:v];
|
|
|
+ }
|
|
|
+ return stv;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// MARK: - collectV delegate datesource
|
|
|
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
|
+ return self.vipImgArr.count;
|
|
|
+}
|
|
|
+
|
|
|
+- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+ ASVipCenterCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASVipCenterCollectCell" forIndexPath:indexPath];
|
|
|
+ [cell setData:self.vipImgArr[indexPath.row] desStr:@"INTEGRAL TO 0-1000"];
|
|
|
+ cell.desLb.textColor = Col_000;
|
|
|
+ if (indexPath.row == self.vipImgArr.count-1) {
|
|
|
+ cell.desLb.textColor = _FFE797;
|
|
|
+ }
|
|
|
+ return cell;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
|
+ NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
|
|
|
+ self.control.currentPage = page;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
|
|
|
+ NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
|
|
|
+ self.control.currentPage = page;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|