MOPkContributionView.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // MOPkContributionView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/2/18.
  6. //
  7. #import "MOPkContributionView.h"
  8. #import "MOPkRankContributionTableView.h"
  9. @interface MOPkContributionView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  10. @property (weak, nonatomic) IBOutlet UIView *bgView;
  11. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  12. @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
  13. @property (nonatomic, strong) UIView *titleBgView;
  14. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  15. @end
  16. @implementation MOPkContributionView
  17. + (instancetype)moPkContributionView{
  18. return [[[NSBundle mainBundle] loadNibNamed:@"MOPkContributionView" owner:self options:nil] firstObject];
  19. }
  20. - (IBAction)closeBtnClick:(id)sender {
  21. [self dismissPkContributionView];
  22. }
  23. - (void)awakeFromNib{
  24. [super awakeFromNib];
  25. self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalContentFontStr];
  26. self.bgView.layer.cornerRadius = 16.0;
  27. self.bgView.layer.masksToBounds = YES;
  28. [self.bgView addSubview:self.titleBgView];
  29. [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.equalTo(self.titleLab.mas_bottom).offset(12.0);
  31. make.left.equalTo(self.bgView).offset(45.0);
  32. make.right.equalTo(self.bgView).offset(-45.0);
  33. make.height.equalTo(@32.0);
  34. }];
  35. self.titleBgView.layer.cornerRadius = 32.0 / 2.0;
  36. [self.bgView addSubview:self.titleCategoryView];
  37. [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.centerY.equalTo(self.titleBgView.mas_centerY);
  39. make.left.equalTo(self.bgView).offset(40.0);
  40. make.right.equalTo(self.bgView).offset(-40.0);
  41. make.height.equalTo(@70.0);
  42. }];
  43. self.titleCategoryView.titles = @[@"Our side",@"Other side"];
  44. CGFloat totalItemWidth = SCREENWIDTH - 40.0 * 2.0 - 22.0 * 2.0;
  45. self.titleCategoryView.cellSpacing = 0.0;
  46. self.titleCategoryView.cellWidth = totalItemWidth / self.titleCategoryView.titles.count;
  47. self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0];
  48. self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor;
  49. self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:15.0 AndFontName:kNormalContentFontStr];
  50. self.titleCategoryView.titleSelectedFont = [MOTextTools getTheFontWithSize:15.0 AndFontName:kNormalContentFontStr];
  51. self.titleCategoryView.backgroundColor = [UIColor clearColor];
  52. JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
  53. backgroundView.indicatorHeight = 70.0;
  54. backgroundView.indicatorWidth = totalItemWidth / self.titleCategoryView.titles.count + 30.0;
  55. backgroundView.indicatorWidthIncrement = 0;
  56. backgroundView.indicatorColor = [UIColor clearColor];
  57. backgroundView.verticalMargin = 4.0;
  58. // NSArray *colorArr = @[[MOTools colorWithHexString:@"#FF62EE" alpha:1.0],[MOTools colorWithHexString:@"#9923FF" alpha:1.0]];
  59. // UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 15.0 * 2) / 2.0, 40.0) Colors:colorArr GradientType:0];
  60. UIImageView *imgBgView = [[UIImageView alloc] init];
  61. imgBgView.contentMode = UIViewContentModeScaleToFill;
  62. [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]];
  63. [backgroundView addSubview:imgBgView];
  64. [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.edges.equalTo(backgroundView);
  66. }];
  67. self.titleCategoryView.indicators = @[backgroundView];
  68. [self.bgView addSubview:self.listContainerView];
  69. [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.equalTo(self.titleCategoryView.mas_bottom).offset(5.0);
  71. make.left.right.bottom.equalTo(self.bgView);
  72. }];
  73. self.titleCategoryView.listContainer = self.listContainerView;
  74. }
  75. // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  76. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  77. MOLogV(@"变换了");
  78. }
  79. #pragma mark - JXCategoryListContainerViewDelegate
  80. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  81. return self.titleCategoryView.titles.count;
  82. }
  83. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  84. MOPkRankContributionTableView *view = [[MOPkRankContributionTableView alloc] init];
  85. view.viewType = index + 1;
  86. view.roomId = self.roomId;
  87. WEAKSELF
  88. view.cellClickBlock = ^(NSString * _Nonnull userId, NSInteger viewType) {
  89. weakSelf.cellClickBlock ? weakSelf.cellClickBlock(userId,viewType) : nil;
  90. [weakSelf dismissPkContributionView];
  91. };
  92. return view;
  93. }
  94. #pragma mark - Lazy
  95. - (JXCategoryTitleView *)titleCategoryView{
  96. if(!_titleCategoryView){
  97. _titleCategoryView = [[JXCategoryTitleView alloc] init];
  98. _titleCategoryView.delegate = self;
  99. }
  100. return _titleCategoryView;
  101. }
  102. - (JXCategoryListContainerView *)listContainerView{
  103. if(!_listContainerView){
  104. _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  105. }
  106. return _listContainerView;
  107. }
  108. - (UIView *)titleBgView{
  109. if(!_titleBgView){
  110. _titleBgView = [[UIView alloc] init];
  111. _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05];
  112. }
  113. return _titleBgView;
  114. }
  115. - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
  116. return UIInterfaceOrientationMaskPortrait;
  117. }
  118. - (void)showPkContributionView//界面显示动画
  119. {
  120. UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
  121. [keyWindow addSubview:self];
  122. self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT);
  123. //动画效果
  124. self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
  125. self.bgView.alpha = 0;
  126. [UIView animateWithDuration:0.2 animations:^
  127. {
  128. self.bgView.transform = CGAffineTransformMakeScale(1.0, 1.0);
  129. self.bgView.alpha = 1;
  130. } completion:^(BOOL finished)
  131. {
  132. }];
  133. //不能滑动
  134. SendNotification(@"MOShowLivePagesVCCannotScroll")
  135. }
  136. - (void)dismissPkContributionView//取消掉键盘
  137. {
  138. [UIView animateWithDuration:0.2 animations:^
  139. {
  140. self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
  141. self.bgView.alpha = 0;
  142. } completion:^(BOOL finished)
  143. {
  144. if (finished)
  145. {
  146. [self.bgView removeFromSuperview];
  147. [self removeFromSuperview];
  148. }
  149. }];
  150. //可以滑动
  151. SendNotification(@"MOShowLivePagesVCCanScroll")
  152. }
  153. @end