| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 | 
							- //
 
- //  ASPointDetailViewController.m
 
- //  Asteria
 
- //
 
- //  Created by iOS on 2023/6/24.
 
- //
 
- #import "ASPointDetailViewController.h"
 
- #import "ASPointDetailTableView.h"
 
- #import "ASPointsViewModel.h"
 
- @interface ASPointDetailViewController () <UIScrollViewDelegate>
 
- @property (nonatomic, strong) ASPointsViewModel *vm;
 
- @property (nonatomic, assign) NSInteger allPage;
 
- @property (nonatomic, assign) NSInteger usedPage;
 
- @property (nonatomic, strong) UIView *topBgV;
 
- @property (nonatomic, strong) UIView *bottomBgV;
 
- @property (nonatomic, strong) UIButton *allBt;
 
- @property (nonatomic, strong) UIButton *usedBt;
 
- @property (nonatomic, strong) UIScrollView *scrollV;
 
- @property (nonatomic, strong) ASPointDetailTableView *allTableV;
 
- @property (nonatomic, strong) ASPointDetailTableView *usedTableV;
 
- @end
 
- @implementation ASPointDetailViewController
 
- - (void)viewDidLoad {
 
-     [super viewDidLoad];
 
-     self.vm = [ASPointsViewModel new];
 
-     self.allPage = 1;
 
-     self.usedPage = 1;
 
-     [self loadSubVs];
 
-     [self configSubVs];
 
- }
 
- - (void)viewWillAppear:(BOOL)animated {
 
-     [super viewWillAppear:animated];
 
-     [self checkEmpty];
 
- }
 
- - (void)checkEmpty {
 
-     if (_allTableV.dataArr.count == 0 && self.allBt.isSelected) {
 
-         [self showEmptyV: self.allTableV];
 
-     } else if (_usedTableV.dataArr.count == 0 && self.usedBt.isSelected) {
 
-         [self showEmptyV: self.usedTableV];
 
-     } else {
 
-         [self hiddenEmpty];
 
-     }
 
- }
 
- // MARK: - nets
 
- - (void)getAllListData {
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     __weak typeof(self) weakSelf = self;
 
-     [self.vm getAllList:self.allPage com:^(BOOL hasNext, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf.allTableV.mj_header endRefreshing];
 
-         if (hasNext) {
 
-             [weakSelf.allTableV.mj_footer endRefreshing];
 
-         } else {
 
-             [weakSelf.allTableV.mj_footer endRefreshingWithNoMoreData];
 
-         }
 
-         weakSelf.allTableV.dataArr = weakSelf.vm.allList;
 
-         [weakSelf checkEmpty];
 
-         [weakSelf.allTableV reloadData];
 
-     }];
 
- }
 
- - (void)getUsedListData {
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     __weak typeof(self) weakSelf = self;
 
-     [self.vm getUsedList:self.usedPage com:^(BOOL hasNext, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf.usedTableV.mj_header endRefreshing];
 
-         if (hasNext) {
 
-             [weakSelf.usedTableV.mj_footer endRefreshing];
 
-         } else {
 
-             [weakSelf.usedTableV.mj_footer endRefreshingWithNoMoreData];
 
-         }
 
-         weakSelf.usedTableV.dataArr = weakSelf.vm.usedList;
 
-         [weakSelf checkEmpty];
 
-         [weakSelf.usedTableV reloadData];
 
-     }];
 
- }
 
- // MARK: - loadSubVs
 
- - (void)configSubVs {
 
-     self.view.backgroundColor = _E0FFF5;
 
-     self.customNavBar.backgroundColor = _F0FFFA;
 
-     self.titleStr = @"Points Details";
 
-     __weak typeof(self) weakSelf = self;
 
-     [self setNavRightSearch:^{
 
-         
 
-     }];
 
-     self.allTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
 
-         weakSelf.allPage = 1;
 
-         [weakSelf getAllListData];
 
-     }];
 
-     self.allTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
 
-         weakSelf.allPage += 1;
 
-         [weakSelf getAllListData];
 
