Commit 0a2586c5 cgx

修复白噪音功能模块相关bug

1 个父辈 cc16cf97
正在显示 26 个修改的文件 包含 193 行增加95 行删除
...@@ -1011,26 +1011,10 @@ ...@@ -1011,26 +1011,10 @@
D0A72E36282B539200EED7BE /* WhiteNoise */ = { D0A72E36282B539200EED7BE /* WhiteNoise */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D01BD423282BFFB400BA86B3 /* WhiteNoiseRequestModel.h */, D0D20C40282F68C500C9374D /* View */,
D01BD424282BFFB400BA86B3 /* WhiteNoiseRequestModel.m */, D0D20C42282F68EE00C9374D /* Model */,
D01BD426282C003900BA86B3 /* NoiseTypeModel.h */, D0D20C43282F690A00C9374D /* Controller */,
D01BD427282C003900BA86B3 /* NoiseTypeModel.m */, D0D20C41282F68E100C9374D /* RequestModel */,
D01BD429282C03FC00BA86B3 /* NoiseAudioModel.h */,
D01BD42A282C03FC00BA86B3 /* NoiseAudioModel.m */,
D01BD42C282C06D200BA86B3 /* NoiseListController.h */,
D01BD42D282C06D200BA86B3 /* NoiseListController.m */,
D0D00197282C9402004EAFA1 /* NoiseView.h */,
D0D00198282C9402004EAFA1 /* NoiseView.m */,
D0A750FA282DE21D00589B0E /* NoiseAudioCell.h */,
D0A750FB282DE21D00589B0E /* NoiseAudioCell.m */,
D0A75106282E2A8500589B0E /* NoisePlayBar.h */,
D0A75107282E2A8500589B0E /* NoisePlayBar.m */,
D0A7510C282E2FEF00589B0E /* NoisePlayView.h */,
D0A7510D282E2FEF00589B0E /* NoisePlayView.m */,
D0A7510F282E3D0D00589B0E /* NoisePlayCell.h */,
D0A75110282E3D0D00589B0E /* NoisePlayCell.m */,
D0A75113282E499200589B0E /* NoiseDataManager.h */,
D0A75114282E499200589B0E /* NoiseDataManager.m */,
); );
path = WhiteNoise; path = WhiteNoise;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1124,6 +1108,54 @@ ...@@ -1124,6 +1108,54 @@
path = UserLogin; path = UserLogin;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D0D20C40282F68C500C9374D /* View */ = {
isa = PBXGroup;
children = (
D0D00197282C9402004EAFA1 /* NoiseView.h */,
D0D00198282C9402004EAFA1 /* NoiseView.m */,
D0A750FA282DE21D00589B0E /* NoiseAudioCell.h */,
D0A750FB282DE21D00589B0E /* NoiseAudioCell.m */,
D0A75106282E2A8500589B0E /* NoisePlayBar.h */,
D0A75107282E2A8500589B0E /* NoisePlayBar.m */,
D0A7510C282E2FEF00589B0E /* NoisePlayView.h */,
D0A7510D282E2FEF00589B0E /* NoisePlayView.m */,
D0A7510F282E3D0D00589B0E /* NoisePlayCell.h */,
D0A75110282E3D0D00589B0E /* NoisePlayCell.m */,
);
path = View;
sourceTree = "<group>";
};
D0D20C41282F68E100C9374D /* RequestModel */ = {
isa = PBXGroup;
children = (
D01BD423282BFFB400BA86B3 /* WhiteNoiseRequestModel.h */,
D01BD424282BFFB400BA86B3 /* WhiteNoiseRequestModel.m */,
);
path = RequestModel;
sourceTree = "<group>";
};
D0D20C42282F68EE00C9374D /* Model */ = {
isa = PBXGroup;
children = (
D01BD426282C003900BA86B3 /* NoiseTypeModel.h */,
D01BD427282C003900BA86B3 /* NoiseTypeModel.m */,
D01BD429282C03FC00BA86B3 /* NoiseAudioModel.h */,
D01BD42A282C03FC00BA86B3 /* NoiseAudioModel.m */,
D0A75113282E499200589B0E /* NoiseDataManager.h */,
D0A75114282E499200589B0E /* NoiseDataManager.m */,
);
path = Model;
sourceTree = "<group>";
};
D0D20C43282F690A00C9374D /* Controller */ = {
isa = PBXGroup;
children = (
D01BD42C282C06D200BA86B3 /* NoiseListController.h */,
D01BD42D282C06D200BA86B3 /* NoiseListController.m */,
);
path = Controller;
sourceTree = "<group>";
};
D0D3826428124E34005BB219 /* Feedback */ = { D0D3826428124E34005BB219 /* Feedback */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1239,12 +1271,12 @@ ...@@ -1239,12 +1271,12 @@
D0F808FA280420DE0097899F /* Model */ = { D0F808FA280420DE0097899F /* Model */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D01814EC28002DC700583D4E /* HeaderDataModel.h */,
D01814ED28002DC700583D4E /* HeaderDataModel.m */,
D0DF90AC2814390000FC0F64 /* BannerModel.h */, D0DF90AC2814390000FC0F64 /* BannerModel.h */,
D0DF90AD2814390000FC0F64 /* BannerModel.m */, D0DF90AD2814390000FC0F64 /* BannerModel.m */,
D0DB33A628224D5100E15914 /* PromotionModel.h */, D0DB33A628224D5100E15914 /* PromotionModel.h */,
D0DB33A728224D5100E15914 /* PromotionModel.m */, D0DB33A728224D5100E15914 /* PromotionModel.m */,
D01814EC28002DC700583D4E /* HeaderDataModel.h */,
D01814ED28002DC700583D4E /* HeaderDataModel.m */,
); );
path = Model; path = Model;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1870,7 +1902,7 @@ ...@@ -1870,7 +1902,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = SPH85C3TWU; DEVELOPMENT_TEAM = SPH85C3TWU;
EXCLUDED_ARCHS = ""; EXCLUDED_ARCHS = "";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
...@@ -1908,7 +1940,7 @@ ...@@ -1908,7 +1940,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ",
); );
MARKETING_VERSION = 1.0.3; MARKETING_VERSION = 1.0.4;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
...@@ -1936,7 +1968,7 @@ ...@@ -1936,7 +1968,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -1973,7 +2005,7 @@ ...@@ -1973,7 +2005,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ",
); );
MARKETING_VERSION = 1.0.3; MARKETING_VERSION = 1.0.4;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
...@@ -2063,7 +2095,7 @@ ...@@ -2063,7 +2095,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 4NDZ6UX8PW; DEVELOPMENT_TEAM = 4NDZ6UX8PW;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -2100,7 +2132,7 @@ ...@@ -2100,7 +2132,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/SocialLibraries/QQ",
); );
MARKETING_VERSION = 1.0.3; MARKETING_VERSION = 1.0.4;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
......
...@@ -38,6 +38,10 @@ FOUNDATION_EXTERN NSString * const WXLoginAuthNoti; ...@@ -38,6 +38,10 @@ FOUNDATION_EXTERN NSString * const WXLoginAuthNoti;
FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti; FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti;
// 刷新主页通知 // 刷新主页通知
FOUNDATION_EXTERN NSString * const NeedUpdateHomePage; FOUNDATION_EXTERN NSString * const NeedUpdateHomePage;
// 首页白噪音播放列表变化通知
FOUNDATION_EXTERN NSString * const NoisePlaylistHasChange;
// 首页白噪音定时器被点击通知
FOUNDATION_EXTERN NSString * const NoiseTimingDidClick;
// 用户基础信息 // 用户基础信息
FOUNDATION_EXTERN NSString * const UserBasicInfo; FOUNDATION_EXTERN NSString * const UserBasicInfo;
......
...@@ -27,6 +27,8 @@ NSString * const ExpireTime2 = @"06:00:00"; ...@@ -27,6 +27,8 @@ NSString * const ExpireTime2 = @"06:00:00";
NSString * const WXLoginAuthNoti = @"wxLoginAuthNoti"; NSString * const WXLoginAuthNoti = @"wxLoginAuthNoti";
NSString * const HasUpdateUserDataNoti = @"hasUpdateUserDataNoti"; NSString * const HasUpdateUserDataNoti = @"hasUpdateUserDataNoti";
NSString * const NeedUpdateHomePage = @"NeedUpdateHomePageNoti"; NSString * const NeedUpdateHomePage = @"NeedUpdateHomePageNoti";
NSString * const NoisePlaylistHasChange = @"NoisePlaylistHasChangeNoti";
NSString * const NoiseTimingDidClick = @"NoiseTimingDidClickNoti";
NSString * const UserBasicInfo = @"UserBasicInfo"; NSString * const UserBasicInfo = @"UserBasicInfo";
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "SafeSleepRequestModel.h" #import "SafeSleepRequestModel.h"
#import "WhiteNoiseRequestModel.h" #import "WhiteNoiseRequestModel.h"
#import "NoisePlayBar.h" #import "NoisePlayBar.h"
#import "NoiseDataManager.h"
@interface HomeViewController () @interface HomeViewController ()
@property (nonatomic, strong) DSHomeView *homeTV; @property (nonatomic, strong) DSHomeView *homeTV;
...@@ -58,6 +59,12 @@ ...@@ -58,6 +59,12 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil];
} }
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[NoiseDataManager sharedNoiseDataManager] stopNoiseAudio];
}
- (void)dealloc { - (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil];
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#pragma mark - Actions #pragma mark - Actions
- (void)timerSetting:(UIButton *)sender { - (void)timerSetting:(UIButton *)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"timingDidClickNoti" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:NoiseTimingDidClick object:nil];
} }
#pragma mark - lazy #pragma mark - lazy
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@interface NoiseListController () <UICollectionViewDelegate, UICollectionViewDataSource> @interface NoiseListController () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *noiseAudioView; @property (nonatomic, strong) UICollectionView *noiseAudioView;
@property (nonatomic, strong) NSArray *noiseAudioArr; @property (nonatomic, strong) NSArray *noiseAudioArr;
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
@end @end
@implementation NoiseListController { @implementation NoiseListController {
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID { - (instancetype)initWithNoiseTypeID:(NSInteger)typeID {
if (self = [super init]) { if (self = [super init]) {
// 白噪音类型id
_typeID = typeID; _typeID = typeID;
} }
return self; return self;
...@@ -32,10 +34,23 @@ ...@@ -32,10 +34,23 @@
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view addSubview:self.noiseAudioView]; [self.view addSubview:self.noiseAudioView];
[self queryRelaxWhiteNoiseAudiosRequest];
}
- (void)queryRelaxWhiteNoiseAudiosRequest {
[WhiteNoiseRequestModel queryRelaxWhiteNoiseAudiosWithTypeID:_typeID completion:^(WhiteNoiseRequestModel * _Nonnull requestModel) { [WhiteNoiseRequestModel queryRelaxWhiteNoiseAudiosWithTypeID:_typeID completion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
self.exceptionView.hidden = YES;
self.noiseAudioArr = requestModel.noiseAudioArr; self.noiseAudioArr = requestModel.noiseAudioArr;
[self.noiseAudioView reloadData]; [self.noiseAudioView reloadData];
// 重置
NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList;
for (NoiseAudioCell *audioCell in playList) {
[audioCell.model.audioStream stop];
}
[NoiseDataManager sharedNoiseDataManager].playList = @[];
} else {
self.exceptionView.hidden = NO;
} }
}]; }];
} }
...@@ -47,14 +62,28 @@ ...@@ -47,14 +62,28 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath]; NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath];
cell.model = self.noiseAudioArr[indexPath.row]; NoiseAudioModel *model = self.noiseAudioArr[indexPath.row];
cell.model = model;
// 处理数据刷新后之前已经被选中的cell需要恢复被选中状态并配置播放器(只能根据音频id判断),暂不处理
// NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList;
// for (__strong NoiseAudioCell *oldCell in playList) {
// if (cell.model.noise_audio_id == oldCell.model.noise_audio_id) {
// cell.audioIV.selected = YES;
// cell.model = oldCell.model;
// // 将oldCell替换成新的cell
// oldCell = cell;
// // 替换model
// model = oldCell.model;
// }
// }
return cell; return cell;
} }
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NoiseAudioModel *model = [self.noiseAudioArr objectAtIndex:indexPath.row]; NoiseAudioModel *model = [self.noiseAudioArr objectAtIndex:indexPath.row];
NoiseAudioCell *cell = (NoiseAudioCell *)[collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]]; NoiseAudioCell *cell = (NoiseAudioCell *)[collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]];
cell.model = model;
NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList; NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList;
NSMutableArray *selectedDataArr = [NSMutableArray arrayWithArray:playList]; NSMutableArray *selectedDataArr = [NSMutableArray arrayWithArray:playList];
...@@ -70,14 +99,13 @@ ...@@ -70,14 +99,13 @@
FSAudioStream *audioStream = [[FSAudioStream alloc] init]; FSAudioStream *audioStream = [[FSAudioStream alloc] init];
audioStream.strictContentTypeChecking = NO; audioStream.strictContentTypeChecking = NO;
audioStream.defaultContentType = @"audio/mpeg"; audioStream.defaultContentType = @"audio/mpeg";
audioStream.volume = .5;
model.audioStream = audioStream; model.audioStream = audioStream;
[selectedDataArr addObject:cell]; [selectedDataArr addObject:cell];
playList = [selectedDataArr copy]; playList = [selectedDataArr copy];
} else { } else {
// 白噪音已经选择了则从播放列表移除 // 白噪音已经选择了则从播放列表移除
if (model.audioStream) { if (model.audioStream) { [model.audioStream stop]; }
[model.audioStream stop];
}
[selectedDataArr removeObject:cell]; [selectedDataArr removeObject:cell];
} }
cell.audioIV.selected = !cell.audioIV.selected; cell.audioIV.selected = !cell.audioIV.selected;
...@@ -109,4 +137,15 @@ ...@@ -109,4 +137,15 @@
return _noiseAudioArr; return _noiseAudioArr;
} }
- (ExceptionDefaultView *)exceptionView {
if (!_exceptionView) {
WS(weakSelf);
_exceptionView = [[ExceptionDefaultView alloc] initWithType:ExceptionTypeNet block:^{
weakSelf.exceptionView.hidden = YES;
[weakSelf queryRelaxWhiteNoiseAudiosRequest];
} superView:self.noiseAudioView];
}
return _exceptionView;
}
@end @end
...@@ -16,8 +16,10 @@ SingletonH(NoiseDataManager) ...@@ -16,8 +16,10 @@ SingletonH(NoiseDataManager)
/// 选中的白噪音数据 /// 选中的白噪音数据
@property (nonatomic, strong) NSArray *playList; @property (nonatomic, strong) NSArray *playList;
/// 用于存储播放流对象
@property (nonatomic, strong) NSArray *audioStreamArr; /// 停止白噪音
- (void)stopNoiseAudio;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
#import "NoiseDataManager.h" #import "NoiseDataManager.h"
#import "NoiseAudioCell.h"
@implementation NoiseDataManager @implementation NoiseDataManager
...@@ -14,11 +15,16 @@ SingletonM(NoiseDataManager) ...@@ -14,11 +15,16 @@ SingletonM(NoiseDataManager)
- (void)setPlayList:(NSArray *)playList { - (void)setPlayList:(NSArray *)playList {
_playList = playList; _playList = playList;
[[NSNotificationCenter defaultCenter] postNotificationName:@"updatePlistNoti" object:nil userInfo:@{@"playList":self.playList}]; [[NSNotificationCenter defaultCenter] postNotificationName:NoisePlaylistHasChange object:nil userInfo:@{@"playList":self.playList}];
} }
- (void)setAudioStreamArr:(NSArray *)audioStreamArr { - (void)stopNoiseAudio {
_audioStreamArr = audioStreamArr; if (self.playList && self.playList.count) {
for (int i = 0; i < self.playList.count; i++) {
NoiseAudioCell *audioCell = self.playList[i];
[audioCell.model.audioStream stop];
}
}
} }
@end @end
...@@ -22,11 +22,6 @@ ...@@ -22,11 +22,6 @@
NSMutableArray *tmpArr = [NSMutableArray array]; NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) { for (int i = 0; i < resultArr.count; i++) {
NoiseTypeModel *noiseTypeModel = [NoiseTypeModel yy_modelWithJSON:resultArr[i]]; NoiseTypeModel *noiseTypeModel = [NoiseTypeModel yy_modelWithJSON:resultArr[i]];
// if (i == 0) {
// noiseTypeModel.is_lock = 0;
// } else {
// noiseTypeModel.is_lock = ![LoginUtils getUserLoginData];
// }
[tmpArr addObject:noiseTypeModel]; [tmpArr addObject:noiseTypeModel];
} }
requestModel.noiseTypeArr = [tmpArr copy]; requestModel.noiseTypeArr = [tmpArr copy];
...@@ -42,7 +37,7 @@ ...@@ -42,7 +37,7 @@
WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init]; WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init];
NSString *api = @"query_relax_white_noise_audios_for_IOS"; NSString *api = @"query_relax_white_noise_audios_for_IOS";
NSString *argStr = [NSString stringWithFormat:@"query{%@(type_id:%ld)}", api, typeID]; NSString *argStr = [NSString stringWithFormat:@"query{%@(type_id:%ld)}", api, typeID];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) { return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"睡眠-放松训练-白噪声列表接口apiDic:%@", apiDic); DSLog(@"睡眠-放松训练-白噪声列表接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess; requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"]; NSArray *resultArr = apiDic[@"result"];
......
...@@ -65,10 +65,10 @@ ...@@ -65,10 +65,10 @@
self.minuteIndex = 0; self.minuteIndex = 0;
self.countTime = 60; self.countTime = 60;
// 添加对单例对象播放列表变化通知 // 添加对单例对象白噪音播放列表变化通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlist:) name:@"updatePlistNoti" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlist:) name:NoisePlaylistHasChange object:nil];
// 监听定时按钮被点击事件通知 // 监听定时按钮被点击事件通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openTimingView) name:@"timingDidClickNoti" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openTimingView) name:NoiseTimingDidClick object:nil];
} }
return self; return self;
} }
...@@ -84,6 +84,9 @@ ...@@ -84,6 +84,9 @@
__weak FSAudioStream *audioStream = audioCell.model.audioStream; __weak FSAudioStream *audioStream = audioCell.model.audioStream;
audioStream.onStateChange = ^(FSAudioStreamState state) { audioStream.onStateChange = ^(FSAudioStreamState state) {
weakSelf.playBtn.selected = state == kFsAudioStreamPlaying; weakSelf.playBtn.selected = state == kFsAudioStreamPlaying;
if (self->_noisePlayView) {
weakSelf.noisePlayView.selected = weakSelf.playBtn.selected;
}
// 如果播放完成则重复播放 // 如果播放完成则重复播放
if (state == kFsAudioStreamPlaybackCompleted) { if (state == kFsAudioStreamPlaybackCompleted) {
[audioStream play]; [audioStream play];
...@@ -97,8 +100,8 @@ ...@@ -97,8 +100,8 @@
} }
- (void)dealloc { - (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"updatePlistNoti" object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NoisePlaylistHasChange object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"timingDidClickNoti" object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NoiseTimingDidClick object:nil];
[_timer invalidate]; [_timer invalidate];
_timer = nil; _timer = nil;
...@@ -111,7 +114,7 @@ ...@@ -111,7 +114,7 @@
} }
- (void)showAudioListView { - (void)showAudioListView {
[self.noisePlayView show]; [self.noisePlayView showNoisePlayViewWith:self.playBtn.selected];
} }
- (void)playNoiseAudio:(UIButton *)sender { - (void)playNoiseAudio:(UIButton *)sender {
......
...@@ -20,13 +20,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -20,13 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@interface NoisePlayCell : UITableViewCell @interface NoisePlayCell : UITableViewCell
@property (nonatomic, weak) id<NoisePlayCellDelegate> delegate; @property (nonatomic, weak) id<NoisePlayCellDelegate> delegate;
@property (nonatomic, strong) NoiseAudioModel *model; @property (nonatomic, strong) NoiseAudioModel *model;
@property (nonatomic, strong) NSIndexPath *indexPath; @property (nonatomic, strong) NSIndexPath *indexPath;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.dk_backgroundColorPicker = DKColorPickerWithColors(BGColor, AlertDarkColor, DSWhite); self.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
self.selectionStyle = UITableViewCellSelectionStyleNone; self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.bgView]; [self.contentView addSubview:self.bgView];
......
...@@ -11,7 +11,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,7 +11,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface NoisePlayView : UIView @interface NoisePlayView : UIView
- (void)show; /// 显示白噪音列表页面
/// @param selected 按钮状态
- (void)showNoisePlayViewWith:(BOOL)selected;
/// 设置一键开启、一键暂停按钮状态
@property (nonatomic, assign) BOOL selected;
@end @end
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
[self addSubview:self.headView]; [self addSubview:self.headView];
[self addSubview:self.playListView]; [self addSubview:self.playListView];
[self addSubview:self.oneClickBtn]; [self addSubview:self.oneClickBtn];
[self.oneClickBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.oneClickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self); make.centerX.equalTo(self);
make.size.mas_equalTo(CGSizeMake(155, 40)); make.size.mas_equalTo(CGSizeMake(155, 40));
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
return self; return self;
} }
- (void)show { - (void)showNoisePlayViewWith:(BOOL)selected {
[DSKeyWindow addSubview:self]; [DSKeyWindow addSubview:self];
NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList; NSArray *playList = [NoiseDataManager sharedNoiseDataManager].playList;
...@@ -42,15 +43,23 @@ ...@@ -42,15 +43,23 @@
self.audioArr = playList; self.audioArr = playList;
[self.playListView reloadData]; [self.playListView reloadData];
} }
self.oneClickBtn.selected = selected;
}
- (void)setSelected:(BOOL)selected {
_selected = selected;
self.oneClickBtn.selected = selected;
} }
#pragma mark - Actions
- (void)oneClickAction:(UIButton *)sender { - (void)oneClickAction:(UIButton *)sender {
for (NoiseAudioCell *audioCell in self.audioArr) { for (NoiseAudioCell *audioCell in self.audioArr) {
FSAudioStream *audioStream = audioCell.model.audioStream; FSAudioStream *audioStream = audioCell.model.audioStream;
if (sender.selected) { if (sender.selected) {
[audioStream pause]; [audioStream stop];
} else { } else {
[audioStream pause]; [audioStream play];
} }
} }
sender.selected = !sender.selected; sender.selected = !sender.selected;
...@@ -174,6 +183,7 @@ ...@@ -174,6 +183,7 @@
_playListView.bounces = NO; _playListView.bounces = NO;
_playListView.delegate = self; _playListView.delegate = self;
_playListView.dataSource = self; _playListView.dataSource = self;
_playListView.separatorStyle = UITableViewCellSeparatorStyleNone;
_playListView.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG); _playListView.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
} }
return _playListView; return _playListView;
...@@ -181,11 +191,11 @@ ...@@ -181,11 +191,11 @@
- (UIButton *)oneClickBtn { - (UIButton *)oneClickBtn {
if (!_oneClickBtn) { if (!_oneClickBtn) {
_oneClickBtn = [UIButton btnWithTitle:@"一键暂停" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor]; _oneClickBtn = [UIButton btnWithTitle:@"" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
[_oneClickBtn addTarget:self action:@selector(oneClickAction:) forControlEvents:UIControlEventTouchUpInside]; [_oneClickBtn addTarget:self action:@selector(oneClickAction:) forControlEvents:UIControlEventTouchUpInside];
[_oneClickBtn cornerRadius:22]; [_oneClickBtn cornerRadius:22];
[_oneClickBtn setTitle:@"一键暂停" forState:UIControlStateNormal]; [_oneClickBtn setTitle:@"一键开启" forState:UIControlStateNormal];
[_oneClickBtn setTitle:@"一键开启" forState:UIControlStateSelected]; [_oneClickBtn setTitle:@"一键暂停" forState:UIControlStateSelected];
} }
return _oneClickBtn; return _oneClickBtn;
} }
......
...@@ -211,7 +211,7 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -211,7 +211,7 @@ static NSString *mainCell = @"inxx_mainCell";
scrollViewPage.showsVerticalScrollIndicator = NO; scrollViewPage.showsVerticalScrollIndicator = NO;
scrollViewPage.showsHorizontalScrollIndicator = NO; scrollViewPage.showsHorizontalScrollIndicator = NO;
scrollViewPage.delegate = self; scrollViewPage.delegate = self;
scrollViewPage.backgroundColor = _pageBarBgColor; scrollViewPage.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self addSubview:scrollViewPage]; [self addSubview:scrollViewPage];
CGFloat contentWidth = 0; CGFloat contentWidth = 0;
...@@ -269,12 +269,12 @@ CGRect childFrame; ...@@ -269,12 +269,12 @@ CGRect childFrame;
[self addSubview:collection]; [self addSubview:collection];
[self bringSubviewToFront:self.collectionMain]; [self bringSubviewToFront:self.collectionMain];
// childFrame = frame; // childFrame = frame;
// for (UIViewController *childVc in self.controllersClass) { // for (UIViewController *childVc in self.controllersClass) {
// //子控制器的frame.origin.y肯定要从其自己的0开始 // //子控制器的frame.origin.y肯定要从其自己的0开始
// childFrame.origin.y = 0; // childFrame.origin.y = 0;
// childVc.view.frame = childFrame; // childVc.view.frame = childFrame;
// } // }
} }
- (void)addPageBottomLine { - (void)addPageBottomLine {
...@@ -421,7 +421,7 @@ CGRect childFrame; ...@@ -421,7 +421,7 @@ CGRect childFrame;
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:mainCell forIndexPath:indexPath]; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:mainCell forIndexPath:indexPath];
NoiseListController *childVC = self.controllersClass[indexPath.row]; NoiseListController *childVC = self.controllersClass[indexPath.row];
childVC.view.frame = cell.contentView.bounds; childVC.view.frame = cell.contentView.bounds;
[cell.contentView addSubview:childVC.view]; [cell.contentView addSubview:childVC.view];
return cell; return cell;
} }
...@@ -594,7 +594,7 @@ static float oldOffsetX; ...@@ -594,7 +594,7 @@ static float oldOffsetX;
newCell = _pageCells[pageIndex+1]; newCell = _pageCells[pageIndex+1];
} }
//滑动过程中字体实时改变的大小 // 滑动过程中字体实时改变的大小
if (_pageTitleFontChangeType == PageTitleFontChangeTypeScrolling && _titleSelectedFont.pointSize != _titleFont.pointSize) { if (_pageTitleFontChangeType == PageTitleFontChangeTypeScrolling && _titleSelectedFont.pointSize != _titleFont.pointSize) {
CGFloat fontRuntimeDifferenceSize = xInScreen/kScreenWidth*(_titleSelectedFont.pointSize-_titleFont.pointSize); CGFloat fontRuntimeDifferenceSize = xInScreen/kScreenWidth*(_titleSelectedFont.pointSize-_titleFont.pointSize);
...@@ -625,23 +625,23 @@ static float oldOffsetX; ...@@ -625,23 +625,23 @@ static float oldOffsetX;
} }
// if (_pageTitleColorChangeType == PageTitleColorChangeTypeScrolling) { // if (_pageTitleColorChangeType == PageTitleColorChangeTypeScrolling) {
// NSArray *rgba0 = [self getRGBValueFromColor:_titleColor]; // NSArray *rgba0 = [self getRGBValueFromColor:_titleColor];
// NSArray *rgba1 = [self getRGBValueFromColor:_titleSelectedColor]; // NSArray *rgba1 = [self getRGBValueFromColor:_titleSelectedColor];
// CGFloat diffR = xInScreen / kScreenWidth * ([rgba1[0] floatValue] - [rgba0[0] floatValue]); // CGFloat diffR = xInScreen / kScreenWidth * ([rgba1[0] floatValue] - [rgba0[0] floatValue]);
// CGFloat diffG = xInScreen / kScreenWidth * ([rgba1[1] floatValue] - [rgba0[1] floatValue]); // CGFloat diffG = xInScreen / kScreenWidth * ([rgba1[1] floatValue] - [rgba0[1] floatValue]);
// CGFloat diffB = xInScreen / kScreenWidth * ([rgba1[2] floatValue] - [rgba0[2] floatValue]); // CGFloat diffB = xInScreen / kScreenWidth * ([rgba1[2] floatValue] - [rgba0[2] floatValue]);
// CGFloat runingRed0 = [rgba0[0] floatValue] + diffR; // CGFloat runingRed0 = [rgba0[0] floatValue] + diffR;
// CGFloat runingGreen0 = [rgba0[1] floatValue] + diffG; // CGFloat runingGreen0 = [rgba0[1] floatValue] + diffG;
// CGFloat runingBlue0 = [rgba0[2] floatValue] + diffB; // CGFloat runingBlue0 = [rgba0[2] floatValue] + diffB;
// CGFloat runingred1 = [rgba1[0] floatValue] - diffR; // CGFloat runingred1 = [rgba1[0] floatValue] - diffR;
// CGFloat runinGreen1 = [rgba1[1] floatValue] - diffG; // CGFloat runinGreen1 = [rgba1[1] floatValue] - diffG;
// CGFloat runingBlue1 = [rgba1[2] floatValue] - diffB; // CGFloat runingBlue1 = [rgba1[2] floatValue] - diffB;
// UIColor *runtimeColor0 = [UIColor colorWithRed:runingRed0 green:runingGreen0 blue:runingBlue0 alpha:1.0]; // UIColor *runtimeColor0 = [UIColor colorWithRed:runingRed0 green:runingGreen0 blue:runingBlue0 alpha:1.0];
// UIColor *runtimeColor1 = [UIColor colorWithRed:runingred1 green:runinGreen1 blue:runingBlue1 alpha:1.0]; // UIColor *runtimeColor1 = [UIColor colorWithRed:runingred1 green:runinGreen1 blue:runingBlue1 alpha:1.0];
// oldCell.titleLabel.textColor = runtimeColor1; // oldCell.titleLabel.textColor = runtimeColor1;
// newCell.titleLabel.textColor = runtimeColor0; // newCell.titleLabel.textColor = runtimeColor0;
// } // }
} }
/** 系统API获取UIColor的RGBA值 */ /** 系统API获取UIColor的RGBA值 */
...@@ -658,8 +658,9 @@ static float oldOffsetX; ...@@ -658,8 +658,9 @@ static float oldOffsetX;
if (scrollView == _collectionMain) { if (scrollView == _collectionMain) {
CGFloat x = scrollView.contentOffset.x ; CGFloat x = scrollView.contentOffset.x;
int index = (x + kScreenWidth*0.5) / kScreenWidth; //滑动切换基准选择: kScreenWidth*0.5(半屏) //滑动切换基准选择: kScreenWidth*0.5(半屏)
int index = (x + kScreenWidth*0.5) / kScreenWidth;
// ScrollViewPage 处理偏移:setContentOffset // ScrollViewPage 处理偏移:setContentOffset
[self updateCurrentScrollViewPageContentOffsetByIndex:index]; [self updateCurrentScrollViewPageContentOffsetByIndex:index];
...@@ -681,9 +682,7 @@ static float oldOffsetX; ...@@ -681,9 +682,7 @@ static float oldOffsetX;
} }
}]; }];
} }
} }
} }
/// 更新当前使用的分页ScrollView偏移量,复现UICollectionView滑动到view边缘处理的大致流程 /// 更新当前使用的分页ScrollView偏移量,复现UICollectionView滑动到view边缘处理的大致流程
......
...@@ -9,7 +9,5 @@ ...@@ -9,7 +9,5 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate> @interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow * window; @property (strong, nonatomic) UIWindow * window;
/// 选中的白噪音数据
@property (nonatomic, strong) NSArray *playList;
@end @end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!