157 lines
4.9 KiB
Objective-C
Executable File
157 lines
4.9 KiB
Objective-C
Executable File
//
|
|
// RoomSongSettingView.m
|
|
// romantic
|
|
//
|
|
// Created by 八角_马方圆 on 2022/1/6.
|
|
// Copyright © 2022 romantic. All rights reserved.
|
|
//
|
|
|
|
#import "RoomSongSettingView.h"
|
|
#import "RoomHunxiangCell.h"
|
|
|
|
@interface RoomSongSettingView () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
|
|
|
@property (nonatomic, strong) NSArray *dataArray;
|
|
@property (nonatomic, assign) NSInteger selectIndex;
|
|
|
|
@end
|
|
|
|
@implementation RoomSongSettingView
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
|
|
self.backgroundColor = [kBlackColor colorWithAlphaComponent:0.3];
|
|
|
|
WEAK_SELF
|
|
[self.displayMaskView dg_Tapped:^{
|
|
[weakSelf onDismiss];
|
|
}];
|
|
|
|
self.dataArray = @[
|
|
@{@"icon":@"hx_原声", @"title":@"原声"},
|
|
@{@"icon":@"hx_流行", @"title":@"流行"},
|
|
@{@"icon":@"hx_地下室", @"title":@"地下室"},
|
|
@{@"icon":@"hx_摇滚", @"title":@"摇滚"},
|
|
@{@"icon":@"hx_演唱会", @"title":@"演唱会"},
|
|
@{@"icon":@"hx_KTV", @"title":@"KTV"},
|
|
@{@"icon":@"hx_录音棚", @"title":@"录音棚"},
|
|
@{@"icon":@"hx_电音", @"title":@"电音"}];
|
|
|
|
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
|
flowLayout.itemSize = CGSizeMake((APPW-15*2-15*3)/4, 64);
|
|
flowLayout.minimumLineSpacing = 15;
|
|
flowLayout.minimumInteritemSpacing = 15;
|
|
flowLayout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
|
|
|
|
_collectionView.collectionViewLayout = flowLayout;
|
|
_collectionView.delegate = self;
|
|
_collectionView.dataSource = self;
|
|
[_collectionView registerNib:[UINib nibWithNibName:@"RoomHunxiangCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"RoomHunxiangCell"];
|
|
}
|
|
|
|
- (void)onShow {
|
|
[UIApplication.sharedApplication.keyWindow addSubview:self];
|
|
self.whiteView.transform = CGAffineTransformMakeTranslation(0, 240);
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
self.whiteView.transform = CGAffineTransformIdentity;
|
|
}];
|
|
}
|
|
|
|
- (void)setViewModel:(RCMicRoomViewModel *)viewModel {
|
|
_viewModel = viewModel;
|
|
|
|
_erfanSwitch.on = [_viewModel ktv_GetErfan];
|
|
_renshengSlider.value = [_viewModel ktv_GetRenshengVolume];
|
|
_banzouSlider.value = [_viewModel ktv_GetBanzouVolume];
|
|
}
|
|
|
|
- (void)onDismiss {
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
self.whiteView.transform = CGAffineTransformMakeTranslation(0, 240);
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
- (IBAction)onErfan:(id)sender {
|
|
[_viewModel ktv_SetErfan:self.erfanSwitch.isOn];
|
|
}
|
|
|
|
- (IBAction)onRensheng:(id)sender {
|
|
[_viewModel ktv_SetRenshengVolume:self.renshengSlider.value];
|
|
}
|
|
|
|
- (IBAction)onBanzou:(id)sender {
|
|
[_viewModel ktv_SetBanzouVolume:self.banzouSlider.value];
|
|
}
|
|
|
|
- (IBAction)onChangeOrigin:(id)sender {
|
|
[_viewModel ktv_OriginalSingSetting:_originSwitch.isOn];
|
|
}
|
|
|
|
- (IBAction)onPlayOrPause:(id)sender {
|
|
self.playBtn.selected = !self.playBtn.isSelected;
|
|
[_viewModel ktv_StartSing:self.playBtn.isSelected];
|
|
}
|
|
|
|
- (IBAction)onChangeSong:(id)sender {
|
|
[_viewModel ktv_SelfChangeSong];
|
|
}
|
|
|
|
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
|
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
|
{
|
|
return self.dataArray.count;
|
|
}
|
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
RoomHunxiangCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomHunxiangCell" forIndexPath:indexPath];
|
|
NSDictionary *dict = self.dataArray[indexPath.row];
|
|
cell.nameLab.text = dict[@"title"];
|
|
cell.iconImgV.image = ImageNamed(dict[@"icon"]);
|
|
if(self.selectIndex == indexPath.row){
|
|
cell.selImgV.hidden = NO;
|
|
}else{
|
|
cell.selImgV.hidden = YES;
|
|
}
|
|
|
|
return cell;
|
|
}
|
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
self.selectIndex = indexPath.row;
|
|
[self.collectionView reloadData];
|
|
|
|
AgoraAudioEffectPreset effect = AgoraAudioEffectPresetOff;
|
|
if (0 == indexPath.row) {//原声
|
|
effect = AgoraAudioEffectPresetOff;
|
|
}else if (1 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetStyleTransformationPopular;
|
|
}else if (2 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetRoomAcousEthereal;
|
|
}else if (3 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetStyleTransformationRnb;
|
|
}else if (4 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetRoomAcousVocalConcer;
|
|
}else if (5 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetRoomAcousticsKTV;
|
|
}else if (6 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetRoomAcousStudio;
|
|
}else if (7 == indexPath.row) {
|
|
effect = AgoraAudioEffectPresetPitchCorrection;
|
|
}
|
|
|
|
[self.viewModel.agoraKit setAudioEffectPreset:effect];
|
|
}
|
|
|
|
@end
|