Commit 848187e6 cgx

睡前准备引入白噪音模块

1 个父辈 59be051d
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
D01DC957287023C20035B78B /* RankHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01DC956287023C20035B78B /* RankHeadView.m */; }; D01DC957287023C20035B78B /* RankHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01DC956287023C20035B78B /* RankHeadView.m */; };
D01DC95A28702F270035B78B /* RankViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D01DC95928702F260035B78B /* RankViewCell.m */; }; D01DC95A28702F270035B78B /* RankViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D01DC95928702F260035B78B /* RankViewCell.m */; };
D020CE1F280D951400E7E82F /* invite_friend.webp in Resources */ = {isa = PBXBuildFile; fileRef = D020CE1E280D915D00E7E82F /* invite_friend.webp */; }; D020CE1F280D951400E7E82F /* invite_friend.webp in Resources */ = {isa = PBXBuildFile; fileRef = D020CE1E280D915D00E7E82F /* invite_friend.webp */; };
D024CE89287D59FF00FB4320 /* SRMusicView.m in Sources */ = {isa = PBXBuildFile; fileRef = D024CE88287D59FF00FB4320 /* SRMusicView.m */; };
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; }; D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; }; D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; }; D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; };
...@@ -320,6 +321,8 @@ ...@@ -320,6 +321,8 @@
D01DC95828702F260035B78B /* RankViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RankViewCell.h; sourceTree = "<group>"; }; D01DC95828702F260035B78B /* RankViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RankViewCell.h; sourceTree = "<group>"; };
D01DC95928702F260035B78B /* RankViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RankViewCell.m; sourceTree = "<group>"; }; D01DC95928702F260035B78B /* RankViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RankViewCell.m; sourceTree = "<group>"; };
D020CE1E280D915D00E7E82F /* invite_friend.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = invite_friend.webp; sourceTree = "<group>"; }; D020CE1E280D915D00E7E82F /* invite_friend.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = invite_friend.webp; sourceTree = "<group>"; };
D024CE87287D59FF00FB4320 /* SRMusicView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SRMusicView.h; sourceTree = "<group>"; };
D024CE88287D59FF00FB4320 /* SRMusicView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SRMusicView.m; sourceTree = "<group>"; };
D027EE2427FB3DC0004BBA61 /* NetLoadingStateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetLoadingStateView.h; sourceTree = "<group>"; }; D027EE2427FB3DC0004BBA61 /* NetLoadingStateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetLoadingStateView.h; sourceTree = "<group>"; };
D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NetLoadingStateView.m; sourceTree = "<group>"; }; D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NetLoadingStateView.m; sourceTree = "<group>"; };
D027EE2727FB51D0004BBA61 /* DSGifHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSGifHeader.h; sourceTree = "<group>"; }; D027EE2727FB51D0004BBA61 /* DSGifHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSGifHeader.h; sourceTree = "<group>"; };
...@@ -1021,6 +1024,8 @@ ...@@ -1021,6 +1024,8 @@
D02D082C287BD05D005C3A00 /* ReadyListController.m */, D02D082C287BD05D005C3A00 /* ReadyListController.m */,
D02D0828287BCEF3005C3A00 /* SRTipsView.h */, D02D0828287BCEF3005C3A00 /* SRTipsView.h */,
D02D0829287BCEF3005C3A00 /* SRTipsView.m */, D02D0829287BCEF3005C3A00 /* SRTipsView.m */,
D024CE87287D59FF00FB4320 /* SRMusicView.h */,
D024CE88287D59FF00FB4320 /* SRMusicView.m */,
); );
path = SleepReady; path = SleepReady;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2282,6 +2287,7 @@ ...@@ -2282,6 +2287,7 @@
D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */, D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */,
D0498874286E95F2000ACF55 /* DsTaskManager.m in Sources */, D0498874286E95F2000ACF55 /* DsTaskManager.m in Sources */,
D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */, D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */,
D024CE89287D59FF00FB4320 /* SRMusicView.m in Sources */,
D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */, D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */,
D0930F122801124E006B497A /* BaseNaviController.m in Sources */, D0930F122801124E006B497A /* BaseNaviController.m in Sources */,
D0878F4F280C087E005F1B7F /* LoginController.m in Sources */, D0878F4F280C087E005F1B7F /* LoginController.m in Sources */,
......
...@@ -12,6 +12,7 @@ typedef NS_ENUM(NSInteger, MaskType) { ...@@ -12,6 +12,7 @@ typedef NS_ENUM(NSInteger, MaskType) {
MaskTypeNormal, // 正常,不带圆角 MaskTypeNormal, // 正常,不带圆角
MaskTypeAllCorner, // 四周带圆角 MaskTypeAllCorner, // 四周带圆角
MaskTypeCornerBottom, // 底部带圆角 MaskTypeCornerBottom, // 底部带圆角
MaskTypeCornerTop, // 顶部带圆角
}; };
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
......
...@@ -122,6 +122,8 @@ ...@@ -122,6 +122,8 @@
UIRectCorner rectCorner = UIRectCornerAllCorners; UIRectCorner rectCorner = UIRectCornerAllCorners;
if (type == MaskTypeCornerBottom) { if (type == MaskTypeCornerBottom) {
rectCorner = UIRectCornerBottomLeft | UIRectCornerBottomRight; rectCorner = UIRectCornerBottomLeft | UIRectCornerBottomRight;
} else if (type == MaskTypeCornerTop) {
rectCorner = UIRectCornerTopLeft | UIRectCornerTopRight;
} }
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:maskView.bounds byRoundingCorners:rectCorner cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:maskView.bounds byRoundingCorners:rectCorner cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
......
//
// SRMusicView.h
// DreamSleep
//
// Created by peter on 2022/7/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 睡前准备白噪音视图
@interface SRMusicView : UIView
- (void)refreshNoiseTypeData:(NSArray *)data;
@end
NS_ASSUME_NONNULL_END
//
// SRMusicView.m
// DreamSleep
//
// Created by peter on 2022/7/12.
//
#import "SRMusicView.h"
#import "NoiseView.h"
#import "NoisePlayBar.h"
#import "GoodSleepHeadView.h"
@interface SRMusicView () <GoodSleepHeadViewDelegate>
@property (nonatomic, strong) GoodSleepHeadView *goodSleepHeadView;
@property (nonatomic, strong) NoiseView *noiseView;
@property (nonatomic, strong) NoisePlayBar *noisePlayBar;
@end
@implementation SRMusicView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setCornerRadiusRect:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadius:24.0];
[self addSubview:self.goodSleepHeadView];
[self addSubview:self.noiseView];
[self addSubview:self.noisePlayBar];
[self.noisePlayBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.bottom.equalTo(self).offset(-15);
make.height.equalTo(@50);
}];
}
return self;
}
- (void)refreshNoiseTypeData:(NSArray *)data {
[self.noiseView refreshNoiseTypeData:data];
}
#pragma mark - GoodSleepHeadViewDelegate
- (void)closeAction {
[UIView animateWithDuration:.3 animations:^{
self.y = kScreenHeight;
}];
}
#pragma mark - lazy
- (GoodSleepHeadView *)goodSleepHeadView {
if (!_goodSleepHeadView) {
_goodSleepHeadView = [[GoodSleepHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 68) headType:GSHeadTypeSR];
_goodSleepHeadView.delegate = self;
}
return _goodSleepHeadView;
}
- (NoiseView *)noiseView {
if (!_noiseView) {
_noiseView = [[NoiseView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.goodSleepHeadView.frame), kScreenWidth, 40 + 327 + 70) noiseTypeData:@[] headType:GSHeadTypeSR];
}
return _noiseView;
}
- (NoisePlayBar *)noisePlayBar {
if (!_noisePlayBar) {
_noisePlayBar = [[NoisePlayBar alloc] initWithFrame:CGRectZero headType:GSHeadTypeSR];
}
return _noisePlayBar;
}
@end
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
// //
#import "SleepReadyController.h" #import "SleepReadyController.h"
#import "SRTipsView.h"
#import "ReadyListController.h" #import "ReadyListController.h"
#import "SRTipsView.h" #import "SRTipsView.h"
#import "SRMusicView.h"
#import "NoisePlayerManager.h"
#import "WhiteNoiseRequestModel.h"
@interface SleepReadyController () <ReadyListControllerDelegate> @interface SleepReadyController () <ReadyListControllerDelegate>
@property (nonatomic, strong) UIImageView *headIV; @property (nonatomic, strong) UIImageView *headIV;
...@@ -17,6 +19,7 @@ ...@@ -17,6 +19,7 @@
@property (nonatomic, strong) SRTipsView *sRTipsView; @property (nonatomic, strong) SRTipsView *sRTipsView;
@property (nonatomic, strong) UIButton *startBtn; @property (nonatomic, strong) UIButton *startBtn;
@property (nonatomic, strong) UIButton *musicBtn; @property (nonatomic, strong) UIButton *musicBtn;
@property (nonatomic, strong) SRMusicView *musicView;
@end @end
@implementation SleepReadyController @implementation SleepReadyController
...@@ -30,15 +33,16 @@ ...@@ -30,15 +33,16 @@
[self.dsNaviBar addSubview:self.backBtn]; [self.dsNaviBar addSubview:self.backBtn];
self.titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal]; [self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
[self.dsNaviBar addSubview:self.tipsBtn]; [self.dsNaviBar addSubview:self.tipsBtn];
[self.dsNaviBar addSubview:self.setBtn]; [self.dsNaviBar addSubview:self.setBtn];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view insertSubview:self.headIV atIndex:0]; [self.view insertSubview:self.headIV atIndex:0];
[self.view addSubview:self.startBtn]; [self.view addSubview:self.startBtn];
[self.view addSubview:self.musicBtn]; [self.view addSubview:self.musicBtn];
[self.view addSubview:self.musicView];
[self.tipsBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.tipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.titleLab); make.centerY.equalTo(self.titleLab);
...@@ -60,6 +64,25 @@ ...@@ -60,6 +64,25 @@
make.centerY.equalTo(self.startBtn); make.centerY.equalTo(self.startBtn);
make.right.equalTo(self.view).offset(-15); make.right.equalTo(self.view).offset(-15);
}]; }];
[self queryRelaxWhiteNoiseType];
}
- (void)queryRelaxWhiteNoiseType {
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取白噪音类型请求成功...");
[self.musicView refreshNoiseTypeData:requestModel.noiseTypeArr];
}
}];
}
- (void)backAction {
// 重置白噪音播放
[[NoisePlayerManager sharedNoisePlayerManager] removeAllNoiseAudioCell];
[super backAction];
} }
#pragma mark - ReadyListControllerDelegate #pragma mark - ReadyListControllerDelegate
...@@ -107,13 +130,13 @@ ...@@ -107,13 +130,13 @@
- (UIButton *)startBtn { - (UIButton *)startBtn {
if (!_startBtn) { if (!_startBtn) {
WS(weakSelf); // WS(weakSelf);
_startBtn = [UIButton btnWithTitle:@"开始仪式" font:BoldFont(16.0)]; _startBtn = [UIButton btnWithTitle:@"开始仪式" font:BoldFont(16.0)];
[_startBtn cornerRadius:20.0]; [_startBtn cornerRadius:20.0];
[_startBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)]; [_startBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)];
[_startBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal]; [_startBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_startBtn addTouchUpInsideHandler:^(NSInteger tag) { [_startBtn addTouchUpInsideHandler:^(NSInteger tag) {
// [weakSelf dismissTipsAlertView]; // [weakSelf dismissTipsAlertView];
}]; }];
} }
return _startBtn; return _startBtn;
...@@ -121,13 +144,23 @@ ...@@ -121,13 +144,23 @@
- (UIButton *)musicBtn { - (UIButton *)musicBtn {
if (!_musicBtn) { if (!_musicBtn) {
WS(weakSelf);
_musicBtn = [UIButton new]; _musicBtn = [UIButton new];
[_musicBtn setImage:[UIImage imageNamed:@"ic_zhunbei_baizaoyin"] forState:UIControlStateNormal]; [_musicBtn setImage:[UIImage imageNamed:@"ic_zhunbei_baizaoyin"] forState:UIControlStateNormal];
[_musicBtn addTouchUpInsideHandler:^(NSInteger tag) { [_musicBtn addTouchUpInsideHandler:^(NSInteger tag) {
[UIView animateWithDuration:.3 animations:^{
weakSelf.musicView.y = kScreenHeight - weakSelf.musicView.height;
}];
}]; }];
} }
return _musicBtn; return _musicBtn;
} }
- (SRMusicView *)musicView {
if (!_musicView) {
_musicView = [[SRMusicView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, 68 + 40 + 327 + 70)];
}
return _musicView;
}
@end @end
...@@ -401,7 +401,7 @@ ...@@ -401,7 +401,7 @@
- (NoisePlayBar *)noisePlayBar { - (NoisePlayBar *)noisePlayBar {
if (!_noisePlayBar) { if (!_noisePlayBar) {
_noisePlayBar = [NoisePlayBar new]; _noisePlayBar = [[NoisePlayBar alloc] initWithFrame:CGRectZero headType:GSHeadTypeHome];
} }
return _noisePlayBar; return _noisePlayBar;
} }
......
...@@ -110,14 +110,14 @@ ...@@ -110,14 +110,14 @@
- (GoodSleepHeadView *)goodSleepHeadView { - (GoodSleepHeadView *)goodSleepHeadView {
if (!_goodSleepHeadView) { if (!_goodSleepHeadView) {
_goodSleepHeadView = [[GoodSleepHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 68)]; _goodSleepHeadView = [[GoodSleepHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 68) headType:GSHeadTypeHome];
} }
return _goodSleepHeadView; return _goodSleepHeadView;
} }
- (NoiseView *)noiseView { - (NoiseView *)noiseView {
if (!_noiseView) { if (!_noiseView) {
_noiseView = [[NoiseView alloc] initWithNoiseTypeData:@[]]; _noiseView = [[NoiseView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40 + 327 + 70) noiseTypeData:@[] headType:GSHeadTypeHome];
} }
return _noiseView; return _noiseView;
} }
......
...@@ -6,12 +6,21 @@ ...@@ -6,12 +6,21 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "NoiseTypeModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol GoodSleepHeadViewDelegate <NSObject>
- (void)closeAction;
@end
/// 好眠声音头部 /// 好眠声音头部
@interface GoodSleepHeadView : UIView @interface GoodSleepHeadView : UIView
@property (nonatomic, weak) id<GoodSleepHeadViewDelegate> delegate;
- (instancetype)initWithFrame:(CGRect)frame headType:(GSHeadType)headType;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -14,15 +14,16 @@ ...@@ -14,15 +14,16 @@
@property (nonatomic, strong) UILabel *titleLab; @property (nonatomic, strong) UILabel *titleLab;
/// 定时器 /// 定时器
@property (nonatomic, strong) UIButton *timerBtn; @property (nonatomic, strong) UIButton *timerBtn;
/// 关闭按钮
@property (nonatomic, strong) UIButton *closeBtn;
@end @end
@implementation GoodSleepHeadView @implementation GoodSleepHeadView
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame headType:(GSHeadType)headType {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
[self addSubview:self.verticalView]; [self addSubview:self.verticalView];
[self addSubview:self.titleLab]; [self addSubview:self.titleLab];
[self addSubview:self.timerBtn];
[self.verticalView mas_makeConstraints:^(MASConstraintMaker *make) { [self.verticalView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).offset(15); make.left.equalTo(self.mas_left).offset(15);
...@@ -34,12 +35,26 @@ ...@@ -34,12 +35,26 @@
make.left.equalTo(self.verticalView.mas_right).offset(8); make.left.equalTo(self.verticalView.mas_right).offset(8);
make.centerY.equalTo(self.verticalView.mas_centerY); make.centerY.equalTo(self.verticalView.mas_centerY);
}]; }];
[self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.mas_right).offset(-15); if (headType == GSHeadTypeHome) {
make.width.equalTo(@40); [self addSubview:self.timerBtn];
make.height.equalTo(@30); [self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.verticalView.mas_centerY); make.right.equalTo(self.mas_right).offset(-15);
}]; make.width.equalTo(@40);
make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY);
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
}];
} else if (headType == GSHeadTypeSR) {
[self addSubview:self.closeBtn];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.mas_right).offset(-15);
make.width.equalTo(@30);
make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY);
}];
self.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
}
} }
return self; return self;
} }
...@@ -75,4 +90,18 @@ ...@@ -75,4 +90,18 @@
return _timerBtn; return _timerBtn;
} }
- (UIButton *)closeBtn {
if (!_closeBtn) {
WS(weakSelf);
_closeBtn = [UIButton new];
[_closeBtn dk_setImage:DKImagePickerWithNames(@"home_close", @"dk_home_close", @"home_close") forState:UIControlStateNormal];
[_closeBtn addTouchUpInsideHandler:^(NSInteger tag) {
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(closeAction)]) {
[weakSelf.delegate closeAction];
}
}];
}
return _closeBtn;
}
@end @end
...@@ -6,15 +6,18 @@ ...@@ -6,15 +6,18 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "NoiseTypeModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 白噪音通用分页 /// 白噪音通用分页
@interface NoiseListController : UIViewController @interface NoiseListController : UIViewController
@property(nonatomic, assign) GSHeadType headType;
@property (nonatomic, copy) NSString *sub_name; @property (nonatomic, copy) NSString *sub_name;
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID; - (instancetype)initWithNoiseTypeID:(NSInteger)typeID headType:(GSHeadType)headType;
@end @end
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
NSInteger _typeID; NSInteger _typeID;
} }
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID { - (instancetype)initWithNoiseTypeID:(NSInteger)typeID headType:(GSHeadType)headType {
if (self = [super init]) { if (self = [super init]) {
// 头部类型
_headType = headType;
// 白噪音类型id // 白噪音类型id
_typeID = typeID; _typeID = typeID;
} }
...@@ -30,7 +32,7 @@ ...@@ -30,7 +32,7 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = self.headType == GSHeadTypeHome ? DKColorPickerWithKey(VCViewBG) : DKColorPickerWithKey(TabBarBG);
[self.view addSubview:self.noiseAudioView]; [self.view addSubview:self.noiseAudioView];
} }
...@@ -62,20 +64,6 @@ ...@@ -62,20 +64,6 @@
NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath]; NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath];
NoiseAudioModel *model = self.noiseAudioArr[indexPath.row]; NoiseAudioModel *model = self.noiseAudioArr[indexPath.row];
cell.model = model; 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;
} }
...@@ -116,7 +104,7 @@ ...@@ -116,7 +104,7 @@
layout.minimumInteritemSpacing = space; layout.minimumInteritemSpacing = space;
layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.scrollDirection = UICollectionViewScrollDirectionVertical;
_noiseAudioView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 327 + 70) collectionViewLayout:layout]; _noiseAudioView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 327 + 70) collectionViewLayout:layout];
_noiseAudioView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); _noiseAudioView.dk_backgroundColorPicker = self.headType == GSHeadTypeHome ? DKColorPickerWithKey(VCViewBG) : DKColorPickerWithKey(TabBarBG);
_noiseAudioView.delegate = self; _noiseAudioView.delegate = self;
_noiseAudioView.dataSource = self; _noiseAudioView.dataSource = self;
[_noiseAudioView registerClass:[NoiseAudioCell class] forCellWithReuseIdentifier:@"NoiseAudioCellID"]; [_noiseAudioView registerClass:[NoiseAudioCell class] forCellWithReuseIdentifier:@"NoiseAudioCellID"];
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 好眠声音头部类型
typedef NS_ENUM(NSInteger, GSHeadType) {
GSHeadTypeHome, // 首页定时
GSHeadTypeSR, // 安睡准备关闭
};
/// 白噪音类型数据model /// 白噪音类型数据model
@interface NoiseTypeModel : NSObject @interface NoiseTypeModel : NSObject
/// 白噪音分类id /// 白噪音分类id
......
...@@ -6,11 +6,15 @@ ...@@ -6,11 +6,15 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "NoiseTypeModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 首页白噪音播放悬浮条 /// 首页白噪音播放悬浮条
@interface NoisePlayBar : UIView @interface NoisePlayBar : UIView
- (instancetype)initWithFrame:(CGRect)frame headType:(GSHeadType)headType;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -26,15 +26,12 @@ ...@@ -26,15 +26,12 @@
@implementation NoisePlayBar @implementation NoisePlayBar
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame headType:(GSHeadType)headType {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
[self cornerRadius:12.0]; [self cornerRadius:12.0];
self.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG); self.dk_backgroundColorPicker = headType == GSHeadTypeHome ? DKColorPickerWithKey(TabBarBG) : DKColorPickerWithColors(BGColor, DarkColor, DSWhite);
self.hidden = YES; self.hidden = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showAudioListView)];
[self addGestureRecognizer:tap];
[self addSubview:self.topIV]; [self addSubview:self.topIV];
[self addSubview:self.audioLab]; [self addSubview:self.audioLab];
[self addSubview:self.timeLab]; [self addSubview:self.timeLab];
...@@ -61,6 +58,13 @@ ...@@ -61,6 +58,13 @@
make.height.width.equalTo(@35); make.height.width.equalTo(@35);
}]; }];
if (headType == GSHeadTypeSR) {
self.topIV.hidden = YES;
} else if (headType == GSHeadTypeHome) {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showAudioListView)];
[self addGestureRecognizer:tap];
}
self.minuteIndex = 0; self.minuteIndex = 0;
self.countTime = 60; self.countTime = 60;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "NoiseTypeModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
...@@ -77,9 +78,9 @@ typedef NS_ENUM(NSInteger, PageTitleColorChangeType) { ...@@ -77,9 +78,9 @@ typedef NS_ENUM(NSInteger, PageTitleColorChangeType) {
/// @param data data /// @param data data
- (void)refreshNoiseTypeData:(NSArray *)data; - (void)refreshNoiseTypeData:(NSArray *)data;
/// 初始化 - (instancetype)initWithFrame:(CGRect)frame noiseTypeData:(NSArray *)data headType:(GSHeadType)headType;
/// @param data data
- (instancetype)initWithNoiseTypeData:(NSArray *)data; @property(nonatomic, assign) GSHeadType headType;
/** 分页条高度 */ /** 分页条高度 */
@property(nonatomic, assign) CGFloat pageBarHeight; @property(nonatomic, assign) CGFloat pageBarHeight;
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
@implementation XXPageItemCell @implementation XXPageItemCell
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleClick)]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleClick)];
[self addGestureRecognizer:tap]; [self addGestureRecognizer:tap];
...@@ -116,8 +114,9 @@ ...@@ -116,8 +114,9 @@
#define kAnimateDuration 0.3 #define kAnimateDuration 0.3
static NSString *mainCell = @"inxx_mainCell"; static NSString *mainCell = @"inxx_mainCell";
- (instancetype)initWithNoiseTypeData:(NSArray *)data { - (instancetype)initWithFrame:(CGRect)frame noiseTypeData:(NSArray *)data headType:(GSHeadType)headType {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, 40 + 327 + 70)]) { if (self = [super initWithFrame:frame]) {
self.headType = headType;
self.pageTypes = data; self.pageTypes = data;
self.controllersClass = @[]; self.controllersClass = @[];
self.selectedIndex = 0; self.selectedIndex = 0;
...@@ -136,7 +135,7 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -136,7 +135,7 @@ static NSString *mainCell = @"inxx_mainCell";
NSMutableArray *tmpVCArr = [NSMutableArray array]; NSMutableArray *tmpVCArr = [NSMutableArray array];
for (int i = 0; i < self.pageTypes.count; i++) { for (int i = 0; i < self.pageTypes.count; i++) {
NoiseTypeModel *typeModel = self.pageTypes[i]; NoiseTypeModel *typeModel = self.pageTypes[i];
NoiseListController *list = [[NoiseListController alloc] initWithNoiseTypeID:typeModel.type_id]; NoiseListController *list = [[NoiseListController alloc] initWithNoiseTypeID:typeModel.type_id headType:self.headType];
list.sub_name = typeModel.sub_name; list.sub_name = typeModel.sub_name;
list.view.frame = CGRectMake(0, 0, self.collectionMain.width, self.collectionMain.height); list.view.frame = CGRectMake(0, 0, self.collectionMain.width, self.collectionMain.height);
[tmpVCArr addObject:list]; [tmpVCArr addObject:list];
...@@ -147,7 +146,7 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -147,7 +146,7 @@ static NSString *mainCell = @"inxx_mainCell";
[self addScrollViewPage]; [self addScrollViewPage];
[self addCollectionMain]; [self addCollectionMain];
[self addPageBottomLine]; [self addPageBottomLine];
[self addObserver:self forKeyPath:@"selectedIndex" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil]; [self addObserver:self forKeyPath:@"selectedIndex" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
// 1. 更新下划线的frame // 1. 更新下划线的frame
[self updateLineFrameWithIndex:self.selectedIndex]; [self updateLineFrameWithIndex:self.selectedIndex];
...@@ -212,7 +211,7 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -212,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.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); scrollViewPage.dk_backgroundColorPicker = self.headType == GSHeadTypeHome ? DKColorPickerWithKey(VCViewBG) : DKColorPickerWithKey(TabBarBG);
[self addSubview:scrollViewPage]; [self addSubview:scrollViewPage];
CGFloat contentWidth = 0; CGFloat contentWidth = 0;
...@@ -284,7 +283,7 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -284,7 +283,7 @@ static NSString *mainCell = @"inxx_mainCell";
_line.center = CGPointMake((index * _pageCellW) + _pageCellW/2, _pageBarHeight - _lineHeight/2); _line.center = CGPointMake((index * _pageCellW) + _pageCellW/2, _pageBarHeight - _lineHeight/2);
} }
if (_lineColors) { if (_lineColors) {
//_line.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleLeftToRight withFrame:_line.bounds andColors:_lineColors]; // _line.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleLeftToRight withFrame:_line.bounds andColors:_lineColors];
} }
} }
...@@ -323,7 +322,9 @@ static NSString *mainCell = @"inxx_mainCell"; ...@@ -323,7 +322,9 @@ static NSString *mainCell = @"inxx_mainCell";
} }
- (void)dealloc { - (void)dealloc {
[self removeObserver:self forKeyPath:@"selectedIndex"]; if (self.pageTypes.count) {
[self removeObserver:self forKeyPath:@"selectedIndex"];
}
} }
/// 刷新 CollectionPage的Cell 数据 /// 刷新 CollectionPage的Cell 数据
...@@ -429,7 +430,7 @@ static float oldOffsetX; ...@@ -429,7 +430,7 @@ static float oldOffsetX;
/// 处理working中的2个分页标题底部线性指示器的实时属性 /// 处理working中的2个分页标题底部线性指示器的实时属性
/// @param x SrollX /// @param x SrollX
- (void)changePageLinePropertyiesWithSrollX:(CGFloat)x { - (void)changePageLinePropertyiesWithSrollX:(CGFloat)x {
//需要随滑动而改变UI样式:LineScrollTypeDynamicAnimation/LineScrollTypeDynamicLinear // 需要随滑动而改变UI样式:LineScrollTypeDynamicAnimation/LineScrollTypeDynamicLinear
if (_lineScrollType == LineScrollTypeDynamicAnimation || _lineScrollType == LineScrollTypeDynamicLinear) { if (_lineScrollType == LineScrollTypeDynamicAnimation || _lineScrollType == LineScrollTypeDynamicLinear) {
int lineIndex = (x + kScreenWidth*0.5) / kScreenWidth; ///< 线指示器滑动切换index基准选择: kScreenWidth*0.5(半屏) 过半屏 index 值会+1 int lineIndex = (x + kScreenWidth*0.5) / kScreenWidth; ///< 线指示器滑动切换index基准选择: kScreenWidth*0.5(半屏) 过半屏 index 值会+1
......
...@@ -30,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -30,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL isNeedUpdateStatusBarStyle; @property (nonatomic, assign) BOOL isNeedUpdateStatusBarStyle;
/// 导航栏背景色 /// 导航栏背景色
@property (nonatomic, strong) UIColor *naviBgColor; @property (nonatomic, strong) UIColor *naviBgColor;
- (void)backAction;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!