| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- //
- // MORoomThemeBaseView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/8/13.
- //
- #import "MORoomThemeBaseView.h"
- @interface MORoomThemeBaseView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
- @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
- @property (nonatomic, strong) UIView *titleBgView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @end
- @implementation MORoomThemeBaseView
- - (instancetype)init{
- self = [super init];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- #pragma mark - JXCategoryListContentViewDelegate
- - (void)listWillAppear{
-
- }
- - (UIView *)listView{
- return self;
- }
- - (void)setupUI{
- [self addSubview:self.titleBgView];
- [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(5.0);
- make.left.equalTo(self).offset(15.0);
- make.right.equalTo(self).offset(-15.0);
- make.height.equalTo(@32.0);
- }];
- self.titleBgView.layer.cornerRadius = 32.0 / 2.0;
-
- [self addSubview:self.titleCategoryView];
- [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.titleBgView.mas_centerY);
- make.left.equalTo(self).offset(0.0);
- make.right.equalTo(self).offset(-0.0);
- make.height.equalTo(@70.0);
- }];
-
- self.titleCategoryView.titles = @[NSLocalString(@"mimo_create_live_set_background"),NSLocalString(@"mimo_create_live_set_style"),NSLocalString(@"mimo_create_live_set_ripple")];
- CGFloat totalItemWidth = SCREENWIDTH;
- CGFloat cellWidth = totalItemWidth / self.titleCategoryView.titles.count;
- self.titleCategoryView.cellSpacing = 0;
- self.titleCategoryView.cellWidth = cellWidth;
- self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0];
- self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor;
- self.titleCategoryView.titleLabelMaskEnabled = YES;
- self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentFontStr];
- self.titleCategoryView.backgroundColor = [UIColor clearColor];
-
- JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundView.indicatorHeight = 70.0;
- backgroundView.indicatorWidth = 148.0;
- backgroundView.indicatorWidthIncrement = 0;
- backgroundView.indicatorColor = [UIColor clearColor];
- backgroundView.verticalMargin = 4.0;
-
- UIImageView *imgBgView = [[UIImageView alloc] init];
- imgBgView.contentMode = UIViewContentModeScaleToFill;
- [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]];
- [backgroundView addSubview:imgBgView];
- [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backgroundView);
- }];
-
-
- self.titleCategoryView.indicators = @[backgroundView];
-
- [self addSubview:self.listContainerView];
- [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(50.0);
- make.left.right.bottom.equalTo(self);
- }];
- self.titleCategoryView.listContainer = self.listContainerView;
- }
- - (void)setBaseData:(MOVoiceThemeData *)baseData{
- _baseData = baseData;
-
- [self.listContainerView reloadData];
- }
- // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
- MOLogV(@"变换了");
- }
- #pragma mark - JXCategoryListContainerViewDelegate
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
- return self.titleCategoryView.titles.count;
- }
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
-
- WEAKSELF
- if(index == 0){
- MORoomBackgroundSetView *view = [[MORoomBackgroundSetView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 310.0)];
- view.dataArr = [self.baseData.backgrounds copy];
- view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.backgroundSelectBlock ? weakSelf.backgroundSelectBlock(cellModel) : nil;
- };
- return view;
- }
- else{
- MORoomStyleAndRippleSetView *view = [[MORoomStyleAndRippleSetView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 310.0)];
-
- if(index == 1){
- view.dataArr = [self.baseData.microStyleModel copy];
- view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.styleSelectBlock ? weakSelf.styleSelectBlock(cellModel) : nil;
- };
- }
- else{
- view.dataArr = [self.baseData.soundRipple copy];
- view.didSelectCellBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.rippleSelectBlock ? weakSelf.rippleSelectBlock(cellModel) : nil;
- };
- }
-
- return view;
- }
- }
- #pragma Lazy
- - (JXCategoryTitleView *)titleCategoryView{
- if(!_titleCategoryView){
- _titleCategoryView = [[JXCategoryTitleView alloc] init];
- _titleCategoryView.delegate = self;
- }
- return _titleCategoryView;
- }
- - (JXCategoryListContainerView *)listContainerView{
- if(!_listContainerView){
- _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- }
- return _listContainerView;
- }
- - (UIView *)titleBgView{
- if(!_titleBgView){
- _titleBgView = [[UIView alloc] init];
- _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05];
- }
- return _titleBgView;
- }
- @end
|