123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //
- // RQHomeSubPageVideoScrollViewController.m
- // JSJP
- //
- // Created by 张嵘 on 2021/11/11.
- //
- #import "RQHomeSubPageVideoScrollViewController.h"
- @interface RQHomeSubPageVideoScrollViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) RQHomeSubPageVideoScrollViewModel *viewModel;
- @property (nonatomic, readwrite, strong) JXPagerView *pagerView;
- @property (nonatomic, readwrite, strong) JXCategoryTitleView *categoryView;
- @property (nonatomic, readwrite, strong) NSArray <NSString *> *titles;
- @property (nonatomic, readwrite, strong) UIScrollView *currentListView;
- @property (nonatomic, readwrite, copy) void(^scrollCallback)(UIScrollView *scrollView);
- @end
- @implementation RQHomeSubPageVideoScrollViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- self.pagerView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(194.f));
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- self.titles = [self.viewModel.videosItemArr.rac_sequence map:^id _Nullable(VideosItem *videosItem) {
- return videosItem.title;
- }].array;
- if (self.titles.count > 1) {
- self.titles = @[self.titles.firstObject];
- }
- [self.view addSubview:self.pagerView];
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return [UIView new];
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- return 0.f;
- }
- - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return 0.f;
- }
- - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return self.categoryView;
- }
- - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
- //和categoryView的item数量一致
- return self.categoryView.titles.count;
- }
- - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
- @weakify(self);
- RQHomeSubPageVideoScrollSubViewModel *homeSubPageVideoScrollSubViewModel = [[RQHomeSubPageVideoScrollSubViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQViewModelUtilKey : self.viewModel.treeListModel,
- RQVideoItemIndexKey : @(self.viewModel.index),
- RQVideoItemIndexPathKey : [NSIndexPath indexPathForRow:index inSection:self.viewModel.myIndexPath.section],
- RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
- RQViewCommonValueKey : self.viewModel.videosItemArr[index],
- }];
- RQHomeSubPageVideoScrollSubViewController *homeSubPageVideoScrollSubViewController = [[RQHomeSubPageVideoScrollSubViewController alloc] initWithViewModel:homeSubPageVideoScrollSubViewModel];
- homeSubPageVideoScrollSubViewController.scrollCallback = ^(UIScrollView *scrollView) {
- @strongify(self);
- self.scrollCallback(scrollView);
- };
- self.currentListView = homeSubPageVideoScrollSubViewController.tableView;
- return homeSubPageVideoScrollSubViewController;
- }
- - (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
- }
- #pragma mark - JXCategoryViewDelegate
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
- self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
- //根据选中的下标,实时更新currentListView
- RQHomeSubPageVideoScrollSubViewController *list = (RQHomeSubPageVideoScrollSubViewController *)self.pagerView.listContainerView.validListDict[@(index)];
- self.currentListView = list.tableView;
- }
- - (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index {
-
- }
- - (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
- }
- #pragma mark - JXPagerMainTableViewGestureDelegate
- - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- //禁止categoryView左右滑动的时候,上下和左右都可以滚动
- if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
- return NO;
- }
- return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- !self.scrollCallback ?: self.scrollCallback(scrollView);
- }
- #pragma mark - JXPagingViewListViewDelegate
- - (UIView *)listView {
- return self.view;
- }
- - (UIScrollView *)listScrollView {
- return self.currentListView;
- }
- - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
- self.scrollCallback = callback;
- }
- - (void)listScrollViewWillResetContentOffset {
- //当前的listScrollView需要重置的时候,就把所有列表的contentOffset都重置了
- // for (RQHomePageSubjectOneOrFourViewController *list in self.pagerView.listContainerView.validListDict.allValues) {
- // list.collectionView.contentOffset = CGPointZero;
- // }
- }
- #pragma mark - LazyLoad
- - (JXPagerView *)pagerView {
- if (!_pagerView) {
- _pagerView = [[JXPagerView alloc] initWithDelegate:self];
- _pagerView.mainTableView.gestureDelegate = self;
- _pagerView.mainTableView.bounces = NO;
- _pagerView.listContainerView.categoryNestPagingEnabled = YES;
- _pagerView.listContainerView.frame = CGRectMake(0, RQHeightForPinSectionHeaderInPagerView, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQHeightForPinSectionHeaderInPagerView_One - RQHeightForPinSectionHeaderInPagerView - RQ_APPLICATION_TAB_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
- self.contentScrollView = _pagerView.listContainerView.contentScrollView;
- }
- return _pagerView;
- }
- - (JXCategoryTitleView *)categoryView {
- if (!_categoryView) {
- _categoryView = [[JXCategoryTitleView alloc] init];
- _categoryView.titles = self.titles;
- _categoryView.backgroundColor = [UIColor whiteColor];
- _categoryView.titleSelectedColor = RQ_MAIN_TEXT_COLOR_1;
- _categoryView.titleColor = RQ_MAIN_TEXT_COLOR_2;
- _categoryView.titleFont = RQRegularFont(13);
- _categoryView.titleSelectedFont = RQRegularFont(15);
- _categoryView.titleColorGradientEnabled = YES;
- _categoryView.titleLabelZoomEnabled = NO;
- _categoryView.contentScrollViewClickTransitionAnimationEnabled = NO;
- _categoryView.titleLabelZoomSelectedVerticalOffset = 0.0f;
- _categoryView.titleLabelVerticalOffset = 6.f;
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.indicatorColor = RQ_MAIN_COLOR;
- lineView.indicatorWidth = 20;
- lineView.indicatorHeight = 4;
- _categoryView.indicators = @[lineView];
-
- _categoryView.defaultSelectedIndex = 0;
- _categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- _categoryView.delegate = self;
- }
- return _categoryView;
- }
- - (NSArray<NSString *> *)titles {
- if (!_titles) {
- _titles = @[@"侧方停车", @"倒车入库", @"坡道定点\n停车与起步", @"曲线行驶", @"直角转弯"];
- }
- return _titles;
- }
- @end
|