-     }];
 
-     
 
-     self.usedTableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
 
-         weakSelf.usedPage = 1;
 
-         [weakSelf getUsedListData];
 
-     }];
 
-     self.usedTableV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
 
-         weakSelf.usedPage += 1;
 
-         [weakSelf getUsedListData];
 
-     }];
 
-     
 
-     [self.allTableV.mj_header beginRefreshing];
 
-     [self.usedTableV.mj_header beginRefreshing];
 
- }
 
- - (void)loadSubVs {
 
-     [self.view addSubview:self.topBgV];
 
-     [self.view addSubview:self.bottomBgV];
 
-     
 
-     [self.topBgV addSubview:self.allBt];
 
-     [self.topBgV addSubview:self.usedBt];
 
-     
 
-     [self.bottomBgV addSubview:self.scrollV];
 
-     [self.scrollV addSubview:self.allTableV];
 
-     [self.scrollV addSubview:self.usedTableV];
 
-     
 
-     
 
-     [self.topBgV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.customNavBar.mas_bottom);
 
-         make.leading.trailing.equalTo(self.view);
 
-         make.height.equalTo(@60);
 
-     }];
 
-     
 
-     [self.allBt mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.centerY.equalTo(self.topBgV);
 
-         make.height.equalTo(@40);
 
-         make.leading.equalTo(self.topBgV).offset(10);
 
-     }];
 
-     [self.usedBt mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.centerY.equalTo(self.allBt);
 
-         make.height.equalTo(@40);
 
-         make.leading.equalTo(self.allBt.mas_trailing).offset(10);
 
-         make.trailing.equalTo(self.topBgV).offset(-10);
 
-         make.width.equalTo(self.allBt);
 
-     }];
 
-     
 
-     [self.bottomBgV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.topBgV.mas_bottom);
 
-         make.leading.trailing.bottom.equalTo(self.view);
 
-     }];
 
-     
 
-     [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.bottomBgV).offset(10);
 
-         make.leading.trailing.bottom.equalTo(self.bottomBgV);
 
-     }];
 
-     
 
-     [self.allTableV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.leading.bottom.equalTo(self.scrollV);
 
-         make.width.equalTo(self.bottomBgV);
 
-         make.height.equalTo(self.bottomBgV).offset(-10);
 
-     }];
 
-     
 
-     [self.usedTableV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.leading.equalTo(self.allTableV.mas_trailing);
 
-         make.top.trailing.bottom.equalTo(self.scrollV);
 
-         make.width.equalTo(self.bottomBgV);
 
-         make.height.equalTo(self.bottomBgV).offset(-10);
 
-     }];
 
-     
 
-     
 
- }
 
- // MARK: - bt Actions
 
- - (void)topBtAction:(UIButton *)bt {
 
-     if (bt == self.usedBt) {
 
-         self.allBt.selected = false;
 
-         self.usedBt.selected = true;
 
-         [self.scrollV setContentOffset:CGPointMake(KScreenWidth, 0) animated:true];
 
-     } else {
 
-         self.allBt.selected = true;
 
-         self.usedBt.selected = false;
 
-         [self.scrollV setContentOffset:CGPointMake(0, 0) animated:true];
 
-     }
 
-     [self setBtStatus:self.allBt];
 
-     [self setBtStatus:self.usedBt];
 
-     [self checkEmpty];
 
- }
 
- - (void)setBtStatus:(UIButton *)bt {
 
-     bt.backgroundColor = bt.isSelected ? _113632 : Col_FFF;
 
-     bt.titleLabel.font = [UIFont fontWithName:bt.isSelected ? Rob_Bold : Rob_Regular size:16];
 
-     
 
- }
 
- // MARK: - subvs
 
- - (UIView *)topBgV {
 
-     if (!_topBgV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = _E0FFF5;
 
-         _topBgV = v;
 
-     }
 
-     return _topBgV;
 
- }
 
