MORoomThemeBaseView.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // MORoomThemeBaseView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/8/13.
  6. //
  7. #import "MORoomThemeBaseView.h"
  8. @interface MORoomThemeBaseView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  9. @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
  10. @property (nonatomic, strong) UIView *titleBgView;
  11. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  12. @end
  13. @implementation MORoomThemeBaseView
  14. - (instancetype)init{
  15. self = [super init];
  16. if (self)
  17. {
  18. [self setupUI];
  19. }
  20. return self;
  21. }
  22. - (instancetype)initWithFrame:(CGRect)frame
  23. {
  24. self = [super initWithFrame:frame];
  25. if (self)
  26. {
  27. [self setupUI];
  28. }
  29. return self;
  30. }
  31. #pragma mark - JXCategoryListContentViewDelegate
  32. - (void)listWillAppear{
  33. }
  34. - (UIView *)listView{
  35. return self;
  36. }
  37. - (void)setupUI{
  38. [self addSubview:self.titleBgView];
  39. [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.equalTo(self).offset(5.0);
  41. make.left.equalTo(self).offset(15.0);
  42. make.right.equalTo(self).offset(-15.0);
  43. make.height.equalTo(@32.0);
  44. }];
  45. self.titleBgView.layer.cornerRadius = 32.0 / 2.0;
  46. [self addSubview:self.titleCategoryView];
  47. [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.centerY.equalTo(self.titleBgView.mas_centerY);
  49. make.left.equalTo(self).offset(0.0);
  50. make.right.equalTo(self).offset(-0.0);
  51. make.height.equalTo(@70.0);
  52. }];
  53. self.titleCategoryView.titles = @[NSLocalString(@"mimo_create_live_set_background"),NSLocalString(@"mimo_create_live_set_style"),NSLocalString(@"mimo_create_live_set_ripple")];
  54. CGFloat totalItemWidth = SCREENWIDTH;
  55. CGFloat cellWidth = totalItemWidth / self.titleCategoryView.titles.count;
  56. self.titleCategoryView.cellSpacing = 0;
  57. self.titleCategoryView.cellWidth = cellWidth;
  58. self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0];
  59. self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor;
  60. self.titleCategoryView.titleLabelMaskEnabled = YES;
  61. self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentFontStr];
  62. self.titleCategoryView.backgroundColor = [UIColor clearColor];
  63. JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
  64. backgroundView.indicatorHeight = 70.0;
  65. backgroundView.indicatorWidth = 148.0;
  66. backgroundView.indicatorWidthIncrement = 0;
  67. backgroundView.indicatorColor = [UIColor clearColor];
  68. backgroundView.verticalMargin = 4.0;
  69. UIImageView *imgBgView = [[UIImageView alloc] init];
  70. imgBgView.contentMode = UIViewContentModeScaleToFill;
  71. [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]];
  72. [backgroundView addSubview:imgBgView];
  73. [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.edges.equalTo(backgroundView);
  75. }];
  76. self.titleCategoryView.indicators = @[backgroundView];
  77. [self addSubview:self.listContainerView];
  78. [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.equalTo(self).offset(50.0);
  80. make.left.right.bottom.equalTo(self);
  81. }];
  82. self.titleCategoryView.listContainer = self.listContainerView;
  83. }
  84. - (void)setBaseData:(MOVoiceThemeData *)baseData{
  85. _baseData = baseData;
  86. [self.listContainerView reloadData];
  87. }
  88. // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  89. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  90. MOLogV(@"变换了");
  91. }
  92. #pragma mark - JXCategoryListContainerViewDelegate
  93. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  94. return self.titleCategoryView.titles.count;
  95. }
  96. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  97. WEAKSELF
  98. if(index == 0){
  99. MORoomBackgroundSetView *view = [[MORoomBackgroundSetView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 310.0)];
  100. view.dataArr = [self.baseData.backgrounds copy];
  101. view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
  102. weakSelf.backgroundSelectBlock ? weakSelf.backgroundSelectBlock(cellModel) : nil;
  103. };
  104. return view;
  105. }
  106. else{
  107. MORoomStyleAndRippleSetView *view = [[MORoomStyleAndRippleSetView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 310.0)];
  108. if(index == 1){
  109. view.dataArr = [self.baseData.microStyleModel copy];
  110. view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
  111. weakSelf.styleSelectBlock ? weakSelf.styleSelectBlock(cellModel) : nil;
  112. };
  113. }
  114. else{
  115. view.dataArr = [self.baseData.soundRipple copy];
  116. view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
  117. weakSelf.rippleSelectBlock ? weakSelf.rippleSelectBlock(cellModel) : nil;
  118. };
  119. }
  120. return view;
  121. }
  122. }
  123. #pragma Lazy
  124. - (JXCategoryTitleView *)titleCategoryView{
  125. if(!_titleCategoryView){
  126. _titleCategoryView = [[JXCategoryTitleView alloc] init];
  127. _titleCategoryView.delegate = self;
  128. }
  129. return _titleCategoryView;
  130. }
  131. - (JXCategoryListContainerView *)listContainerView{
  132. if(!_listContainerView){
  133. _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  134. }
  135. return _listContainerView;
  136. }
  137. - (UIView *)titleBgView{
  138. if(!_titleBgView){
  139. _titleBgView = [[UIView alloc] init];
  140. _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05];
  141. }
  142. return _titleBgView;
  143. }
  144. @end