123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- //
- // RQErrorViewController.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/8/3.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "RQErrorViewController.h"
- @interface RQErrorViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) RQErrorViewModel *viewModel;
- @property (nonatomic, readwrite, strong) RQErrorAndCollectHeaderView *errorHeaderView;
- @end
- @implementation RQErrorViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- @weakify(self)
- [super viewDidLoad];
- self.tableView.tableHeaderView = self.errorHeaderView;
- self.tableView.backgroundColor = UIColor.clearColor;
- [[RACObserve(self.viewModel, dataSource) deliverOnMainThread] subscribeNext:^(NSArray *dataSource) {
- @strongify(self)
- NSUInteger count = dataSource.count;
- if (count == 0) {
- // [self showEmptyViewWithImage:RQImageNamed(@"暂无错题") text:@"暂无错题,继续保持~" detailText:nil buttonTitle:nil buttonAction:nil];
- [self.emptyView setImage:RQImageNamed(@"暂无错题")];
- [self.emptyView setLoadingViewHidden:YES];
- [self.emptyView setTextLabelText:@"暂无错题,继续保持~"];
- [self.tableView addSubview:self.emptyView];
- [self.tableView sendSubviewToBack:self.emptyView];
- CGFloat a = 8.f + RQ_FIT_HORIZONTAL(214.f) + 4.f + RQ_FIT_HORIZONTAL(40.f) + 20.f + 10.f + ((10.f + ((RQ_SCREEN_WIDTH - 32.f) * (74.f / 345.f)) + 10.f) + (RQ_FIT_HORIZONTAL(56.f)) + (RQ_FIT_HORIZONTAL(49.f)));
- self.emptyView.frame = CGRectMake(0, a / 2.f + 50.f, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
- self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0);
- } else {
- [self hideEmptyView];
- self.tableView.contentInset = UIEdgeInsetsMake((RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT), 0, 0, 0);
- }
- }];
-
- [[[RQNotificationCenter rac_addObserverForName:RQCancelWrongNotification object:nil] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification * _Nullable x) {
- @strongify(self);
- self.errorHeaderView.allNumLabel.text = [NSString qmui_stringWithNSInteger:[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count];
- }];
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- self.tableView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - RQ_APPLICATION_STATUS_BAR_HEIGHT - RQ_APPLICATION_NAV_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
- self.errorHeaderView.size = CGSizeMake(RQ_SCREEN_WIDTH, 8.f + RQ_FIT_HORIZONTAL(214.f) + 4.f + RQ_FIT_HORIZONTAL(40.f) + 20.f + 10.f + ((10.f + ((RQ_SCREEN_WIDTH - 32.f) * (74.f / 345.f)) + 10.f) + (RQ_FIT_HORIZONTAL(56.f)) + (RQ_FIT_HORIZONTAL(49.f))));
- }
- #pragma mark - OverrideMethods
- - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
- return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
- }
- - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- [cell bindViewModel:object];
- }
- #pragma mark - JXPagerSmoothViewListViewDelegate
- - (UIView *)listView {
- return self.view;
- }
- - (UIScrollView *)listScrollView {
- return self.tableView;
- }
- #pragma mark - LazyLoad
- - (RQErrorAndCollectHeaderView *)errorHeaderView {
- if (!_errorHeaderView) {
- _errorHeaderView = [RQErrorAndCollectHeaderView errorAndCollectHeaderView];
- _errorHeaderView.size = CGSizeMake(RQ_SCREEN_WIDTH, 8.f + RQ_FIT_HORIZONTAL(214.f) + 4.f + RQ_FIT_HORIZONTAL(40.f) + 20.f + 10.f + ((10.f + ((RQ_SCREEN_WIDTH - 32.f) * (74.f / 345.f)) + 10.f) + (RQ_FIT_HORIZONTAL(56.f)) + (RQ_FIT_HORIZONTAL(49.f))));
- _errorHeaderView.bottomView.hidden = NO;
- [_errorHeaderView.todayErrorBtn setTitleNormal:@"今日错题"];
- [_errorHeaderView.allErrorBtn setTitleNormal:@"全部错题"];
- _errorHeaderView.titleLabel.text = @"错题数";
- _errorHeaderView.allNumLabel.text = [NSString qmui_stringWithNSInteger:[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count];
-
-
- [_errorHeaderView.todayErrorBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- NSArray *todayArr = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong];
- NSArray *arr = [todayArr.rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
- return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
- }].toArray;
- RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
- RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
- RQHomeSubPageTypeKey : @(RQHomeSubPageType_WrongTopicAndCollection),
- RQViewModelIDKey : @"今日错题",
- RQExerciseTypeKey : @(RQExerciseType_Wrong),
- RQViewModelUtilKey : arr,
- }];
- [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
- }];
-
- [_errorHeaderView.allErrorBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- NSArray *allArr = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong];
- NSArray *arr = [allArr.rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
- return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
- }].toArray;
- RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
- RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
- RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
- RQHomeSubPageTypeKey : @(RQHomeSubPageType_WrongTopicAndCollection),
- RQViewModelIDKey : @"全部错题",
- RQExerciseTypeKey : @(RQExerciseType_Wrong),
- RQViewModelUtilKey : arr,
- }];
- [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
- }];
- }
- return _errorHeaderView;
- }
- @end
|