- - (UIView *)bottomBgV{
 
-     if (!_bottomBgV) {
 
-         UIView *v = [UIView baseV];
 
-         v.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
 
-         v.backgroundColor = Col_FFF;
 
-         // 左上和右上为圆角
 
-         UIBezierPath *cornerRadiusPath = [UIBezierPath      bezierPathWithRoundedRect:v.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)];
 
-         
 
-         CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc ] init];
 
-         cornerRadiusLayer.frame = v.bounds;
 
-         
 
-         cornerRadiusLayer.path = cornerRadiusPath.CGPath;
 
-         
 
-         v.layer.mask = cornerRadiusLayer;
 
-         
 
-         _bottomBgV = v;
 
-     }
 
-     return _bottomBgV;
 
- }
 
- - (UIButton *)allBt {
 
-     if (!_allBt) {
 
-         UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [bt addTarget:self action:@selector(topBtAction:) forControlEvents:UIControlEventTouchUpInside];
 
-         bt.selected = true;
 
-         bt.backgroundColor = _113632;
 
-         bt.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16];
 
-         [bt setTitleColor:Col_000 forState:UIControlStateNormal];
 
-         bt.layer.cornerRadius = 4;
 
-         bt.layer.masksToBounds = true;
 
-         [bt setTitleColor:Col_FFF forState:UIControlStateSelected];
 
-         [bt setTitle:@"ALL" forState:UIControlStateNormal];
 
-         _allBt = bt;
 
-     }
 
-     return _allBt;
 
- }
 
- - (UIButton *)usedBt {
 
-     if (!_usedBt) {
 
-         UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [bt addTarget:self action:@selector(topBtAction:) forControlEvents:UIControlEventTouchUpInside];
 
-         bt.backgroundColor = Col_FFF;
 
-         bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
 
-         [bt setTitleColor:Col_000 forState:UIControlStateNormal];
 
-         bt.layer.cornerRadius = 4;
 
-         bt.layer.masksToBounds = true;
 
-         [bt setTitleColor:Col_FFF forState:UIControlStateSelected];
 
-         [bt setTitle:@"USED" forState:UIControlStateNormal];
 
-         _usedBt = bt;
 
-     }
 
-     return _usedBt;
 
- }
 
- - (UIScrollView *)scrollV {
 
-     if (!_scrollV) {
 
-         UIScrollView *v = [[UIScrollView alloc] init];
 
-         v.showsVerticalScrollIndicator = false;
 
-         v.showsHorizontalScrollIndicator = false;
 
-         v.delegate = self;
 
-         v.pagingEnabled = true;
 
-         v.backgroundColor = UIColor.clearColor;
 
-         v.alwaysBounceHorizontal = true;
 
-         _scrollV = v;
 
-     }
 
-     return _scrollV;
 
- }
 
- - (ASPointDetailTableView *)allTableV {
 
-     if (!_allTableV) {
 
-         ASPointDetailTableView *v = [[ASPointDetailTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
 
-         _allTableV = v;
 
-     }
 
-     return _allTableV;
 
- }
 
- - (ASPointDetailTableView *)usedTableV {
 
-     if (!_usedTableV) {
 
-         ASPointDetailTableView *v = [[ASPointDetailTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
 
-         _usedTableV = v;
 
-     }
 
-     return _usedTableV;
 
- }
 
- // MARK: - scrollview delegate
 
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
 
-     NSInteger index = (NSInteger)(scrollView.contentOffset.x/KScreenWidth);
 
-     self.allBt.selected = index == 0;
 
-     self.usedBt.selected = index == 1;
 
-     [self setBtStatus:self.allBt];
 
-     [self setBtStatus:self.usedBt];
 
-     [self checkEmpty];
 
- }
 
- - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
 
-     NSInteger index = (NSInteger)(scrollView.contentOffset.x/KScreenWidth);
 
-     self.allBt.selected = index == 0;
 
-     self.usedBt.selected = index == 1;
 
-     [self setBtStatus:self.allBt];
 
-     [self setBtStatus:self.usedBt];
 
-     [self checkEmpty];
 
-     
 
- }
 
- @end
 
 
  |