123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- //
- // DocumentLibraryHomeVC.m
- // Telemarketing
- //
- // Created by apple on 2021/4/28.
- // Copyright © 2021 刘惠萍. All rights reserved.
- //
- #import "DocumentLibraryHomeVC.h"
- #import "SliderView.h"
- #import "DocumentLibraryListVC.h"
- @interface DocumentLibraryHomeVC ()<SliderViewDelegate,UIScrollViewDelegate>
- @property (strong, nonatomic) SliderView *sliderView;
- @property (nonatomic, strong) UIScrollView *scList;
- @property (nonatomic, strong) NSMutableArray *aryModelbtns;
- @property (strong, nonatomic) ModelBaseData *modelb;
- @end
- @implementation DocumentLibraryHomeVC
- - (NSMutableArray *)aryModelbtns{
- if (!_aryModelbtns) {
- _aryModelbtns = [NSMutableArray new];
- }
- return _aryModelbtns;
- }
- - (SliderView *)sliderView{
- if (_sliderView == nil) {
- _sliderView = [SliderView new];
- self.sliderView.frame = CGRectMake(0,W(5),SCREEN_WIDTH,W(44));
- _sliderView.viewSlidWidth = 15;
- _sliderView.isHasSlider = true;
- _sliderView.isLineVerticalHide = true;
- _sliderView.viewSlidColor = COLOR_BLUE;
- _sliderView.delegate = self;
- _sliderView.isScroll=true;
- }
-
- return _sliderView;
- }
- - (UIScrollView *)scList{
- if (!_scList) {
- _scList = [UIScrollView new];
- self.scList = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.sliderView.bottom +1, SCREEN_WIDTH, self.scAll.height - self.sliderView.height)];
- _scList.backgroundColor = [UIColor whiteColor];
- _scList.delegate = self;
- _scList.showsVerticalScrollIndicator = false;
- _scList.showsHorizontalScrollIndicator = false;
- // _scList.contentSize = CGSizeMake(SCREEN_WIDTH * 3, 0);
- _scList.pagingEnabled = true;
- }
- return _scList;
- }
- - (LinkScrollView *)scAll{
- if (!_scAll) {
- _scAll = [LinkScrollView new];
- _scAll.frame = CGRectMake(0, NAVIGATIONBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT-NAVIGATIONBAR_HEIGHT);
- _scAll.contentSize = CGSizeMake(0, SCREEN_HEIGHT*5);
- _scAll.backgroundColor = [UIColor clearColor];
- _scAll.showsVerticalScrollIndicator = false;
- _scAll.showsHorizontalScrollIndicator = false;
- _scAll.delegate = self;
- }
- return _scAll;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.view addSubview:[BaseNavView initNavBackTitle:@"文案库" rightView:nil]];
- [self.view addSubview:self.scAll];
-
- [self.scAll addSubview:self.sliderView];
- self.scAll.sizeHeight = self.sliderView.top - 2;
- [self.scAll addSubview:self.scList];
- [self requestList];
- [self setupChildVC];
-
- }
- #pragma mark scrollview delegat
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
- if ([scrollView isEqual:self.scList]) {
- [self fetchCurrentView];
- }
- }
- - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
- if ([scrollView isEqual:self.scList]) {
- if (!decelerate) {
- [self fetchCurrentView];
- }
- }
- }
- - (void)fetchCurrentView {
- // 获取已经滚动的比例
- double ratio = self.scList.contentOffset.x / SCREEN_WIDTH;
- int page = (int)(ratio + 0.5);
- // scrollview 到page页时 将toolbar调至对应按钮
- [self.sliderView sliderToIndex:page noticeDelegate:NO];
- [self setupChildVC];
- }
- - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
- if (scrollView == self.scAll) {
- if (velocity.y > 0||targetContentOffset->y>self.sliderView.top) {
- targetContentOffset->y = self.sliderView.top;
- }
- }
- }
- #pragma mark slider delegate
- - (void)protocolSliderViewBtnSelect:(NSUInteger)tag btn:(CustomSliderControl *)control{
- self.scList.contentOffset = CGPointMake(SCREEN_WIDTH * tag, 0);
- [self setupChildVC];
- }
- - (void)requestList{
- [RequestApi requestGetInformationTypeNameWithDelegate:self success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"data"] toAryWithModelName:@"ModelBrand"];
- [self.aryModelbtns removeAllObjects];
- [self.aryModelbtns addObject:[ModelBtn modelWithTitle:@"全部" imageName:nil highImageName:nil tag:0 color:COLOR_999 selectColor:COLOR_BLUE]];
- for (int i =0; i<ary.count; i++) {
- ModelBrand *modelL = ary[i];
- ModelBtn * modelAll = [ModelBtn new];
- modelAll.title = modelL.name;
- modelAll.color = COLOR_666;
- modelAll.colorSelect = COLOR_BLUE;
- modelAll.vcName = modelL.internalBaseClassIdentifier;
- [self.aryModelbtns addObject:modelAll];
- }
- [self.sliderView resetWithAry:self.aryModelbtns];
- [self setupChildVC];
-
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
- }
- - (void)setupChildVC{
- [self.scList removeAllSubViews];
- for ( int i = 0; i<self.aryModelbtns.count; i++) {
- ModelBtn *modelL = self.aryModelbtns[i];
- DocumentLibraryListVC * vc = [[DocumentLibraryListVC alloc] init];
- [self addChildViewController:vc];
- vc.view.frame = CGRectMake(SCREEN_WIDTH*i, 0, SCREEN_WIDTH, self.scList.height-W(10));
- vc.tableView.frame = vc.view.bounds;
- vc.activeStatus=isStr(modelL.vcName)?modelL.vcName:@"FFFFFF";
- [vc refreshHeaderAll];
- [self.scList addSubview:vc.view];
- }
-
- self.scList.contentSize = CGSizeMake(SCREEN_WIDTH * self.aryModelbtns.count, 0);
- }
- @end
|