RQVipCenterSubViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // RQVipCenterSubViewController.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/8.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipCenterSubViewController.h"
  9. @interface RQVipCenterSubViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) RQVipCenterSubViewModel *viewModel;
  12. @property (nonatomic, readwrite, copy) void(^scrollCallback)(UIScrollView *scrollView);
  13. @property (nonatomic, readwrite, strong) JXPagerView *pagerView;
  14. @property (nonatomic, readwrite, strong) JXCategoryTitleView *categoryView;
  15. @property (nonatomic, readwrite, strong) NSArray <NSString *> *titles;
  16. @property (nonatomic, readwrite, strong) UIScrollView *currentListView;
  17. @end
  18. @implementation RQVipCenterSubViewController
  19. @dynamic viewModel;
  20. #pragma mark - SystemMethod
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. /// 初始化
  24. [self rq_setup];
  25. }
  26. - (void)viewDidLayoutSubviews {
  27. [super viewDidLayoutSubviews];
  28. self.pagerView.frame = CGRectMake(0, RQ_FIT_HORIZONTAL(102.f) + 32.f, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - RQ_APPLICATION_NAV_BAR_HEIGHT - RQ_APPLICATION_STATUS_BAR_HEIGHT - 0.f - RQ_FIT_HORIZONTAL(102.f) - 32.f - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  29. }
  30. #pragma mark - PrivateMethods
  31. /// 初始化
  32. - (void)rq_setup {
  33. /// set up ...
  34. [self.view addSubview:self.pagerView];
  35. }
  36. #pragma mark - JXPagerViewDelegate
  37. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  38. return [UIView new];
  39. }
  40. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  41. return 0.f;
  42. }
  43. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  44. return 0.f;
  45. }
  46. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  47. return self.categoryView;
  48. }
  49. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  50. //和categoryView的item数量一致
  51. return self.categoryView.titles.count;
  52. }
  53. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
  54. @weakify(self);
  55. RQVipCenterSubListViewModel *vipCenterSubListViewModel = [[RQVipCenterSubListViewModel alloc] initWithServices:self.viewModel.services params:@{RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType)}];
  56. RQVipCenterSubListViewController *vipCenterSubListViewController = [[RQVipCenterSubListViewController alloc] initWithViewModel:vipCenterSubListViewModel];
  57. vipCenterSubListViewController.scrollCallback = ^(UIScrollView *scrollView) {
  58. @strongify(self);
  59. self.scrollCallback(scrollView);
  60. };
  61. self.currentListView = vipCenterSubListViewController.collectionView;
  62. return vipCenterSubListViewController;
  63. }
  64. - (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
  65. }
  66. #pragma mark - JXCategoryViewDelegate
  67. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  68. self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
  69. //根据选中的下标,实时更新currentListView
  70. RQHomePageSubjectOneOrFourViewController *list = (RQHomePageSubjectOneOrFourViewController *)self.pagerView.listContainerView.validListDict[@(index)];
  71. self.currentListView = list.collectionView;
  72. }
  73. - (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index {
  74. }
  75. - (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
  76. }
  77. #pragma mark - JXPagerMainTableViewGestureDelegate
  78. - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  79. //禁止categoryView左右滑动的时候,上下和左右都可以滚动
  80. // NSLog(@"%@--------%@",NSStringFromClass([gestureRecognizer.view class]),NSStringFromClass([otherGestureRecognizer.view class]));
  81. if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
  82. return NO;
  83. }
  84. return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
  85. }
  86. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  87. !self.scrollCallback ?: self.scrollCallback(scrollView);
  88. }
  89. #pragma mark - JXPagingViewListViewDelegate
  90. - (UIView *)listView {
  91. return self.view;
  92. }
  93. - (UIScrollView *)listScrollView {
  94. return self.collectionView;
  95. }
  96. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  97. self.scrollCallback = callback;
  98. }
  99. #pragma mark - LazyLoad
  100. - (JXPagerView *)pagerView {
  101. if (!_pagerView) {
  102. _pagerView = [[JXPagerView alloc] initWithDelegate:self];
  103. _pagerView.mainTableView.gestureDelegate = self;
  104. _pagerView.mainTableView.bounces = NO;
  105. _pagerView.listContainerView.categoryNestPagingEnabled = YES;
  106. _pagerView.listContainerView.frame = CGRectMake(0, RQ_FIT_HORIZONTAL(102.f) + 32.f, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - RQ_APPLICATION_NAV_BAR_HEIGHT - RQ_APPLICATION_STATUS_BAR_HEIGHT - 88.f - RQ_FIT_HORIZONTAL(102.f) - 32.f - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  107. self.contentScrollView = _pagerView.listContainerView.contentScrollView;
  108. }
  109. return _pagerView;
  110. }
  111. - (JXCategoryTitleView *)categoryView {
  112. if (!_categoryView) {
  113. _categoryView = [[JXCategoryTitleView alloc] init];
  114. _categoryView.titles = self.titles;
  115. _categoryView.backgroundColor = [UIColor whiteColor];
  116. _categoryView.titleSelectedColor = RQ_MAIN_TEXT_COLOR_1;
  117. _categoryView.titleColor = RQ_MAIN_TEXT_COLOR_2;
  118. _categoryView.titleFont = RQRegularFont(16);
  119. _categoryView.titleSelectedFont = RQRegularFont(18);
  120. _categoryView.titleColorGradientEnabled = YES;
  121. _categoryView.titleLabelZoomEnabled = NO;
  122. _categoryView.contentScrollViewClickTransitionAnimationEnabled = NO;
  123. _categoryView.titleLabelZoomSelectedVerticalOffset = 0.0f;
  124. _categoryView.titleLabelVerticalOffset = 6.f;
  125. _categoryView.cellWidth = (RQ_SCREEN_WIDTH - 32.f) / self.titles.count;
  126. _categoryView.cellSpacing = 0;
  127. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  128. lineView.indicatorColor = RQ_MAIN_COLOR;
  129. lineView.indicatorWidth = 20;
  130. lineView.indicatorHeight = 4;
  131. _categoryView.indicators = @[lineView];
  132. _categoryView.defaultSelectedIndex = 0;
  133. _categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  134. _categoryView.delegate = self;
  135. }
  136. return _categoryView;
  137. }
  138. - (NSArray<NSString *> *)titles {
  139. return @[@""];
  140. }
  141. @end