123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // RQSimulationResultsViewController.m
- // SDJK
- //
- // Created by 张嵘 on 2021/8/6.
- //
- #import "RQSimulationResultsViewController.h"
- @interface RQSimulationResultsViewController ()
- // viewModel
- @property (nonatomic, readwrite, strong) RQSimulationResultsViewModel *viewModel;
- @property (nonatomic, readwrite, strong) RQSimulationResultsHeaderView *simulationResultsHeaderView;
- @property (nonatomic, readwrite, strong) RQSimulationResultsSeectionHeaderView *simulationResultsSeectionHeaderView;
- @property (nonatomic, readwrite, strong) UIView *tableViewBgView;
- @end
- @implementation RQSimulationResultsViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- self.simulationResultsHeaderView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQSimulationResultsHeaderViewHeight + 24 - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT);
- self.tableView.frame = CGRectMake(0, CGRectGetMaxY(self.simulationResultsHeaderView.frame) + 10 + 40, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - CGRectGetMaxY(self.simulationResultsHeaderView.frame) - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - 10 - 40 - 15);
- self.tableViewBgView.frame = CGRectMake(16, CGRectGetMaxY(self.simulationResultsHeaderView.frame) + 10, RQ_SCREEN_WIDTH - 32, RQ_SCREEN_HEIGHT - CGRectGetMaxY(self.simulationResultsHeaderView.frame) - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - 10);
- self.simulationResultsSeectionHeaderView.frame = CGRectMake(16, 0, RQ_SCREEN_WIDTH - 32 - 32, 40);
- [self.view sendSubviewToBack:self.tableViewBgView];
- self.emptyView.frame = CGRectMake(0, (RQSimulationResultsHeaderViewHeight + 24 - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT) / 2.f, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
- }
- #pragma mark - PrivateMethods
- - (void)rq_setup {
- self.tableView.backgroundColor = UIColor.clearColor;
- self.tableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:self.tableViewBgView];
- [self.view addSubview:self.simulationResultsHeaderView];
- }
- #pragma mark - OverrideMethods
- /// 配置tableView的区域
- - (UIEdgeInsets)contentInset {
- return UIEdgeInsetsMake(0, 0, 0, 0);
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- RQSimulationResultsListCell *cell = [RQSimulationResultsListCell cellWithTableView:tableView];
- cell.myContentView.backgroundColor = (indexPath.section %2 == 0)? [UIColor colorWithRed:73/255.0 green:142/255.0 blue:245/255.0 alpha:0.15] : RQ_MAIN_BACKGROUNDCOLOR;
- return cell;
- }
- - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- RQSimulationResultsListCell *simulationResultsListCell = (RQSimulationResultsListCell *)cell;
- [simulationResultsListCell bindViewModel:object];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH, 40)];
- }
- #pragma mark - LazyLoad
- - (RQSimulationResultsHeaderView *)simulationResultsHeaderView {
- if (!_simulationResultsHeaderView) {
- _simulationResultsHeaderView = [RQSimulationResultsHeaderView simulationResultsHeaderView];
- RAC(_simulationResultsHeaderView.examTotalLabel, text) = [RACObserve(self.viewModel, totalStr) distinctUntilChanged];
- }
- return _simulationResultsHeaderView;
- }
- - (RQSimulationResultsSeectionHeaderView *)simulationResultsSeectionHeaderView {
- if (!_simulationResultsSeectionHeaderView) {
- _simulationResultsSeectionHeaderView = [RQSimulationResultsSeectionHeaderView simulationResultsSeectionHeaderView];
- }
- return _simulationResultsSeectionHeaderView;
- }
- - (UIView *)tableViewBgView {
- if (!_tableViewBgView) {
- _tableViewBgView = [[UIView alloc] init];
- _tableViewBgView.frame = self.tableView.frame;
- _tableViewBgView.alpha = 1.0;
- _tableViewBgView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
- _tableViewBgView.layer.shadowColor = [UIColor colorWithRed:124/255.0 green:129/255.0 blue:136/255.0 alpha:0.20].CGColor;
- _tableViewBgView.layer.shadowOffset = CGSizeMake(0,0);
- _tableViewBgView.layer.shadowRadius = 8;
- _tableViewBgView.layer.shadowOpacity = 1;
- _tableViewBgView.layer.cornerRadius = 10;
-
- [_tableViewBgView addSubview:self.simulationResultsSeectionHeaderView];
- }
- return _tableViewBgView;
- }
- @end
|