| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- //
- // MORoomSetBaseView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/8/13.
- //
- #import "MORoomSetBaseView.h"
- @interface MORoomSetBaseView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @property (weak, nonatomic) IBOutlet UIButton *sureBtn;
- @end
- @implementation MORoomSetBaseView
- + (instancetype)moRoomSetBaseView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MORoomSetBaseView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.masksToBounds = YES;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
-
- self.sureBtn.layer.cornerRadius = 25.0;
- self.sureBtn.layer.masksToBounds = YES;
- self.sureBtn.hidden = YES;
-
- NSArray *titleDataArr = @[NSLocalString(@"mimo_create_live_set_left"),NSLocalString(@"mimo_create_live_set_right")];
- [self.bgView addSubview:self.titleCategoryView];
- [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.bgView).offset(0.0);
- make.top.equalTo(self.bgView).offset(15.0);
- make.height.equalTo(@30.0);
- }];
-
- self.titleCategoryView.titles = titleDataArr;
- self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#8E8A99" alpha:1.0];
- self.titleCategoryView.titleSelectedColor = [MOTools colorWithHexString:@"#000000" alpha:1.0];
- self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:16.0 AndFontName:kTypeOneTitleFontStr];
- self.titleCategoryView.titleSelectedFont = [MOTextTools getTheFontWithSize:16.0 AndFontName:kTypeOneTitleFontStr];
- self.titleCategoryView.backgroundColor = [UIColor clearColor];
- self.titleCategoryView.cellSpacing = 15.0;
-
- JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundView.indicatorHeight = 8.5;
- backgroundView.indicatorWidth = 50.0;
- backgroundView.indicatorWidthIncrement = 0;
- backgroundView.indicatorColor = [UIColor clearColor];
- backgroundView.componentPosition = JXCategoryComponentPosition_Bottom;
- backgroundView.verticalMargin = -5.0;
-
- UIImageView *imgBgView = [[UIImageView alloc] init];
- imgBgView.contentMode = UIViewContentModeScaleToFill;
- [imgBgView setImage:[UIImage imageNamed:@"icon_square_line_new"]];
- [backgroundView addSubview:imgBgView];
- [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backgroundView);
- }];
- self.titleCategoryView.indicators = @[backgroundView];
-
- [self.bgView addSubview:self.listContainerView];
- [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleCategoryView.mas_bottom).offset(13.0);
- make.left.right.bottom.equalTo(self.bgView);
- }];
- self.titleCategoryView.listContainer = self.listContainerView;
-
- [self.bgView bringSubviewToFront:self.sureBtn];
-
- [self.sureBtn setFont:[MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr]];
- }
- - (IBAction)closeBtnClick:(id)sender {
- [self dismissRoomSetBaseView];
-
- //如何取消了改变 - 则改为以前的
- self.changeTheSettingInfo ? self.changeTheSettingInfo(self.settingInfo) : nil;
- }
- - (void)setRoomId:(NSString *)roomId{
- _roomId = roomId;
-
- if(roomId.length > 0){
- self.sureBtn.hidden = NO;
- }
- }
- - (IBAction)sureBtnClick:(id)sender {
-
- if(!self.theSettingInfo || self.roomId.length == 0){
- return;
- }
-
- WEAKSELF
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:self.roomId forKey:@"roomId"];
- [dict setObject:@(self.theSettingInfo.linkMicNum) forKey:@"linkMicNum"];
-
- NSDictionary *themeDict = @{@"background":(self.theSettingInfo.backgrounds.id ? self.theSettingInfo.backgrounds.id : @""),
- @"microLayout":(self.theSettingInfo.microLayout.id ? self.theSettingInfo.microLayout.id : @""),
- @"microStyle":(self.theSettingInfo.microStyleModel.id ? self.theSettingInfo.microStyleModel.id : @""),
- @"soundRipple":(self.theSettingInfo.soundRipple.id ? self.theSettingInfo.soundRipple.id : @"")};
-
- [dict setObject:themeDict forKey:@"theme"];
-
- NSDictionary *privilegeDict = @{@"fans":@(self.theSettingInfo.privilegeDefaultModel.fans),
- @"level5":@(self.theSettingInfo.privilegeDefaultModel.level5),
- @"audit":@(self.theSettingInfo.privilegeDefaultModel.audit),
- @"manage":@(self.theSettingInfo.privilegeDefaultModel.manage),
- @"video":@(self.theSettingInfo.privilegeDefaultModel.video),
- @"silence":@(self.theSettingInfo.privilegeDefaultModel.silence),
- @"onlyInvite":@(self.theSettingInfo.privilegeDefaultModel.onlyInvite),
- @"camera":@(self.theSettingInfo.privilegeDefaultModel.camera)};
- [dict setObject:privilegeDict forKey:@"privilege"];
-
- [kHttpManager toChangeTheMultipleDataWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MOSettingInfo *baseModel = [MOSettingInfo modelObjectWithDictionary:data[@"data"]];
- weakSelf.changeTheSettingInfo ? weakSelf.changeTheSettingInfo(baseModel) : nil;
- [weakSelf dismissRoomSetBaseView];
- }
- else{
- MOLogV(@"toChangeTheMultipleDataWithParams 接口报错了");
- kShowNetError(data)
- }
- }];
- }
- // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- - (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){
- MORoomThemeBaseView *view = [[MORoomThemeBaseView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 402.0)];
- view.baseData = self.voiceConfigData;
- view.backgroundSelectBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.backgroundSelectBlock ? weakSelf.backgroundSelectBlock(cellModel) : nil;
-
- if(weakSelf.settingInfo){
- for (MOMicroStyleModel *model in weakSelf.voiceConfigData.backgrounds) {
- if([model.id isEqualToString:cellModel.id]){
- model.isChoose = YES;
- }
- else{
- model.isChoose = NO;
- }
- }
-
- weakSelf.theSettingInfo.backgrounds = [cellModel copy];
- weakSelf.changeTheSettingInfo ? weakSelf.changeTheSettingInfo(weakSelf.theSettingInfo) : nil;
- }
- };
-
- view.styleSelectBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.styleSelectBlock ? weakSelf.styleSelectBlock(cellModel) : nil;
-
- if(weakSelf.settingInfo){
- for (MOMicroStyleModel *model in weakSelf.voiceConfigData.microStyleModel) {
- if([model.id isEqualToString:cellModel.id]){
- model.isChoose = YES;
- }
- else{
- model.isChoose = NO;
- }
- }
-
- weakSelf.theSettingInfo.microStyleModel = [cellModel copy];
- weakSelf.changeTheSettingInfo ? weakSelf.changeTheSettingInfo(weakSelf.theSettingInfo) : nil;
- }
- };
-
- view.rippleSelectBlock = ^(MOMicroStyleModel * _Nonnull cellModel) {
- weakSelf.rippleSelectBlock ? weakSelf.rippleSelectBlock(cellModel) : nil;
-
- if(weakSelf.settingInfo){
- for (MOMicroStyleModel *model in weakSelf.voiceConfigData.soundRipple) {
- if([model.id isEqualToString:cellModel.id]){
- model.isChoose = YES;
- }
- else{
- model.isChoose = NO;
- }
- }
-
- weakSelf.theSettingInfo.soundRipple = [cellModel copy];
- weakSelf.changeTheSettingInfo ? weakSelf.changeTheSettingInfo(weakSelf.theSettingInfo) : nil;
- }
- };
- return view;
- }
- else{
- MORoomSettingsView *view = [[MORoomSettingsView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, 402.0)];
- view.voiceConfigData = self.voiceConfigData;
- view.cancelBtnClickBlock = ^{
- [weakSelf dismissRoomSetBaseView];
- };
-
- view.sureBtnClickBlock = ^(NSArray * _Nonnull dataArr) {
- weakSelf.sureBtnClickBlock ? weakSelf.sureBtnClickBlock(dataArr) : nil;
- [weakSelf dismissRoomSetBaseView];
- };
-
- view.theModelChangeBlock = ^(MOPrivilegeDefaultModel * _Nonnull model) {
- weakSelf.theSettingInfo.privilegeDefaultModel = [model copy];
- };
-
- return view;
- }
- }
- - (void)setSettingInfo:(MOSettingInfo *)settingInfo{
- _settingInfo = settingInfo;
-
- self.theSettingInfo = [settingInfo copy];
- }
- - (void)getTheConfigData{
- WEAKSELF
- [kHttpManager toGetTheLiveRoomCongifThemeWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOVoiceThemeData *baseData = [MOVoiceThemeData modelObjectWithDictionary:data[@"data"]];
-
- for (MOMicroStyleModel * object in baseData.backgrounds) {
- if([object.id isEqualToString:weakSelf.theSettingInfo.backgrounds.id]){
- object.isChoose = YES;
- break;
- }
- }
-
- for (MOMicroStyleModel * object in baseData.microStyleModel) {
- if([object.id isEqualToString:weakSelf.theSettingInfo.microStyleModel.id]){
- object.isChoose = YES;
- break;
- }
- }
-
- for (MOMicroStyleModel * object in baseData.soundRipple) {
- if([object.id isEqualToString:weakSelf.theSettingInfo.soundRipple.id]){
- object.isChoose = YES;
- break;
- }
- }
-
- baseData.privilegeDefaultModel = [weakSelf.theSettingInfo.privilegeDefaultModel copy];
-
- weakSelf.voiceConfigData = baseData;
- [weakSelf.titleCategoryView reloadData];
- }
- else{
- MOLogV(@"toGetTheLiveRoomCongifThemeWithParams 接口报错了");
- kShowNetError(data)
- }
- }];
- }
- - (void)showRoomSetBaseView{
- self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT;
- self.bgView.frame = actionViewRect;
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT - 436.0;
- weakSelf.bgView.frame = actionViewRect;
- }];
- }
- - (void)dismissRoomSetBaseView{
- //完成下移动画
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.y = SCREENHEIGHT;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self removeFromSuperview];
- }];
- }
- #pragma mark - Lazy
- - (JXCategoryTitleView *)titleCategoryView{
- if(!_titleCategoryView){
- _titleCategoryView = [[JXCategoryTitleView alloc] init];
- _titleCategoryView.delegate = self;
- _titleCategoryView.backgroundColor = [UIColor whiteColor];
- }
- return _titleCategoryView;
- }
- - (JXCategoryListContainerView *)listContainerView{
- if(!_listContainerView){
- _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- }
- return _listContainerView;
- }
- @end
|