NYClassRoomVC.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // NYClassRoomVC.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/2/4.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. //
  8. #import "NYClassRoomVC.h"
  9. #import "NYClassRoomViewModel.h"
  10. #import "NYGetjobStartRuleCell.h"
  11. #import "CultivateInfoModel.h"
  12. #import "CultivatePhotoModel.h"
  13. #import "NYClassRoomPeiCell.h"
  14. #import "RQQRCodeViewController.h"
  15. @interface NYClassRoomVC ()
  16. /// viewModel
  17. @property (nonatomic, readonly, strong) NYClassRoomViewModel *viewModel;
  18. @property (nonatomic, readwrite, strong) UIButton *signInOrsignOutItem;
  19. @property (nonatomic, readwrite, strong) NYClassRoomPeiCell *nyClassRoomPeiCell;
  20. @end
  21. @implementation NYClassRoomVC
  22. @dynamic viewModel;
  23. #pragma mark - SystemMethod
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. self.view.backgroundColor = UIColor.whiteColor;
  28. self.collectionView.backgroundColor = UIColor.clearColor;
  29. self.collectionView.backgroundView.backgroundColor = UIColor.clearColor;
  30. UIImageView *bgImageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"classroom_bgbg"]];
  31. [self.view insertSubview:bgImageView atIndex:0];
  32. [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.top.right.mas_equalTo(self.view);
  34. make.height.mas_equalTo(184.f);
  35. }];
  36. if(self.viewModel.isSimulationRoom){ //模拟训练
  37. self.viewModel.classRoomPeiViewModel.isSimulationRoom = self.viewModel.isSimulationRoom;
  38. UIBarButtonItem *baritem = [[UIBarButtonItem alloc] initWithCustomView:self.signInOrsignOutItem];
  39. [self.navigationItem setRightBarButtonItems:@[baritem]];
  40. }
  41. }
  42. - (UIColor *)qmui_titleViewTintColor
  43. {
  44. return UIColor.whiteColor;
  45. }
  46. - (UIImage *)qmui_navigationBarBackgroundImage
  47. {
  48. return [UIImage qmui_imageWithColor:UIColor.clearColor];
  49. }
  50. #pragma mark - OverrideMethods
  51. /// 配置collectionView的区域
  52. - (UIEdgeInsets)contentInset {
  53. return UIEdgeInsetsMake(RQ_APPLICATION_STATUS_BAR_HEIGHT + RQ_APPLICATION_NAV_BAR_HEIGHT, 0, 0, 0);
  54. }
  55. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  56. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  57. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  58. UICollectionViewCell *cell = [NSClassFromString(itemViewModel.itemClassName) cellWithCollectionView:collectionView forIndexPath:indexPath];
  59. if([itemViewModel.itemClassName isEqualToString:@"NYClassRoomPeiCell"]){
  60. self.nyClassRoomPeiCell = (NYClassRoomPeiCell *)cell;
  61. self.nyClassRoomPeiCell.signInOrsignOutItem = self.signInOrsignOutItem;
  62. }
  63. return cell;
  64. }
  65. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  66. [cell bindViewModel:object];
  67. }
  68. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  69. switch (section) {
  70. case 1: {
  71. return UIEdgeInsetsMake(0, 16, 0, 16);
  72. }
  73. default: {
  74. return UIEdgeInsetsZero;
  75. }
  76. }
  77. }
  78. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  79. switch (section) {
  80. case 1:
  81. return (RQ_SCREEN_WIDTH - 32 - (RQ_FIT_HORIZONTAL(90.f) * 3)) / 2.f;
  82. default:
  83. return 8;
  84. }
  85. }
  86. - (UIButton *)signInOrsignOutItem {
  87. if (!_signInOrsignOutItem) {
  88. UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
  89. customButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
  90. [customButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  91. [customButton setTitle:@"签到" forState:UIControlStateNormal];
  92. [customButton addTarget:self action:@selector(gotoSignInOrsignOut) forControlEvents:UIControlEventTouchUpInside];
  93. _signInOrsignOutItem = customButton;
  94. // _signInOrsignOutItem = [UIBarButtonItem rq_systemItemWithTitle:@"签到" titleColor:RQ_LIST_BACKGROUNDCOLOR imageName:nil target:self selector:@selector(gotoSignInOrsignOut) textType:YES];
  95. }
  96. return _signInOrsignOutItem;
  97. }
  98. - (void)gotoSignInOrsignOut {
  99. [self.nyClassRoomPeiCell gotoSignInOrsignOut];
  100. }
  101. @end