123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598 |
- //
- // RQHomePageViewController.m
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/21.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #import "RQHomePageViewController.h"
- #import "MapManager.h"
- #import "RQQRCodeViewController.h"
- #import "ScanVC.h"
- #import "ScanPageVC.h"
- #import "DistenceTooLongMapVC.h"
- @interface RQHomePageViewController () <JXCategoryViewDelegate, JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate, SDCycleScrollViewDelegate>
- /// viewModel
- @property (nonatomic, readonly, strong) RQHomePageViewModel *viewModel;
- @property (nonatomic, readwrite, strong) RQHomePageTitleView *homePageTitleView;
- @property (nonatomic, readwrite, strong) JXPagerView *pagerView;
- @property (nonatomic, readwrite, strong) JXCategoryTitleView *categoryView;
- @property (nonatomic, readwrite, copy) NSArray <NSString *> *titles;
- //集中式理论
- @property (nonatomic, readwrite, assign) BOOL isNeedTest;
- @property (nonatomic, readwrite, assign) BOOL isCloseAudio;
- @property (nonatomic, readwrite, assign) NSInteger maxTime;
- @property (nonatomic, readwrite, copy) NSString *scanType;
- @property (nonatomic, readwrite, copy) NSString *scanData;
- @property (nonatomic, readwrite, assign) CLLocationCoordinate2D myLocation;
- @end
- @implementation RQHomePageViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
-
- // if (myDelegate.isLogin) {
- // //更新登录信息 如果是登录状态的时候
- // reLogin(self);
- // }
-
-
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if (RQ_COMMON_MANAGER.JSJP_APP_ICON_NEED_CHANGE) {
- [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon_NewRule" completionHandler:^(NSError * _Nullable error) {
- if (error != nil) {
- NSLog(@"set alternative icon error:%@", error.localizedDescription);
- }
- }];
- } else {
- [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon_Old" completionHandler:^(NSError * _Nullable error) {
- if (error != nil) {
- NSLog(@"set alternative icon error:%@", error.localizedDescription);
- }
- }];
- }
- }
- - (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_TAB_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
- }
- - (void)dealloc{
-
- //移除指定的通知,不然会造成内存泄露
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"Tiku_Change" object:nil];
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- @weakify(self)
- [self.view addSubview:self.pagerView];
- [RACObserve(RQ_USER_MANAGER, currentUser) subscribeNext:^(RQUserModel *userModel) {
- @strongify(self)
- //头像
- CGFloat sBoader = (kNavBarHeight - 35)/2.0;
- UIButton *sideBtn = [[UIButton alloc] initWithFrame:CGRectMake(sBoader, kStatusHeight + sBoader, kNavBarHeight - sBoader*2, kNavBarHeight - sBoader*2)];
- [self.view addSubview:sideBtn];
-
- UIImageView *iv = [[UIImageView alloc] initWithFrame:sideBtn.bounds];
- [iv sd_setImageWithURL:[NSURL URLWithString:userModel.photo] placeholderImage:[UIImage imageNamed:@"头像"]];
- iv.contentMode = UIViewContentModeScaleAspectFill;
- [iv setBoardWid:1 Color:RQ_MAIN_COLOR CornerRadius:6];
- [iv setRound];
-
- [sideBtn addSubview:iv];
- [sideBtn addTarget:self action:@selector(showLeftViewAction) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem* bbi0 = [[UIBarButtonItem alloc] initWithCustomView:sideBtn];
- self.navigationItem.leftBarButtonItem = bbi0;
- }];
-
- if (myDelegate.isSyn) {
- myDelegate.isSyn = NO;
-
- if ([myDelegate.markQuestionTableData isKindOfClass:[NSMutableArray class]]) {
- if (myDelegate.markQuestionTableData.count == 0) {
- [DB_Que_Helper moveIsDoneToMarkQuestion];//移动已做题
- if (myDelegate.isLogin)//更新版本 先做一次同步
- {
- [self syncQuestion];
- }
- }
- }
- }
-
- //监听题库变化
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationAction:) name:@"Tiku_Change" object:nil];
-
- // 注册手势驱动
- // __weak typeof(self)weakSelf = self;
- // [self cw_registerShowIntractiveWithEdgeGesture:YES transitionDirectionAutoBlock:^(CWDrawerTransitionDirection direction) {
- // if (direction == CWDrawerTransitionFromLeft) { // 左侧滑出
- // [weakSelf defaultAnimationFromLeft];
- // }
- // }];
-
- self.navigationItem.titleView = self.homePageTitleView;
- self.homePageTitleView.carTypeLabel.text = [RQ_YDTQuestion_Module getCarTypeCNNameWithCarType:RQ_YDTQuestion_Module.carType];
- //二维码扫描登录网页
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"erWeiMa.png"] originImageScaleToSize:CGSizeMake(22.5, 22.5)] style:UIBarButtonItemStyleDone target:self action:@selector(clickToScan)];
- item.tintColor = RQ_MAIN_COLOR;
- if (RQ_USER_MANAGER.currentUser.city && ![RQ_USER_MANAGER.currentUser.city isEqualToString:@""] && [RQ_USER_MANAGER.currentUser.city isEqualToString:@""]) {
-
- }
- [RACObserve(RQ_USER_MANAGER, currentUser) subscribeNext:^(RQUserModel *userModel) {
- @strongify(self)
- if ([RQ_USER_MANAGER.currentUser.isOpenScan boolValue]) {
- [self.navigationItem setRightBarButtonItem:item];
- } else {
- self.navigationItem.rightBarButtonItems = @[];
- }
- }];
-
- [[[[RQNotificationCenter rac_addObserverForName:RQCarTypeChangeNotification object:nil] takeUntil:self.rac_willDeallocSignal] deliverOnMainThread] subscribeNext:^(NSNotification * _Nullable x) {
- @strongify(self)
- self.pagerView.defaultSelectedIndex = 0;
- self.categoryView.defaultSelectedIndex = 0;
- [self.pagerView reloadData];
- [self.categoryView reloadData];
- self.pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
- self.homePageTitleView.carTypeLabel.text = [RQ_YDTQuestion_Module getCarTypeCNNameWithCarType:RQ_YDTQuestion_Module.carType];
- }];
-
- [[[[RACObserve(RQ_COMMON_MANAGER, APP_SWITCH) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
- @strongify(self)
- // self.pagerView.defaultSelectedIndex = 0;
- // self.categoryView.defaultSelectedIndex = 0;
- [self.pagerView reloadData];
- [self.categoryView reloadData];
- }];
-
-
- // [[RACSignal combineLatest:@[RACObserve(RQ_VIP_Module, isVip), RACObserve(RQ_COMMON_MANAGER, APP_SWITCH)] reduce:^id (NSNumber *isVip, NSNumber *APP_SWITCH) {
- // if (RQ_VIP_Module.isVip && RQ_COMMON_MANAGER.APP_SWITCH) {
- // return @(NO);
- // } else {
- // return @(RQ_COMMON_MANAGER.APP_SWITCH);
- // }
- // }] subscribeNext:^(NSNumber *APP_SWITCH) {
- // if (APP_SWITCH.boolValue != RQ_COMMON_MANAGER.APP_SWITCH) {
- // RQ_COMMON_MANAGER.APP_SWITCH = NO;
- // }
- // }];
- }
- - (void)notificationAction:(NSNotification *)notification{
- self.pagerView.defaultSelectedIndex = 0;
- self.categoryView.defaultSelectedIndex = 0;
- [self.pagerView reloadData];
- [self.categoryView reloadData];
-
- self.pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
-
- if ([notification.userInfo[@"zhigezhengChanged"] isEqualToString:@"NO"]) {
- return;
- }
- }
- /**显示左边抽屉
- */
- - (void)showLeftViewAction {
- [self defaultAnimationFromLeft];
- }
- - (void)clickToScan {
- @weakify(self)
-
- if (RQ_USER_MANAGER.isShouldLogin) {
- [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
- @strongify(self)
- if (isSuccess) {
- if (activationModel.isShare) {
- if (activationModel.isActive == 1) {
- [self gotoPt];
- } else {
- [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
- }
- } else {
- [self gotoPt];
- }
- }
- }];
- }
- }
- - (void)gotoPt {
- @weakify(self)
- [QMUITips showLoadingInView:DefaultTipsParentView];
- RQQRCodeViewController *vc = [[RQQRCodeViewController alloc] init];
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [vc initBlock:^(NSString * _Nonnull result, BOOL isSuccess) {
- if (isSuccess) {
- [RQ_PT_Object_Module uploadScanCodeVerifyWithQRCodeResultStr:result resultBlock:^(BOOL isSuccess) {
-
- }];
- } else {
- ShowMsg(result);
- }
- }];
-
- [LOCATION_MANAGER updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
- @strongify(self)
- if (success) {
- if (RQ_USER_MANAGER.verifyLevel == 0) {
- [self presentViewController:vc animated:YES completion:^{
- [QMUITips hideAllTips];
- }];
- } else {
- if (bmkLocation.mockProbability <= RQ_USER_MANAGER.verifyLevel) {
- [self presentViewController:vc animated:YES completion:^{
- [QMUITips hideAllTips];
- }];
- } else {
- [RQ_SHARE_FUNCTION showAlertWithMessage:@"请勿篡改定位信息!" completion:^(NSUInteger selectedOtherButtonIndex) {
- [QMUITips hideAllTips];
- }];
- }
- }
- } else {
- [RQ_SHARE_FUNCTION showAlertWithMessage:@"定位失败!" completion:^(NSUInteger selectedOtherButtonIndex) {
- [QMUITips hideAllTips];
- }];
- }
- }];
- }
- - (void)getMyLocation {
- //定位功能
- [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
- [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
- [MBProgressHUD rq_hideHUD];
- if (success) {
- _myLocation = location.coordinate;
- [self studentQrcode];
- }
- }];
- }
- /** 扫描二维码调取接口 */
- - (void)studentQrcode {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- if (_myLocation.longitude == 0.0) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"位置获取失败,请重新扫描二维码!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
-
- [arr addPro:@"studentOutid" Value:RQ_USER_MANAGER.currentUser.outId];
- [arr addPro:@"qrcode" Value:_scanData];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
- [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",_myLocation.longitude]];
- [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",_myLocation.latitude]];
- [arr addPro:@"type" Value:_scanType];
- [arr addPro:@"telType" Value:@"ios"];
-
- NSString *method = @"studentQrcode";
-
- NSString *str = [_scanType isEqualToString: @"1"] ? @"签到中...":@"签退中...";
- [MBProgressHUD rq_showProgressHUD:str];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD rq_hideHUD];
- if (!root) {
- ShowMsg(@"操作失败,请重试!");
- [Tools playAudioWithString:@"操作失败,请重试!"];
- return;
- }
- if ([root[@"code"] integerValue] == 0) {//代表操作成功
-
- if ([_scanType isEqualToString:@"1"] || [_scanType isEqualToString:@"3"]) {
- myDelegate.trainStateLabel.text = @"理论学习中...";
- }
-
- if ([_scanType isEqualToString:@"2"]) {
- myDelegate.trainStateLabel.text = @"";
- }
-
-
- if (_isNeedTest) {
- switch ([_scanType integerValue]) { //1、签到 2、签退 3、过程验证
- case 1://签到成功
- if (_maxTime > 0) {
- [self setNotificationWithFireTime:_maxTime];
- }
- break;
- case 2://签退
- if ([[[UIApplication sharedApplication] scheduledLocalNotifications] count] > 0) {
- [[UIApplication sharedApplication] cancelAllLocalNotifications];
- }
- break;
- case 3://验证成功
- if (_maxTime > 0) {
- [self setNotificationWithFireTime:_maxTime];
- }
- break;
- default:
- break;
- }
- }
- }
-
- if ([root[@"code"] integerValue] == 2) {//距离理论教室位置较远
-
- NSString *str = root[@"msg"];
- if (str.length < 1) {
- return;
- }
- NSArray *mapArray = [str componentsSeparatedByString:@";"];
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:[mapArray lastObject] preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
- [alert addAction:[UIAlertAction actionWithTitle:@"查看位置详情" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //进入地图页面 传入两个点 一个距离 lng lat len
- if (mapArray.count > 3) {
- // lng = 123.467129,
- // lat = 41.813997
- //122.769684;41.515881;66822;您当前距离理论教室位置66822米,请到理论教室扫码!
-
- DistenceTooLongMapVC *mapVC = [[DistenceTooLongMapVC alloc] init];
- mapVC.lat1 = _myLocation.latitude;
- mapVC.lng1 = _myLocation.longitude;
- mapVC.lat2 = [mapArray[1] floatValue];
- mapVC.lng2 = [mapArray[0] floatValue];
- mapVC.distence = mapArray[2];
- mapVC.skipMspBlock = ^{
- _myLocation.longitude = 0.0;
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"位置已重置,请重新扫描二维码!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- };
- [self navPushHideTabbarToVC:mapVC];
- }
- }]];
- [self presentViewController:alert animated:true completion:nil];
- return;
- }
-
- [Tools playAudioWithString:root[@"msg"]];
- ShowMsg(root[@"msg"]);
- }];
- }
- //语音播报或者推送
- - (void)setNotificationWithFireTime:(NSInteger)fireTime {
-
- //移除旧的通知
- if ([[[UIApplication sharedApplication] scheduledLocalNotifications] count] > 0) {
- [[UIApplication sharedApplication] cancelAllLocalNotifications];
- }
-
-
- //定义本地通知对象
- UILocalNotification *notification = [[UILocalNotification alloc]init];
- //设置调用时间
- notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:fireTime];
-
- //设置通知属性
- notification.alertBody = @"极速驾培提醒您"; //通知主体
- notification.applicationIconBadgeNumber = 1;//应用程序图标右上角显示的消息数
- notification.alertAction = @"打开应用"; //待机界面的滑动动作提示
- notification.soundName = @"TrainTest.mp3";//收到通知时播放的声音,默认消息声音
- // 通知参数
- NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:@"nothing",@"ShiCaoPeriodVC_reTakePhoto", nil];
- notification.userInfo = userDict;
- //调用通知
- [[UIApplication sharedApplication] scheduleLocalNotification:notification];
- }
- //更新第一次进入同步数据
- - (void)syncQuestion {
- if (![Util connectedToNetWork]) {
- return;
- }
- [self getMyQuestionType:@"" Subject:@""];
- }
- - (void)getMyQuestionType:(NSString*)type Subject:(NSString*)subject {
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"user" Value:RQ_USER_MANAGER.currentUser._id];
- [arr addPro:@"type" Value:type];
- [arr addPro:@"subject" Value:subject];
- [arr addPro:@"carType" Value:RQ_YDTQuestion_Module.car_type];
- [arr addPro:@"isPage" Value:@"0"];
- [arr addPro:@"pageSize" Value:@"0"];
- [arr addPro:@"currentPage" Value:@"0"];
-
- NSString* method = @"getMyQuestionFavs";
- [MBProgressHUD rq_showProgressHUD:@"收藏、错题同步中,请稍后..."];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- //NSLog(@"同步错题收藏---->%@--->%@",arr,root);
- if (!root || [root[@"code"] integerValue] == 1) {
-
- [MBProgressHUD rq_hideHUD];
- ShowMsg(@"题库错题、收藏、排除同步失败,请在侧栏手动同步");
- return;
- }
-
- NSArray *body = [root objectForKey:@"body"];
- if (body.count > 0) {
- if ([DB_Que_Helper deleteAllMarkQuestion]) {
- [DB_Que_Helper setMarkQuestionWithArray:body];
- }
- }
-
- [MBProgressHUD rq_hideHUD];
- [MBProgressHUD rq_showTips:@"题库错题、收藏、排除已同步完毕"];
- }];
- }
- // 仿QQ从左侧划出
- - (void)defaultAnimationFromLeft {
- if (RQ_USER_MANAGER.isShouldLogin) {
- [RQ_APPDELEGATE.services pushViewModel:[[RQSettingViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil] animated:YES];
- }
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return [UIView new];
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- return 0.f;
- }
- - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return [RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"]? 0.f : 49.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 {
- myDelegate.subject = [NSString stringWithFormat:@"%d",(int)index + 1];
- NSInteger myIndex = index;
- RQ_YDTQuestion_Module.subject = myIndex;
- RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
- RQHomePageSubjectOneOrFourViewModel *homePageSubjectFourViewModel = [[RQHomePageSubjectOneOrFourViewModel alloc] initWithServices:self.viewModel.services params:@{RQHomePageCarTypeKey : @(RQHomePageCarType_Car), RQHomePageSubjectTypeKey : @(myIndex)}];
- RQHomePageSubjectOneOrFourViewController *homePageSubjectFourViewController = [[RQHomePageSubjectOneOrFourViewController alloc] initWithViewModel:homePageSubjectFourViewModel];
- return homePageSubjectFourViewController;
- }
- #pragma mark - JXCategoryViewDelegate
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
- RQ_YDTQuestion_Module.subject = index;
- RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
- myDelegate.subject = [NSString stringWithFormat:@"%d",(int)index + 1];
- self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
- }
- - (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index {
- }
- - (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
- }
- - (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio {
- // if (RQ_YDTQuestion_Module.subject == leftIndex) {
- // /// 向左滑 向右滚动
- // if (1.f - ratio > 0.7) {
- // RQ_YDTQuestion_Module.subject = rightIndex;
- // }
- // } else if (RQ_YDTQuestion_Module.subject == rightIndex) {
- // /// 向右滑 向左滚动
- // if (1.f - ratio > 0.3) {
- // RQ_YDTQuestion_Module.subject = leftIndex;
- // }
- // }
- }
- #pragma mark - JXPagerMainTableViewGestureDelegate
- - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- if ([self checkIsNestContentScrollView:(UIScrollView *)gestureRecognizer.view] || [self checkIsNestContentScrollView:(UIScrollView *)otherGestureRecognizer.view]) {
- //如果交互的是嵌套的contentScrollView,证明在左右滑动,就不允许同时响应
- return NO;
- }
- return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
- }
- - (BOOL)checkIsNestContentScrollView:(UIScrollView *)scrollView {
- for (RQHomeSubPageViewController *list in self.pagerView.validListDict.allValues) {
- if (list.contentScrollView == scrollView) {
- return YES;
- }
- }
- return NO;
- }
- #pragma mark - SDCycleScrollViewDelegate
- - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
-
- }
- #pragma mark - LazyLoad
- - (JXPagerView *)pagerView {
- if (!_pagerView) {
- _pagerView = [[JXPagerView alloc] initWithDelegate:self];
- _pagerView.mainTableView.gestureDelegate = self;
- _pagerView.defaultSelectedIndex = 0;
- _pagerView.mainTableView.bounces = NO;
- _pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
- }
- 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(17);
- _categoryView.titleSelectedFont = RQSemiboldFont(22);
- _categoryView.titleColorGradientEnabled = YES;
- _categoryView.titleLabelZoomEnabled = YES;
- _categoryView.contentScrollViewClickTransitionAnimationEnabled = YES;
- _categoryView.titleLabelZoomSelectedVerticalOffset = 0.0f;
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.indicatorColor = RQ_MAIN_COLOR;
- lineView.indicatorHeight = 4;
- lineView.verticalMargin = 0;
- _categoryView.indicators = @[lineView];
-
- _categoryView.defaultSelectedIndex = 0;
- _categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- _categoryView.delegate = self;
- }
- return _categoryView;
- }
- - (NSArray<NSString *> *)titles {
- return @[@"科一", @"科二", @"科三", @"科四"];
- }
- - (RQHomePageTitleView *)homePageTitleView {
- if (!_homePageTitleView) {
- _homePageTitleView = [RQHomePageTitleView homePageTitleViewView];
- _homePageTitleView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH / 3.f, RQ_APPLICATION_NAV_BAR_HEIGHT);
- }
- return _homePageTitleView;
- }
- @end
|