123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- //
- // RQErrorAndCollectViewController.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/8/3.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "RQErrorAndCollectViewController.h"
- @interface RQErrorAndCollectViewController () <JXCategoryViewDelegate, JXPagerViewDelegate, JXPagerSmoothViewDataSource>
- /// viewModel
- @property (nonatomic, readonly, strong) RQErrorAndCollectViewModel *viewModel;
- @property (nonatomic, readwrite, strong) JXPagerSmoothView *pagerView;
- @property (nonatomic, readwrite, strong) JXCategoryTitleView *categoryView;
- @property (nonatomic, readwrite, copy) NSArray <NSString *> *titles;
- @end
- @implementation RQErrorAndCollectViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- self.pagerView.frame = CGRectMake(0, (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT), RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
- }
- - (void)dealloc {
- self.categoryView.delegate = nil;
- self.categoryView = nil;
- self.pagerView = nil;
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- [self.view addSubview:self.pagerView];
- self.navigationItem.titleView = self.categoryView;
- }
- #pragma mark - JXPagerSmoothView
- - (UIView *)viewForPagerHeaderInPagerView:(JXPagerSmoothView *)pagerView {
- return [UIView new];
- }
- - (CGFloat)heightForPagerHeaderInPagerView:(JXPagerSmoothView *)pagerView {
- return 0;
- }
- - (CGFloat)heightForPinHeaderInPagerView:(JXPagerSmoothView *)pagerView {
- return 0.f;
- }
- - (UIView *)viewForPinHeaderInPagerView:(JXPagerSmoothView *)pagerView {
- return [UIView new];
- }
- - (NSInteger)numberOfListsInPagerView:(JXPagerSmoothView *)pagerView {
- //和categoryView的item数量一致
- return self.categoryView.titles.count;
- }
- - (id<JXPagerSmoothViewListViewDelegate>)pagerView:(JXPagerSmoothView *)pagerView initListAtIndex:(NSInteger)index {
- if (index == 0) {
- RQErrorViewModel *errorViewModel = [[RQErrorViewModel alloc] initWithServices:self.viewModel.services params:@{}];
- RQErrorViewController *errorViewController = [[RQErrorViewController alloc] initWithViewModel:errorViewModel];
- return errorViewController;
- } else {
- RQCollectViewModel *collectViewModel = [[RQCollectViewModel alloc] initWithServices:self.viewModel.services params:@{}];
- RQCollectViewController *collectViewController = [[RQCollectViewController alloc] initWithViewModel:collectViewModel];
- return collectViewController;
- }
- }
- #pragma mark - JXCategoryViewDelegate
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
- self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
- }
- #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]];
- }
- #pragma mark - LazyLoad
- - (JXPagerSmoothView *)pagerView {
- if (!_pagerView) {
- _pagerView = [[JXPagerSmoothView alloc] initWithDataSource:self];
- }
- return _pagerView;
- }
- - (JXCategoryTitleView *)categoryView {
- if (!_categoryView) {
- CGFloat autoReadBtnWidth = RQ_FIT_HORIZONTAL(80.f);
- CGFloat autoReadBtnHeight = RQ_FIT_HORIZONTAL(28.f);
-
- _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, autoReadBtnWidth * 2, autoReadBtnHeight)];
- _categoryView.delegate = self;
-
- _categoryView.titles = self.titles;
- _categoryView.titleSelectedColor = UIColor.whiteColor;
- _categoryView.titleColor = RQ_MAIN_TEXT_COLOR_3;
- _categoryView.titleFont = RQRegularFont(13);
- _categoryView.titleSelectedFont = RQRegularFont(13);
- _categoryView.titleNumberOfLines = 0;
- _categoryView.layer.cornerRadius = autoReadBtnHeight / 2.f;
- _categoryView.layer.borderWidth = 1;
- _categoryView.layer.borderColor = RQColorFromHexString(@"#B8C0CC").CGColor;
-
- _categoryView.contentScrollViewClickTransitionAnimationEnabled = YES;
- _categoryView.backgroundColor = UIColor.whiteColor;
- _categoryView.contentEdgeInsetLeft = 0;
- _categoryView.contentEdgeInsetRight = 0;
- _categoryView.backgroundColor = RQ_MAIN_BACKGROUNDCOLOR;
-
- _categoryView.cellSpacing = 0;
- _categoryView.cellWidth = autoReadBtnWidth;
-
-
-
-
- JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundView.indicatorHeight = autoReadBtnHeight;
- backgroundView.indicatorWidth = autoReadBtnWidth;
- backgroundView.indicatorWidthIncrement = 0;
- backgroundView.indicatorColor = RQ_MAIN_COLOR;
- _categoryView.indicators = @[backgroundView];
-
- _categoryView.defaultSelectedIndex = 0;
- /// !!!: 将列表容器视图关联到 categoryView
- _categoryView.contentScrollView = self.pagerView.listCollectionView;
- }
- return _categoryView;
- }
- - (NSArray<NSString *> *)titles {
- return @[@"错题本", @"收藏题目"];
- }
- @end
|