Commit 6ebc1c44 cgx

首页白噪音显示模块初步完成

1 个父辈 1bed1b3e
正在显示 28 个修改的文件 包含 1399 行增加4 行删除
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
D01814E8280020F900583D4E /* CWPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E6280020F800583D4E /* CWPageControl.m */; }; D01814E8280020F900583D4E /* CWPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E6280020F800583D4E /* CWPageControl.m */; };
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814EA28002A8200583D4E /* DsMiddleView.m */; }; D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814EA28002A8200583D4E /* DsMiddleView.m */; };
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814ED28002DC700583D4E /* HeaderDataModel.m */; }; D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814ED28002DC700583D4E /* HeaderDataModel.m */; };
D01BD425282BFFB400BA86B3 /* WhiteNoiseRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01BD424282BFFB400BA86B3 /* WhiteNoiseRequestModel.m */; };
D01BD428282C003900BA86B3 /* NoiseTypeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01BD427282C003900BA86B3 /* NoiseTypeModel.m */; };
D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01BD42A282C03FC00BA86B3 /* NoiseAudioModel.m */; };
D01BD42E282C06D200BA86B3 /* NoiseListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D01BD42D282C06D200BA86B3 /* NoiseListController.m */; };
D01C9D6728167F9D00163567 /* InfoModifyAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */; }; D01C9D6728167F9D00163567 /* InfoModifyAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */; };
D01C9D6E28168BFC00163567 /* WSDatePickerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D01C9D6B28168BFC00163567 /* WSDatePickerView.xib */; }; D01C9D6E28168BFC00163567 /* WSDatePickerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D01C9D6B28168BFC00163567 /* WSDatePickerView.xib */; };
D01C9D6F28168BFC00163567 /* WSDatePickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01C9D6C28168BFC00163567 /* WSDatePickerView.m */; }; D01C9D6F28168BFC00163567 /* WSDatePickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01C9D6C28168BFC00163567 /* WSDatePickerView.m */; };
...@@ -114,6 +118,7 @@ ...@@ -114,6 +118,7 @@
D0A72E3C282B56E600EED7BE /* GoodSleepSoundCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E3B282B56E600EED7BE /* GoodSleepSoundCell.m */; }; D0A72E3C282B56E600EED7BE /* GoodSleepSoundCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E3B282B56E600EED7BE /* GoodSleepSoundCell.m */; };
D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E3E282B89AD00EED7BE /* DSHomeView.m */; }; D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E3E282B89AD00EED7BE /* DSHomeView.m */; };
D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */; }; D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */; };
D0A750FC282DE21D00589B0E /* NoiseAudioCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A750FB282DE21D00589B0E /* NoiseAudioCell.m */; };
D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AE1E3428281B6F008CEF27 /* TimerProxy.m */; }; D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AE1E3428281B6F008CEF27 /* TimerProxy.m */; };
D0AEFE79281781CF00230DC6 /* MyFeedModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AEFE78281781CF00230DC6 /* MyFeedModel.m */; }; D0AEFE79281781CF00230DC6 /* MyFeedModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AEFE78281781CF00230DC6 /* MyFeedModel.m */; };
D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AEFE7A2817D13400230DC6 /* UITableViewCell+CardRadius.m */; }; D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */ = {isa = PBXBuildFile; fileRef = D0AEFE7A2817D13400230DC6 /* UITableViewCell+CardRadius.m */; };
...@@ -145,6 +150,7 @@ ...@@ -145,6 +150,7 @@
D0CFD3CF27FB3B920002982B /* launcher@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CC27FB3B910002982B /* launcher@2x.png */; }; D0CFD3CF27FB3B920002982B /* launcher@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CC27FB3B910002982B /* launcher@2x.png */; };
D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; }; D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; };
D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; }; D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; };
D0D00199282C9402004EAFA1 /* NoiseView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D00198282C9402004EAFA1 /* NoiseView.m */; };
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; }; D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; };
D0D69ED3282360F100A0D5EB /* LookAllController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D69ED2282360F100A0D5EB /* LookAllController.m */; }; D0D69ED3282360F100A0D5EB /* LookAllController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D69ED2282360F100A0D5EB /* LookAllController.m */; };
D0D69ED628236E0800A0D5EB /* SafeSleepListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D69ED528236E0800A0D5EB /* SafeSleepListController.m */; }; D0D69ED628236E0800A0D5EB /* SafeSleepListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D69ED528236E0800A0D5EB /* SafeSleepListController.m */; };
...@@ -202,6 +208,14 @@ ...@@ -202,6 +208,14 @@
D01814EA28002A8200583D4E /* DsMiddleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsMiddleView.m; sourceTree = "<group>"; }; D01814EA28002A8200583D4E /* DsMiddleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsMiddleView.m; sourceTree = "<group>"; };
D01814EC28002DC700583D4E /* HeaderDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HeaderDataModel.h; sourceTree = "<group>"; }; D01814EC28002DC700583D4E /* HeaderDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HeaderDataModel.h; sourceTree = "<group>"; };
D01814ED28002DC700583D4E /* HeaderDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HeaderDataModel.m; sourceTree = "<group>"; }; D01814ED28002DC700583D4E /* HeaderDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HeaderDataModel.m; sourceTree = "<group>"; };
D01BD423282BFFB400BA86B3 /* WhiteNoiseRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WhiteNoiseRequestModel.h; sourceTree = "<group>"; };
D01BD424282BFFB400BA86B3 /* WhiteNoiseRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WhiteNoiseRequestModel.m; sourceTree = "<group>"; };
D01BD426282C003900BA86B3 /* NoiseTypeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoiseTypeModel.h; sourceTree = "<group>"; };
D01BD427282C003900BA86B3 /* NoiseTypeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NoiseTypeModel.m; sourceTree = "<group>"; };
D01BD429282C03FC00BA86B3 /* NoiseAudioModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoiseAudioModel.h; sourceTree = "<group>"; };
D01BD42A282C03FC00BA86B3 /* NoiseAudioModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NoiseAudioModel.m; sourceTree = "<group>"; };
D01BD42C282C06D200BA86B3 /* NoiseListController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoiseListController.h; sourceTree = "<group>"; };
D01BD42D282C06D200BA86B3 /* NoiseListController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NoiseListController.m; sourceTree = "<group>"; };
D01C9D6528167F9D00163567 /* InfoModifyAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoModifyAlertView.h; sourceTree = "<group>"; }; D01C9D6528167F9D00163567 /* InfoModifyAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoModifyAlertView.h; sourceTree = "<group>"; };
D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoModifyAlertView.m; sourceTree = "<group>"; }; D01C9D6628167F9D00163567 /* InfoModifyAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoModifyAlertView.m; sourceTree = "<group>"; };
D01C9D6928168BFC00163567 /* NSDate+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+Extension.h"; sourceTree = "<group>"; }; D01C9D6928168BFC00163567 /* NSDate+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+Extension.h"; sourceTree = "<group>"; };
...@@ -383,6 +397,8 @@ ...@@ -383,6 +397,8 @@
D0A72E3E282B89AD00EED7BE /* DSHomeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSHomeView.m; sourceTree = "<group>"; }; D0A72E3E282B89AD00EED7BE /* DSHomeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSHomeView.m; sourceTree = "<group>"; };
D0A72E40282B8BA600EED7BE /* CourseMusicCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CourseMusicCell.h; sourceTree = "<group>"; }; D0A72E40282B8BA600EED7BE /* CourseMusicCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CourseMusicCell.h; sourceTree = "<group>"; };
D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CourseMusicCell.m; sourceTree = "<group>"; }; D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CourseMusicCell.m; sourceTree = "<group>"; };
D0A750FA282DE21D00589B0E /* NoiseAudioCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoiseAudioCell.h; sourceTree = "<group>"; };
D0A750FB282DE21D00589B0E /* NoiseAudioCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NoiseAudioCell.m; sourceTree = "<group>"; };
D0AE1E3328281B6F008CEF27 /* TimerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TimerProxy.h; sourceTree = "<group>"; }; D0AE1E3328281B6F008CEF27 /* TimerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TimerProxy.h; sourceTree = "<group>"; };
D0AE1E3428281B6F008CEF27 /* TimerProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TimerProxy.m; sourceTree = "<group>"; }; D0AE1E3428281B6F008CEF27 /* TimerProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TimerProxy.m; sourceTree = "<group>"; };
D0AEFE77281781CF00230DC6 /* MyFeedModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyFeedModel.h; sourceTree = "<group>"; }; D0AEFE77281781CF00230DC6 /* MyFeedModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyFeedModel.h; sourceTree = "<group>"; };
...@@ -440,6 +456,8 @@ ...@@ -440,6 +456,8 @@
D0CFD3CC27FB3B910002982B /* launcher@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@2x.png"; sourceTree = "<group>"; }; D0CFD3CC27FB3B910002982B /* launcher@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@2x.png"; sourceTree = "<group>"; };
D0CFD3CD27FB3B910002982B /* launcher@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@3x.png"; sourceTree = "<group>"; }; D0CFD3CD27FB3B910002982B /* launcher@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launcher@3x.png"; sourceTree = "<group>"; };
D0CFD3CE27FB3B920002982B /* launcher.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = launcher.png; sourceTree = "<group>"; }; D0CFD3CE27FB3B920002982B /* launcher.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = launcher.png; sourceTree = "<group>"; };
D0D00197282C9402004EAFA1 /* NoiseView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoiseView.h; sourceTree = "<group>"; };
D0D00198282C9402004EAFA1 /* NoiseView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NoiseView.m; sourceTree = "<group>"; };
D0D3826528124E8A005BB219 /* FeedbackController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackController.h; sourceTree = "<group>"; }; D0D3826528124E8A005BB219 /* FeedbackController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackController.h; sourceTree = "<group>"; };
D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; }; D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; };
D0D69ED1282360F100A0D5EB /* LookAllController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LookAllController.h; sourceTree = "<group>"; }; D0D69ED1282360F100A0D5EB /* LookAllController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LookAllController.h; sourceTree = "<group>"; };
...@@ -980,6 +998,18 @@ ...@@ -980,6 +998,18 @@
D0A72E36282B539200EED7BE /* WhiteNoise */ = { D0A72E36282B539200EED7BE /* WhiteNoise */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D01BD423282BFFB400BA86B3 /* WhiteNoiseRequestModel.h */,
D01BD424282BFFB400BA86B3 /* WhiteNoiseRequestModel.m */,
D01BD426282C003900BA86B3 /* NoiseTypeModel.h */,
D01BD427282C003900BA86B3 /* NoiseTypeModel.m */,
D01BD429282C03FC00BA86B3 /* NoiseAudioModel.h */,
D01BD42A282C03FC00BA86B3 /* NoiseAudioModel.m */,
D01BD42C282C06D200BA86B3 /* NoiseListController.h */,
D01BD42D282C06D200BA86B3 /* NoiseListController.m */,
D0D00197282C9402004EAFA1 /* NoiseView.h */,
D0D00198282C9402004EAFA1 /* NoiseView.m */,
D0A750FA282DE21D00589B0E /* NoiseAudioCell.h */,
D0A750FB282DE21D00589B0E /* NoiseAudioCell.m */,
); );
path = WhiteNoise; path = WhiteNoise;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1522,6 +1552,7 @@ ...@@ -1522,6 +1552,7 @@
D09D0E9D280D73B6008DEDAB /* InviteController.m in Sources */, D09D0E9D280D73B6008DEDAB /* InviteController.m in Sources */,
D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */, D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */,
D053BEE9280F9E310028CCFC /* CloseAlertView.m in Sources */, D053BEE9280F9E310028CCFC /* CloseAlertView.m in Sources */,
D0D00199282C9402004EAFA1 /* NoiseView.m in Sources */,
D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */, D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */,
D0FAC429281B865300D4B859 /* GKYYWebImageManager.m in Sources */, D0FAC429281B865300D4B859 /* GKYYWebImageManager.m in Sources */,
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */, D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */,
...@@ -1567,10 +1598,13 @@ ...@@ -1567,10 +1598,13 @@
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */, D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */,
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */, D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */,
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */, D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */,
D01BD42E282C06D200BA86B3 /* NoiseListController.m in Sources */,
D03AE82B281A9010001C0726 /* MyFeedDetailModel.m in Sources */, D03AE82B281A9010001C0726 /* MyFeedDetailModel.m in Sources */,
D0A750FC282DE21D00589B0E /* NoiseAudioCell.m in Sources */,
D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */, D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */,
D0C50B4627FD66FB00DC68F0 /* DSConstUtil.m in Sources */, D0C50B4627FD66FB00DC68F0 /* DSConstUtil.m in Sources */,
D08F79DC281A1838000D99DD /* TZProgressView.m in Sources */, D08F79DC281A1838000D99DD /* TZProgressView.m in Sources */,
D01BD428282C003900BA86B3 /* NoiseTypeModel.m in Sources */,
D01814D227FFCBAF00583D4E /* CWFlowLayout.m in Sources */, D01814D227FFCBAF00583D4E /* CWFlowLayout.m in Sources */,
D0D69ED3282360F100A0D5EB /* LookAllController.m in Sources */, D0D69ED3282360F100A0D5EB /* LookAllController.m in Sources */,
D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */, D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */,
...@@ -1601,6 +1635,7 @@ ...@@ -1601,6 +1635,7 @@
D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */, D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */,
D09BF331280E570D00E5F06C /* UserModel.m in Sources */, D09BF331280E570D00E5F06C /* UserModel.m in Sources */,
D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */, D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */,
D01BD425282BFFB400BA86B3 /* WhiteNoiseRequestModel.m in Sources */,
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */, D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */,
D091BBBB2809079600487A50 /* NSString+Extras.m in Sources */, D091BBBB2809079600487A50 /* NSString+Extras.m in Sources */,
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */, D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */,
...@@ -1614,6 +1649,7 @@ ...@@ -1614,6 +1649,7 @@
D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */, D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */,
D0A72E39282B566200EED7BE /* HomeBasicCell.m in Sources */, D0A72E39282B566200EED7BE /* HomeBasicCell.m in Sources */,
D08F79DA281A1838000D99DD /* TZPhotoPreviewController.m in Sources */, D08F79DA281A1838000D99DD /* TZPhotoPreviewController.m in Sources */,
D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */,
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */, D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */,
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */, D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */,
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */, D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */,
...@@ -1875,7 +1911,7 @@ ...@@ -1875,7 +1911,7 @@
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 = 2;
DEVELOPMENT_TEAM = 4NDZ6UX8PW; DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/UMSocialUI", "$(PROJECT_DIR)/DreamSleep/Vendors/UMSocial_6.10.4/UMSocialUI",
......
...@@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 用于调试UI /// 用于调试UI
- (void)debugViewShowBorder; - (void)debugViewShowBorder;
- (void)debugViewShowBorderWithColor:(UIColor *)color;
/// 设置圆角 /// 设置圆角
/// @param radius radius /// @param radius radius
- (void)cornerRadius:(CGFloat)radius; - (void)cornerRadius:(CGFloat)radius;
......
...@@ -104,6 +104,11 @@ ...@@ -104,6 +104,11 @@
self.layer.borderWidth = 2; self.layer.borderWidth = 2;
} }
- (void)debugViewShowBorderWithColor:(UIColor *)color {
self.layer.borderColor = color.CGColor;
self.layer.borderWidth = 2;
}
- (void)cornerRadius:(CGFloat)radius { - (void)cornerRadius:(CGFloat)radius {
self.layer.cornerRadius = radius; self.layer.cornerRadius = radius;
self.layer.masksToBounds = YES; self.layer.masksToBounds = YES;
......
...@@ -36,6 +36,8 @@ FOUNDATION_EXTERN NSString * const ExpireTime2; ...@@ -36,6 +36,8 @@ FOUNDATION_EXTERN NSString * const ExpireTime2;
FOUNDATION_EXTERN NSString * const WXLoginAuthNoti; FOUNDATION_EXTERN NSString * const WXLoginAuthNoti;
// 更新用户数据通知 // 更新用户数据通知
FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti; FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti;
// 刷新主页通知
FOUNDATION_EXTERN NSString * const NeedUpdateHomePage;
// 用户基础信息 // 用户基础信息
FOUNDATION_EXTERN NSString * const UserBasicInfo; FOUNDATION_EXTERN NSString * const UserBasicInfo;
......
...@@ -26,6 +26,7 @@ NSString * const ExpireTime2 = @"06:00:00"; ...@@ -26,6 +26,7 @@ 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 UserBasicInfo = @"UserBasicInfo"; NSString * const UserBasicInfo = @"UserBasicInfo";
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "HomeRequestModel.h" #import "HomeRequestModel.h"
#import "ThreeMinuteController.h" #import "ThreeMinuteController.h"
#import "SafeSleepRequestModel.h" #import "SafeSleepRequestModel.h"
#import "WhiteNoiseRequestModel.h"
@interface HomeViewController () @interface HomeViewController ()
@property (nonatomic, strong) DSHomeView *homeTV; @property (nonatomic, strong) DSHomeView *homeTV;
...@@ -44,6 +45,25 @@ ...@@ -44,6 +45,25 @@
[self showFirstLeadAlertView]; [self showFirstLeadAlertView];
[self requestHomeData]; [self requestHomeData];
// 监听主页需要刷新数据通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
dispatch_async(dispatch_get_main_queue(), ^{
self.homeTV.frame = CGRectMake(0, kTopHeight(0), kScreenWidth, kScreenHeight - kTopHeight(0) - kTabBarHeight);
});
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil];
}
- (void)needUpdate {
[self.homeTV.mj_header beginRefreshing];
} }
#pragma mark - banner、舒眠课程、助眠音乐数据获取 #pragma mark - banner、舒眠课程、助眠音乐数据获取
...@@ -70,6 +90,13 @@ ...@@ -70,6 +90,13 @@
[self.homeTV updateCourseMusicCell:CellTypeMusic data:requestModel.courseListData]; [self.homeTV updateCourseMusicCell:CellTypeMusic data:requestModel.courseListData];
} }
}]; }];
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
[self.homeTV.mj_header endRefreshing];
if (requestModel.resCode == DSResCodeSuccess) {
[self.homeTV updateNoiseAllTypeData:requestModel.noiseTypeArr];
}
}];
}]; }];
[self.homeTV.mj_header beginRefreshing]; [self.homeTV.mj_header beginRefreshing];
} }
......
...@@ -22,6 +22,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -22,6 +22,9 @@ NS_ASSUME_NONNULL_BEGIN
/// @param dataArr dataArr /// @param dataArr dataArr
- (void)updateCourseMusicCell:(CellType)type data:(NSArray *)dataArr; - (void)updateCourseMusicCell:(CellType)type data:(NSArray *)dataArr;
/// 更新白噪音类型数据
/// @param typeDataArr typeDataArr
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -13,17 +13,20 @@ ...@@ -13,17 +13,20 @@
@interface DSHomeView () <UITableViewDelegate, UITableViewDataSource> @interface DSHomeView () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) HomeHeaderView *headerView; @property (nonatomic, strong) HomeHeaderView *headerView;
@property (nonatomic, strong) NSArray *courseMusicArr; @property (nonatomic, strong) NSArray *courseMusicArr;
/// 类型数据
@property (nonatomic, strong) NSArray *typeArr;
@end @end
@implementation DSHomeView @implementation DSHomeView
- (instancetype)init { - (instancetype)init {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain]) { if (self = [super initWithFrame:CGRectMake(0, kTopHeight(0), kScreenWidth, kScreenHeight - kTopHeight(0) - kTabBarHeight) style:UITableViewStylePlain]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.separatorStyle = UITableViewCellSeparatorStyleNone; self.separatorStyle = UITableViewCellSeparatorStyleNone;
self.showsVerticalScrollIndicator = NO; self.showsVerticalScrollIndicator = NO;
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[self registerClass:[CourseMusicCell class] forCellReuseIdentifier:NSStringFromClass([CourseMusicCell class])]; [self registerClass:[CourseMusicCell class] forCellReuseIdentifier:NSStringFromClass([CourseMusicCell class])];
[self registerClass:[GoodSleepSoundCell class] forCellReuseIdentifier:NSStringFromClass([GoodSleepSoundCell class])]; [self registerClass:[GoodSleepSoundCell class] forCellReuseIdentifier:NSStringFromClass([GoodSleepSoundCell class])];
self.tableHeaderView = self.headerView; self.tableHeaderView = self.headerView;
...@@ -41,6 +44,16 @@ ...@@ -41,6 +44,16 @@
[cell updateCourseMusicListWithData:dataArr cellIndex:index]; [cell updateCourseMusicListWithData:dataArr cellIndex:index];
} }
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr {
if (typeDataArr && typeDataArr.count > 0) {
self.typeArr = typeDataArr;
}
GoodSleepSoundCell *cell = (GoodSleepSoundCell *)[self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
if (cell) {
[cell updateNoiseAllTypeData:typeDataArr];
}
}
- (NSString *)cellIdentiferAtIndexPath:(NSIndexPath *)indexPath { - (NSString *)cellIdentiferAtIndexPath:(NSIndexPath *)indexPath {
SafeSleepModel *item = self.courseMusicArr[indexPath.row]; SafeSleepModel *item = self.courseMusicArr[indexPath.row];
if (item.type == CellTypeGood) { if (item.type == CellTypeGood) {
...@@ -54,6 +67,11 @@ ...@@ -54,6 +67,11 @@
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
HomeBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:[self cellIdentiferAtIndexPath:indexPath] forIndexPath:indexPath]; HomeBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:[self cellIdentiferAtIndexPath:indexPath] forIndexPath:indexPath];
[cell configBasicData:self.courseMusicArr[indexPath.row] cellIndex:indexPath.row]; [cell configBasicData:self.courseMusicArr[indexPath.row] cellIndex:indexPath.row];
if (indexPath.row == 2) {
GoodSleepSoundCell *goodCell = (GoodSleepSoundCell *)cell;
[goodCell updateNoiseAllTypeData:self.typeArr];
}
return cell; return cell;
} }
...@@ -66,7 +84,9 @@ ...@@ -66,7 +84,9 @@
if (indexPath.row == 0) { if (indexPath.row == 0) {
height = 206; height = 206;
} else if (indexPath.row == 1) { } else if (indexPath.row == 1) {
height = 196; height = 206;
} else if (indexPath.row == 2) {
height = 68 + 40 + 327;
} }
return height; return height;
} }
...@@ -108,4 +128,11 @@ ...@@ -108,4 +128,11 @@
return _courseMusicArr; return _courseMusicArr;
} }
- (NSArray *)typeArr {
if (!_typeArr) {
_typeArr = [NSArray array];
}
return _typeArr;
}
@end @end
...@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 好眠声音cell /// 好眠声音cell
@interface GoodSleepSoundCell : HomeBasicCell @interface GoodSleepSoundCell : HomeBasicCell
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
// //
#import "GoodSleepSoundCell.h" #import "GoodSleepSoundCell.h"
#import "NoiseListController.h"
#import "NoiseTypeModel.h"
#import "NoiseView.h"
@interface GoodSleepSoundCell () @interface GoodSleepSoundCell ()
@property (nonatomic, strong) UIButton *timerBtn; @property (nonatomic, strong) UIButton *timerBtn;
@property (nonatomic, strong) NoiseView *noiseView;
@end @end
@implementation GoodSleepSoundCell @implementation GoodSleepSoundCell
...@@ -16,6 +20,7 @@ ...@@ -16,6 +20,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.contentView addSubview:self.timerBtn]; [self.contentView addSubview:self.timerBtn];
[self.contentView addSubview:self.noiseView];
[self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-5); make.right.equalTo(self.contentView.mas_right).offset(-5);
...@@ -23,13 +28,20 @@ ...@@ -23,13 +28,20 @@
make.height.equalTo(@30); make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY); make.centerY.equalTo(self.verticalView.mas_centerY);
}]; }];
[self.noiseView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.timerBtn.mas_bottom).offset(5);
make.left.right.bottom.equalTo(self.contentView);
}];
} }
return self; return self;
} }
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr {
[self.noiseView refreshNoiseTypeData:typeDataArr];
}
#pragma mark - Actions #pragma mark - Actions
- (void)timerSetting:(UIButton *)sender { - (void)timerSetting:(UIButton *)sender {
DSLog(@"66666:%ld", self.model.type);
DSLog(@"timerSetting"); DSLog(@"timerSetting");
} }
...@@ -43,4 +55,11 @@ ...@@ -43,4 +55,11 @@
return _timerBtn; return _timerBtn;
} }
- (NoiseView *)noiseView {
if (!_noiseView) {
_noiseView = [[NoiseView alloc] initWithNoiseTypeData:@[]];
}
return _noiseView;
}
@end @end
//
// NoiseAudioCell.h
// DreamSleep
//
// Created by peter on 2022/5/13.
//
#import <UIKit/UIKit.h>
#import "NoiseAudioModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 白噪音小音频cell
@interface NoiseAudioCell : UICollectionViewCell
@property (nonatomic, strong) UIButton *audioIV;
@property (nonatomic, strong) NoiseAudioModel *model;
@end
NS_ASSUME_NONNULL_END
//
// NoiseAudioCell.m
// DreamSleep
//
// Created by peter on 2022/5/13.
//
#import "NoiseAudioCell.h"
@interface NoiseAudioCell ()
@property (nonatomic, strong) UILabel *nameLab;
@end
@implementation NoiseAudioCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self.contentView addSubview:self.audioIV];
[self.contentView addSubview:self.nameLab];
[self.audioIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.contentView).offset(5);
make.size.mas_equalTo(CGSizeMake(30, 30));
}];
}
return self;
}
- (void)setModel:(NoiseAudioModel *)model {
_model = model;
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:model.audio_img] forState:UIControlStateNormal placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:model.audio_pic] forState:UIControlStateSelected placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
self.nameLab.text = model.audio_name;
[self.nameLab sizeToFit];
[self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.audioIV.mas_bottom).offset(3);
make.centerX.equalTo(self.audioIV);
}];
}
#pragma mark - lazy
- (UIButton *)audioIV {
if (!_audioIV) {
_audioIV = [UIButton new];
_audioIV.userInteractionEnabled = NO;
_audioIV.imageView.contentMode = UIViewContentModeScaleAspectFit;
_audioIV.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
_audioIV.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
}
return _audioIV;
}
- (UILabel *)nameLab {
if (!_nameLab) {
_nameLab = [UILabel labWithFont:SysFont(12.0)];
_nameLab.textAlignment = NSTextAlignmentCenter;
_nameLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite);
}
return _nameLab;
}
@end
//
// NoiseAudioModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音音频数据model
@interface NoiseAudioModel : NSObject
// 白噪音音频id
@property (nonatomic, assign) int noise_audio_id;
// 名称
@property (nonatomic, copy) NSString *audio_name;
// 未选中图标
@property (nonatomic, copy) NSString *audio_img;
// 选中图标
@property (nonatomic, copy) NSString *audio_pic;
// 音频链接
@property (nonatomic, copy) NSString *audio_url;
// 是否推荐(默认0:不推荐,1:推荐)
@property (nonatomic, copy) NSString *is_recommend;
@end
NS_ASSUME_NONNULL_END
//
// NoiseAudioModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseAudioModel.h"
@implementation NoiseAudioModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"noise_audio_id" : @"id"};
}
@end
//
// NoiseListController.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音列分页
@interface NoiseListController : UIViewController
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID;
@end
NS_ASSUME_NONNULL_END
//
// NoiseListController.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseListController.h"
#import "WhiteNoiseRequestModel.h"
#import "NoiseAudioCell.h"
@interface NoiseListController () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *noiseAudioView;
@property (nonatomic, strong) NSArray *noiseAudioArr;
@end
@implementation NoiseListController {
NSInteger _typeID;
}
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID {
if (self = [super init]) {
_typeID = typeID;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.noiseAudioView];
self.view.backgroundColor = _typeID == 32 ? BrandColor : DSRed;
[WhiteNoiseRequestModel queryRelaxWhiteNoiseAudiosWithTypeID:_typeID completion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.noiseAudioArr = requestModel.noiseAudioArr;
[self.noiseAudioView reloadData];
}
}];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.noiseAudioArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath];
cell.model = self.noiseAudioArr[indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// NoiseAudioModel *model = [self.noiseAudioArr objectAtIndex:indexPath.row];
NoiseAudioCell *cell = (NoiseAudioCell *)[collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]];
cell.audioIV.selected = !cell.audioIV.selected;
}
#pragma mark - lazy
- (UICollectionView *)noiseAudioView {
if (!_noiseAudioView) {
CGFloat space = (kScreenWidth - 240 - 66)/3.0;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(15, 33, 0, 33);
layout.itemSize = CGSizeMake(60, 53);
layout.minimumLineSpacing = 12;
layout.minimumInteritemSpacing = space;
_noiseAudioView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 327) collectionViewLayout:layout];
_noiseAudioView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
_noiseAudioView.delegate = self;
_noiseAudioView.dataSource = self;
[_noiseAudioView registerClass:[NoiseAudioCell class] forCellWithReuseIdentifier:@"NoiseAudioCellID"];
}
return _noiseAudioView;
}
- (NSArray *)noiseAudioArr {
if (!_noiseAudioArr) {
_noiseAudioArr = [NSArray array];
}
return _noiseAudioArr;
}
@end
//
// NoiseTypeModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音类型数据model
@interface NoiseTypeModel : NSObject
/// 白噪音分类id
@property (nonatomic, assign) int type_id;
/// 分类名称
@property (nonatomic, copy) NSString *sub_name;
/// 是否上锁(1:加锁,0:不加锁)
@property (nonatomic, assign) int is_lock;
#pragma mark - 自定义属性
/// 是否被选中
@property (nonatomic, assign) BOOL isSelected;
/// 解锁、未解锁、选中等状态宽度
@property (nonatomic, assign) CGFloat typeWidth;
- (void)calculateWidth;
@end
NS_ASSUME_NONNULL_END
//
// NoiseTypeModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseTypeModel.h"
@implementation NoiseTypeModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"type_id" : @"id"};
}
- (void)setIsSelected:(BOOL)isSelected {
_isSelected = isSelected;
}
- (void)setTypeWidth:(CGFloat)typeWidth {
_typeWidth = typeWidth;
}
- (void)calculateWidth {
// 获取文字宽度
UILabel *lab = [UILabel labWithText:self.sub_name font:(self.isSelected ? BoldFont(15.0) : SysFont(14.0)) fit:YES];
// 图片宽度
CGFloat iconW = self.is_lock == 1 ? 20 : 0;
self.typeWidth = lab.width + iconW;
}
@end
//
// NoiseView.h
// DreamSleep
//
// Created by peter on 2022/5/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/**
下划线长度取值类型
- LineWidthTypeStaticShort: 静态短长度,取个固定短值
- LineWidthTypeStaticLong: 静态长度,根据总长度/数量
- LineWidthTypeDynamic: 动态长度,根据文字长度
*/
typedef NS_ENUM(NSInteger, LineWidthType) {
LineWidthTypeStaticShort = 0,
LineWidthTypeStaticLong,
LineWidthTypeDynamic
};
/**
分页条目 cell 宽度取值类型
- PageCellWidthTypeWithTitleLength: 根据 cell 标题文字长度取值
- PageCellWidthTypeSplitScreen: pageCell个数小于屏宽最大cell展示个数时,按个数平分屏宽
- PageCellWidthTypeWidthByStaticCount: 根据屏宽最大cell展示个数平分屏宽
*/
typedef NS_ENUM(NSInteger, PageCellWidthType) {
PageCellWidthTypeByTitleLength = 0,
PageCellWidthTypeSplitScreen,
PageCellWidthTypeWidthByStaticCount
};
/**
下划线在条目切换时的动态表现类型
- LineScrollTypeDynamicAnimation: 滑动即时的下划线动态动画
- LineScrollTypeDynamicLinear: 滑动即时的下划线线性动画
- LineScrollTypeFinishedLinear: 滑动完成后的下划线线性动画
*/
typedef NS_ENUM(NSInteger, LineScrollType) {
LineScrollTypeDynamicAnimation = 0,
LineScrollTypeDynamicLinear,
LineScrollTypeScrollEndLinear
};
/** 分页滑动时标题字体大小改变方式
- PageTitleFontChangeTypeScrolling: 滑动中实时改变
- PageTitleFontChangeTypeScrollEnd: 滑动结束无动画改变
- PageTitleFontChangeTypeScrollEndAnimation: 滑动结束动画改变
*/
typedef NS_ENUM(NSInteger, PageTitleFontChangeType) {
PageTitleFontChangeTypeScrolling = 0,
PageTitleFontChangeTypeScrollEnd,
PageTitleFontChangeTypeScrollEndAnimation
};
/** 分页滑动时标题颜色改变方式
- PageTitleColorChangeTypeScrolling: 滑动中实时改变
- PageTitleColorChangeTypeScrollEnd: 滑动结束改变
*/
typedef NS_ENUM(NSInteger, PageTitleColorChangeType) {
PageTitleColorChangeTypeScrolling = 0,
PageTitleColorChangeTypeScrollEnd
};
/// 首页白噪音自定义view
@interface NoiseView : UIView
/// 配置分页类型数据
/// @param data data
- (void)refreshNoiseTypeData:(NSArray *)data;
/// 初始化
/// @param data data
- (instancetype)initWithNoiseTypeData:(NSArray *)data;
/** 分页条高度 */
@property(nonatomic, assign) CGFloat pageBarHeight;
/** 分页条背景色 */
@property (nonatomic,strong) UIColor *pageBarBgColor;
/** 下滑线颜色 */
@property (nonatomic,strong) UIColor *lineColor;
/** 下滑线颜色数组 */
@property (nonatomic,strong) NSArray *lineColors;
/** 下滑线高度 */
@property (nonatomic,assign) CGFloat lineHeight;
/** 下划线固定宽度: lineWidthType=LineWidthTypeStaticShort时设置,其他类型自动计算 */
@property (nonatomic,assign) CGFloat lineStaticWidth;
/** 分页工具条在展示区域的条目数量展示最大值: 在导航条上时默认值4,在一屏宽度上时默认值5 */
@property (nonatomic,assign) NSInteger maxPagesCountInPageShowArea;
/** 下划线长度取值类型 */
@property (nonatomic,assign) LineWidthType lineWidthType;
/** 下划线在条目切换时的动态表现类型 */
@property (nonatomic,assign) LineScrollType lineScrollType;
/** 分页条目 cell 宽度取值类型 */
@property (nonatomic,assign) PageCellWidthType pageCellWidthType;
/** 分页滑动时标题字体大小改变方式 */
@property (nonatomic,assign) PageTitleFontChangeType pageTitleFontChangeType;
/** 分页滑动时标题颜色改变方式 */
@property (nonatomic,assign) PageTitleColorChangeType pageTitleColorChangeType;
/** 标题颜色 */
@property (nonatomic,strong) UIColor *titleColor;
/** 标题选中颜色(可不设置) */
@property (nonatomic,strong) UIColor *titleSelectedColor;
/** 标题字体, default: [UIFont systemFontOfSize:15] */
@property (nonatomic,strong) UIFont *titleFont;
/** 标题选中字体(可不设置), default: [UIFont systemFontOfSize:20] */
@property (nonatomic,strong) UIFont *titleSelectedFont;
/** 默认选择的 index 位置 ,默认值为0*/
@property (nonatomic,assign) NSInteger defaultIndex;
/** 分页控制器View视图的 Y 轴方向 设置初始位置(适用于分页条不在导航条上的情况) , 动态位置由于UICollectionViewCell 的复用存在不可知 bug, 暂不实现*/
@property (nonatomic, assign) CGFloat originY;
@end
NS_ASSUME_NONNULL_END
//
// NoiseView.m
// DreamSleep
//
// Created by peter on 2022/5/12.
//
#import "NoiseView.h"
#import "NoiseTypeModel.h"
#import "NoiseAudioModel.h"
#import "NoiseListController.h"
#import "WhiteNoiseRequestModel.h"
@interface PopEnabeldCollectionView : UICollectionView
@end
@implementation PopEnabeldCollectionView
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
//处理横向滚动的scrollView和系统pop手势返回冲突
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")] && otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) return YES;
return NO;
}
@end
@class XXPageItemCell;
@protocol XXPageItemCellDelegate <NSObject>
- (void)pageItemCell:(XXPageItemCell *)pageItemCell didSelectItemAtIndex:(NSInteger)index;
@end
@interface XXPageItemCell : UIView
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *lockIcon;
@property (nonatomic, assign) NSInteger titleIndex;
@property (nonatomic, weak) id<XXPageItemCellDelegate> delegate;
@end
@implementation XXPageItemCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleClick)];
[self addGestureRecognizer:tap];
_titleLabel = [UILabel new];
_titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_titleLabel];
self.lockIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"dk_ic_voice_lock_unselected", @"dk_ic_voice_lock_unselected", @"dk_ic_voice_lock_unselected")];
[self addSubview:self.lockIcon];
}
return self;
}
- (void)titleClick {
if ([self.delegate respondsToSelector:@selector(pageItemCell:didSelectItemAtIndex:)]) {
[self.delegate pageItemCell:self didSelectItemAtIndex:self.titleIndex];
}
}
- (void)refreshTypeCell:(NoiseTypeModel *)typeModel idx:(NSInteger)idx isSelected:(BOOL)isSelected {
self.titleLabel.text = typeModel.sub_name;
self.titleLabel.font = isSelected ? BoldFont(15.0) : SysFont(14.0);
[self.titleLabel sizeToFit];
UIColor *normalColor = isSelected ? MainTextColor : SubTitleColor;
UIColor *dkColor = isSelected ? ColorFromHex(0xE8E9E9) : ColorFromHexA(0xFFFFFF, .5);
self.titleLabel.dk_textColorPicker = DKColorPickerWithColors(normalColor, dkColor, dkColor);
BOOL isLock = typeModel.is_lock == 1;
self.lockIcon.hidden = !isLock;
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
if (isLock) {
make.left.equalTo(self).offset(12.5);
} else {
make.centerX.equalTo(self);
}
make.top.equalTo(self).offset(10);
}];
[self.lockIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel.mas_right);
make.centerY.equalTo(self.titleLabel);
}];
}
@end
@interface NoiseView () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, XXPageItemCellDelegate>
/** 分页条滑动的下滑线 */
@property (readonly, nonatomic, strong) UIView *line;
/** 下滑线宽度 */
@property (nonatomic, assign) CGFloat lineWidth;
/** 是否将分页工具条创建在NavigationBar上 */
@property (nonatomic, assign) BOOL onNavigationBar;
/** 分页工具条 */
@property (nonatomic, strong) UIScrollView *scrollViewPage;
/** 主collection视图 */
@property (nonatomic, weak) PopEnabeldCollectionView *collectionMain;
/** 分页工具条的总宽度 */
@property (nonatomic, assign) CGFloat pageMenuW;
/** 分页工具条上每个 cell 的宽度 */
@property (nonatomic, assign) CGFloat pageCellW;
/** 分页工具条上每个 cell 的宽度集合 */
@property (nonatomic, strong) NSMutableArray *pageCellWs;
/** 分页工具条 cell 集合 */
@property (nonatomic, strong) NSMutableArray *pageCells;
@property (nonatomic, strong) NSArray <NoiseTypeModel *> *pageTypes;
@property (nonatomic, strong) NSArray *controllersClass;
@property (nonatomic, strong) NSArray *controllers;
@property (nonatomic, strong) NSArray *icons;
/** 当前选中的 index 位置 */
@property (nonatomic, assign) NSInteger selectedIndex;
/** 点击didSelectItemAtIndexPath:方法的标记 */
@property (nonatomic,assign) BOOL didSelectCollectionPageItem;
@end
@implementation NoiseView
#define kAnimateDuration 0.3
static NSString *mainCell = @"inxx_mainCell";
- (instancetype)initWithNoiseTypeData:(NSArray *)data {
if (self = [super init]) {
self.pageTypes = data;
self.controllersClass = @[];
self.selectedIndex = 0;
}
return self;
}
- (void)refreshNoiseTypeData:(NSArray *)data {
if (!data || data.count == 0) {
return;
}
self.onNavigationBar = NO;
self.pageTypes = data;
NSMutableArray *tmpVCArr = [NSMutableArray array];
for (int i = 0; i < self.pageTypes.count; i++) {
NoiseTypeModel *typeModel = self.pageTypes[i];
NoiseListController *list = [[NoiseListController alloc] initWithNoiseTypeID:typeModel.type_id];
list.view.frame = CGRectMake(0, 0, self.collectionMain.width, self.collectionMain.height);
[tmpVCArr addObject:list];
}
self.controllersClass = [tmpVCArr copy];
[self configProperties];
[self addScrollViewPage];
[self addCollectionMain];
[self addPageBottomLine];
[self addObserver:self forKeyPath:@"selectedIndex" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
//1. 更新下划线的frame
[self updateLineFrameWithIndex:self.selectedIndex];
//2. 更新collection page的显示index 位置
[self updateCurrentScrollViewPageContentOffsetByIndex:self.selectedIndex];
//3. 更新collection main的显示index 位置
[self.collectionMain scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.selectedIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
// for (int i = 0; i < data.count; i++) {
// NoiseTypeModel *typeModel = data[i];
// if (i == 0) { typeModel.isSelected = YES; }
// }
// self.pageTypes = data;
// self.selectedIndex = 0;
//
// [self config];
//
// if (self.scrollViewPage) { [self.scrollViewPage removeFromSuperview]; }
// [self addScrollViewPage];
// [self addSubview:self.bodyPageView];
// [self.scrollViewPage mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.left.right.equalTo(self);
// make.height.equalTo(@40);
// }];
// [self.bodyPageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.equalTo(self.scrollViewPage.mas_bottom);
// make.left.bottom.right.equalTo(self);
// }];
// [self addPageBottomLine];
// [self updateLineFrameWithIndex:self.selectedIndex];
//
// [self addObserver:self forKeyPath:@"selectedIndex" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
}
- (void)configProperties {
//init default value
_pageBarHeight = _onNavigationBar ? 40 : (_pageBarHeight ?: 40);
_pageBarBgColor = _pageBarBgColor ? : [UIColor whiteColor];
_lineColor = _lineColor ? : BrandColor;
_lineColors = _lineColors ?: _lineColors;
_lineHeight = _lineHeight ? : 4;
_lineStaticWidth = _lineStaticWidth ?: 8;
_maxPagesCountInPageShowArea = _maxPagesCountInPageShowArea ?: (_onNavigationBar ? 4 : 5);
_titleFont = _titleFont ? : SysFont(14.0);
_titleSelectedFont = _titleSelectedFont ?: BoldFont(15.0);
_titleColor = _titleColor ? : MainTextColor;
_titleSelectedColor = _titleSelectedColor ?: MainTextColor;
_pageMenuW = _onNavigationBar ? (kScreenWidth - 120) : kScreenWidth; //120为预估的左右navigationItem的总宽度
if (_pageCellWidthType == PageCellWidthTypeSplitScreen) {
//根据titles.count平分宽度
_pageCellW = (_pageTypes.count <= _maxPagesCountInPageShowArea) ? _pageMenuW / _pageTypes.count : _pageMenuW / _maxPagesCountInPageShowArea;
} else if (_pageCellWidthType == PageCellWidthTypeWidthByStaticCount) {
//根据_maxPagesCountInPageShowArea平分宽度
_pageCellW = _pageMenuW / _maxPagesCountInPageShowArea;
} else if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
//根据title长度取cell动态宽度, 初始化宽度值数组
_pageCellWs = [NSMutableArray array];
NSInteger showCount = 0;
CGFloat sumWidth = 0;
for (NoiseTypeModel *typeModel in self.pageTypes) {
// 获取文字宽度
UILabel *lab1 = [UILabel labWithText:typeModel.sub_name font:SysFont(14.0) fit:YES];
UILabel *lab2 = [UILabel labWithText:typeModel.sub_name font:BoldFont(15.0) fit:YES];
CGFloat width1 = lab1.width + 25;
CGFloat width2 = lab2.width; //n防止有少数过长标题时滑动异常
CGFloat width = MAX(width1, width2);
if (typeModel.is_lock == 1) {
width += 20;
}
sumWidth += width;
if (sumWidth < _pageMenuW) {
showCount++;
}
[_pageCellWs addObject:@(width)]; //保存每个动态宽度
}
_maxPagesCountInPageShowArea = showCount;
}
self.selectedIndex = _defaultIndex;
}
- (void)addScrollViewPage {
CGRect frame = CGRectMake(0, 0, _pageMenuW, _pageBarHeight);
UIScrollView *scrollViewPage = [[UIScrollView alloc] initWithFrame:frame];
scrollViewPage.showsVerticalScrollIndicator = NO;
scrollViewPage.showsHorizontalScrollIndicator = NO;
scrollViewPage.delegate = self;
scrollViewPage.backgroundColor = _pageBarBgColor;
[self addSubview:scrollViewPage];
CGFloat contentWidth = 0;
if (_pageCellWidthType != PageCellWidthTypeByTitleLength) {
contentWidth = _pageCellW * _pageTypes.count;
} else {
contentWidth = [[_pageCellWs valueForKeyPath:@"@sum.floatValue"] floatValue];
}
scrollViewPage.contentSize = CGSizeMake(contentWidth, _pageBarHeight);
_pageCells = [NSMutableArray array];
__block CGFloat currentX = 0;
[self.pageTypes enumerateObjectsUsingBlock:^(NoiseTypeModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
CGFloat pageCellW = _pageCellW;
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
pageCellW = [self.pageCellWs[idx] floatValue];
}
CGRect frame = CGRectMake(currentX, 0, pageCellW, _pageBarHeight);
currentX += pageCellW;
XXPageItemCell *pageItemCell = [[XXPageItemCell alloc] initWithFrame:frame];
pageItemCell.titleIndex = idx;
pageItemCell.delegate = self;
BOOL selected = (idx == self.selectedIndex); //是否被选中
[pageItemCell refreshTypeCell:obj idx:idx isSelected:selected];
// [pageItemCell.titleLabel setText:obj.sub_name];
// [pageItemCell.titleLabel setTextColor:(selected ? _titleSelectedColor : _titleColor)];
// [pageItemCell.titleLabel setFont:(selected ? _titleSelectedFont : _titleFont)];
[scrollViewPage addSubview:pageItemCell];
[_pageCells addObject:pageItemCell];
}];
self.scrollViewPage = scrollViewPage;
}
CGRect childFrame;
- (void)addCollectionMain {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
CGFloat y = _onNavigationBar ? 0 : _pageBarHeight;
layout.itemSize = CGSizeMake(_pageMenuW, 327);
CGRect frame = CGRectMake(0, y, layout.itemSize.width, layout.itemSize.height);
PopEnabeldCollectionView *collection = [[PopEnabeldCollectionView alloc] initWithFrame:frame collectionViewLayout:layout];
collection.backgroundColor = [UIColor whiteColor];
collection.dataSource = self;
collection.delegate = self;
collection.pagingEnabled = YES;
collection.scrollEnabled = [LoginUtils getUserLoginData];
collection.bounces = NO; //禁止左右弹簧拉伸
collection.showsHorizontalScrollIndicator = NO;
[collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:mainCell];
self.collectionMain = collection;
[self addSubview:collection];
[self bringSubviewToFront:self.collectionMain];
// childFrame = frame;
// for (UIViewController *childVc in self.controllersClass) {
// //子控制器的frame.origin.y肯定要从其自己的0开始
// childFrame.origin.y = 0;
// childVc.view.frame = childFrame;
// }
}
- (void)addPageBottomLine {
_line = [UIView new];
_line.backgroundColor = _lineColor;
[_line cornerRadius:2.0];
[self.scrollViewPage addSubview:_line];
}
//- (void)updateLineFrameWithIndex:(NSInteger)index {
// _lineWidth = [self lineWidthWithsSelectedIndex:index];
// _line.frame = CGRectMake(0, _pageBarHeight - 9, _lineWidth, _lineHeight);
// CGFloat width = [self lineCenterXWithIndex:index];
// _line.center = CGPointMake(width, _pageBarHeight - 4/2);
//}
//
//- (CGFloat)lineCenterXWithIndex:(NSInteger)index {
// __block CGFloat centerX = 0;
// [self.pageTypes enumerateObjectsUsingBlock:^(NoiseTypeModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
// if (idx < index) {
// centerX = centerX + [_pageCellWs[idx] floatValue];
// } else {
// centerX = centerX + [_pageCellWs[idx] floatValue]/2;
// *stop = YES;
// }
// }];
// return centerX;
//}
//
//- (CGFloat)lineWidthWithsSelectedIndex:(NSInteger)index {
// self.selectedIndex = index;
// NoiseTypeModel *model = self.pageTypes[index];
// CGFloat adaptIconW = model.is_lock == 1 ? 20 : 0;
// UILabel *lab2 = [UILabel labWithText:model.sub_name font:BoldFont(15.0) fit:YES];
// CGFloat _lineWidth = lab2.width + adaptIconW;
// return _lineWidth;
//}
/** 更新/设置 下划线的 frame */
- (void)updateLineFrameWithIndex:(NSInteger)index {
_lineWidth = [self lineWidthWithsSelectedIndex:index];
_line.frame = CGRectMake(0, _pageBarHeight - _lineHeight, _lineWidth, _lineHeight);
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
CGFloat width = [self lineCenterXWithIndex:index];
_line.center = CGPointMake(width, _pageBarHeight - _lineHeight/2);
} else {
_line.center = CGPointMake((index * _pageCellW) + _pageCellW/2, _pageBarHeight - _lineHeight/2);
}
if (_lineColors) {
//_line.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleLeftToRight withFrame:_line.bounds andColors:_lineColors];
}
}
- (CGFloat)lineCenterXWithIndex:(NSInteger)index {
__block CGFloat centerX = 0;
[_pageTypes enumerateObjectsUsingBlock:^(NoiseTypeModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (idx < index) {
centerX = centerX + [_pageCellWs[idx] floatValue];
} else {
centerX = centerX + [_pageCellWs[idx] floatValue]/2;
*stop = YES;
}
}];
return centerX;
}
- (CGFloat)lineWidthWithsSelectedIndex:(NSInteger)index {
self.selectedIndex = index;
NoiseTypeModel *model = self.pageTypes[index];
CGFloat adaptIconW = model.is_lock == 1 ? 20 : 0;
UILabel *lab2 = [UILabel labWithText:model.sub_name font:BoldFont(15.0) fit:YES];
CGFloat _lineWidth = lab2.width + adaptIconW;
return _lineWidth;
}
#pragma mark - KVO
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"selectedIndex"]) {
NSInteger oldIndex = [[change objectForKey:NSKeyValueChangeOldKey] integerValue];
NSInteger newIndex = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
if (newIndex != oldIndex) {
[self reloadCollectionPageCell:_pageCells[oldIndex] index:oldIndex selected:NO];
[self reloadCollectionPageCell:_pageCells[newIndex] index:newIndex selected:YES];
}
}
}
- (void)dealloc {
[self removeObserver:self forKeyPath:@"selectedIndex"];
}
///// 刷新 CollectionPage的Cell 数据
///// @param selected 待刷新cell是否被选中
//- (void)reloadCollectionPageCell:(XXPageItemCell *)cell index:(NSInteger)index selected:(BOOL)selected {
// UILabel *titleLabel = cell.titleLabel;
// NoiseTypeModel *typeModel = self.pageTypes[index];
// UILabel *lab1 = [UILabel labWithText:typeModel.sub_name font:SysFont(14.0) fit:YES];
// UILabel *lab2 = [UILabel labWithText:typeModel.sub_name font:BoldFont(15.0) fit:YES];
// CGFloat scale = selected ? lab2.width/lab1.width : lab1.width/lab2.width;
// [UIView animateWithDuration:.3 animations:^{
// titleLabel.transform = CGAffineTransformMakeScale(scale, scale);
// } completion:^(BOOL finished) {
// //缩放结束后重置transform, 并设置当前对应的字体大小. 这样就能避免transform从小到大时字体模糊
// titleLabel.transform = CGAffineTransformIdentity;
// [titleLabel setFont:(selected ? self->_titleSelectedFont : self->_titleFont)];
// }];
// NoiseTypeModel *model = self.pageTypes[index];
// model.isSelected = selected;
// [cell refreshTypeCell:model idx:index];
//}
/// 刷新 CollectionPage的Cell 数据
/// @param selected 待刷新cell是否被选中
- (void)reloadCollectionPageCell:(XXPageItemCell *)cell index:(NSInteger)index selected:(BOOL)selected {
UILabel *titleLabel = nil;
titleLabel = cell.titleLabel;
//title font 的改变方式: 滑动结束动画改变 || 点击didSelectItemAtIndexPath:方法
if (_pageTitleFontChangeType == PageTitleFontChangeTypeScrollEndAnimation || _didSelectCollectionPageItem) {
CGFloat scale = selected ? _titleSelectedFont.pointSize/_titleFont.pointSize : _titleFont.pointSize/_titleSelectedFont.pointSize;
[UIView animateWithDuration:kAnimateDuration animations:^{
titleLabel.transform = CGAffineTransformMakeScale(scale, scale);
} completion:^(BOOL finished) {
//缩放结束后重置transform, 并设置当前对应的字体大小. 这样就能避免transform从小到大时字体模糊
titleLabel.transform = CGAffineTransformIdentity;
[titleLabel setFont:(selected ? self->_titleSelectedFont : self->_titleFont)];
}];
} else {
[titleLabel setFont:(selected ? _titleSelectedFont : _titleFont)];
}
NoiseTypeModel *model = self.pageTypes[index];
// [titleLabel setText:model.sub_name];
// [titleLabel setTextColor:(selected ? _titleSelectedColor : _titleColor)];
[cell refreshTypeCell:model idx:index isSelected:selected];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.pageTypes.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:mainCell forIndexPath:indexPath];
NoiseListController *childVC = self.controllersClass[indexPath.row];
childVC.view.frame = cell.contentView.bounds;
[cell.contentView addSubview:childVC.view];
return cell;
}
- (void)sendUpdateRequest {
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self refreshNoiseTypeData:requestModel.noiseTypeArr];
}
}];
}
#pragma mark - XXPageItemCellDelegate
- (void)pageItemCell:(XXPageItemCell *)pageItemCell didSelectItemAtIndex:(NSInteger)index {
NoiseTypeModel *typeModel = self.pageTypes[index];
if (typeModel.is_lock == 1) {
[LoginUtils jumpToLoginControllerWithTarget:self.ds_viewController selector:@selector(sendUpdateRequest)];
return;
}
_didSelectCollectionPageItem = YES;
BOOL needReset = NO;
LineScrollType lineScrollType = _lineScrollType;
PageTitleFontChangeType titleFontChangeType = _pageTitleFontChangeType;
PageTitleColorChangeType titleColorChangeType = _pageTitleColorChangeType;
if ((_lineScrollType != LineScrollTypeScrollEndLinear)) {
_lineScrollType = LineScrollTypeScrollEndLinear;
needReset = YES;
}
if (_pageTitleFontChangeType != PageTitleFontChangeTypeScrollEnd) {
_pageTitleFontChangeType = PageTitleFontChangeTypeScrollEnd;
needReset = YES;
}
if (_pageTitleColorChangeType != PageTitleColorChangeTypeScrollEnd) {
_pageTitleColorChangeType = PageTitleColorChangeTypeScrollEnd;
needReset = YES;
}
[UIView animateWithDuration:kAnimateDuration animations:^{
//ABS(self.selectedIndex - indexPath.item)>1 表示跨越至少 2 个 index 移动
[self updateLineFrameWithIndex:index] ;
} completion:^(BOOL finished) {
if (needReset) { //复位
self->_lineScrollType = lineScrollType;
self->_pageTitleFontChangeType = titleFontChangeType;
self->_pageTitleColorChangeType = titleColorChangeType;
}
self->_didSelectCollectionPageItem = NO;
}];
[self updateCurrentScrollViewPageContentOffsetByIndex:index];
[self.collectionMain scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
}
static float oldOffsetX;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (_didSelectCollectionPageItem) return;
if (scrollView == self.collectionMain) {
// 处理working中的2个分页标题底部线性指示器的实时属性
[self changePageLinePropertyiesWithSrollX:scrollView.contentOffset.x];
//处理working中的2个分页标题的实时属性
[self changePageTitlePropertyiesWithSrollX:scrollView.contentOffset.x];
}
}
/// 处理working中的2个分页标题底部线性指示器的实时属性
/// @param x SrollX
- (void)changePageLinePropertyiesWithSrollX:(CGFloat)x {
//需要随滑动而改变UI样式:LineScrollTypeDynamicAnimation/LineScrollTypeDynamicLinear
if (_lineScrollType == LineScrollTypeDynamicAnimation || _lineScrollType == LineScrollTypeDynamicLinear) {
int lineIndex = (x + kScreenWidth*0.5) / kScreenWidth; ///< 线指示器滑动切换index基准选择: kScreenWidth*0.5(半屏) 过半屏 index 值会+1
CGFloat scrollRatio = fabs(x-kScreenWidth*lineIndex) / kScreenWidth; ///< 滑动比率 [0 ~ 0.5 ~ 0]
CGFloat changedW; ///< line动态改变的宽度
CGFloat centerX; ///< 线的实时滑动中心
//NSLog(@"scrollRatio - %.1f",scrollRatio);
BOOL toLeft = (x > oldOffsetX);
oldOffsetX = x;
if (toLeft) {
if ((x-kScreenWidth*lineIndex) > 0) { //未过半屏: 过半屏之后因为lineIndex = (x + kScreenWidth*0.5) / kScreenWidth 所以 lineIndex 值会+1
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
CGFloat chazhi = [_pageCellWs[lineIndex+1] floatValue] - [_pageCellWs[lineIndex] floatValue];
chazhi = 0;
changedW = [_pageCellWs[lineIndex] floatValue] * scrollRatio + [_pageCellWs[lineIndex+1] floatValue] * scrollRatio + chazhi * scrollRatio;
centerX = [self lineCenterXWithIndex:lineIndex] + changedW/2;
} else {
//保留减少消耗方案:每一个 cell 的宽度都是_pageCellW,是相等的, 不用去_pageCellWs数组里去取每个 _pageCellW 的值
changedW = _pageCellW * scrollRatio * 2;
//保留减少消耗方案: 每一个 cell 的宽度都是_pageCellW,是相等的, 省去了 for 循环计算宽度
centerX = lineIndex * _pageCellW + _pageCellW/2 + changedW/2;
}
}else{ //划过半屏, lineIndex 值会+1
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
CGFloat chazhi = [_pageCellWs[lineIndex] floatValue] - [_pageCellWs[lineIndex-1] floatValue];
chazhi = 0;
changedW = [_pageCellWs[lineIndex-1] floatValue] * scrollRatio + [_pageCellWs[lineIndex] floatValue] * scrollRatio - chazhi * scrollRatio;
centerX = [self lineCenterXWithIndex:lineIndex] - changedW/2;
} else {
changedW = _pageCellW * scrollRatio * 2;
centerX = lineIndex * _pageCellW + _pageCellW/2 - changedW/2;
}
}
}else{
if ((x-kScreenWidth*lineIndex) < 0) { //未过半屏
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
CGFloat chazhi = [_pageCellWs[lineIndex] floatValue] - [_pageCellWs[lineIndex-1] floatValue];
chazhi = 0;
changedW = [_pageCellWs[lineIndex-1] floatValue] * scrollRatio + [_pageCellWs[lineIndex] floatValue] * scrollRatio - chazhi * scrollRatio;
centerX = [self lineCenterXWithIndex:lineIndex] - changedW/2;
} else {
changedW = _pageCellW * scrollRatio * 2;
centerX = lineIndex * _pageCellW + _pageCellW/2 - changedW/2;
}
}else{ //划过半屏
if (_pageCellWidthType == PageCellWidthTypeByTitleLength) {
CGFloat chazhi = [_pageCellWs[lineIndex+1] floatValue] - [_pageCellWs[lineIndex] floatValue];
chazhi = 0;
changedW = [_pageCellWs[lineIndex] floatValue] * scrollRatio + [_pageCellWs[lineIndex+1] floatValue] * scrollRatio + chazhi * scrollRatio;
centerX = [self lineCenterXWithIndex:lineIndex] + changedW/2;
} else {
changedW = _pageCellW * scrollRatio * 2;
centerX = lineIndex * _pageCellW + _pageCellW/2 + changedW/2;
}
}
}
_lineWidth = [self lineWidthWithsSelectedIndex:lineIndex]; //根据 lineIndex 值判断的静态宽度
if (_lineScrollType == LineScrollTypeDynamicAnimation) {
_line.frame = CGRectMake(0, _pageBarHeight-_lineHeight, _lineWidth+changedW, _lineHeight);
} else if (_lineScrollType == LineScrollTypeDynamicLinear) {
_line.frame = CGRectMake(0, _pageBarHeight-_lineHeight, _lineWidth, _lineHeight);
}
_line.center = CGPointMake(centerX, _pageBarHeight-_lineHeight/2);
}
if (_lineColors) {
//_line.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleLeftToRight withFrame:_line.bounds andColors:_lineColors];
}
}
/// 处理working中的2个分页标题的实时属性
/// @param x SrollX
- (void)changePageTitlePropertyiesWithSrollX:(CGFloat)x {
//创建通用变量
int pageIndex = ABS(x) / kScreenWidth;
CGFloat xInScreen = x-kScreenWidth*pageIndex; //一屏内的位移距离
XXPageItemCell *oldCell = _pageCells[pageIndex];
XXPageItemCell *newCell = nil;
if (pageIndex+1 < _pageCells.count) {
newCell = _pageCells[pageIndex+1];
}
//滑动过程中字体实时改变的大小
if (_pageTitleFontChangeType == PageTitleFontChangeTypeScrolling && _titleSelectedFont.pointSize != _titleFont.pointSize) {
CGFloat fontRuntimeDifferenceSize = xInScreen/kScreenWidth*(_titleSelectedFont.pointSize-_titleFont.pointSize);
//此方案会有抖动,效果不太完美
//oldCell.titleLabel.font = [UIFont fontWithDescriptor:oldCell.titleLabel.font.fontDescriptor size:_titleSelectedFont.pointSize-fontRuntimeDifferenceSize];
//newCell.titleLabel.font = [UIFont fontWithDescriptor:newCell.titleLabel.font.fontDescriptor size:_titleFont.pointSize+fontRuntimeDifferenceSize];
//transform形变稳定防抖动处理
//避免transform从小到大时字体模糊: 先把font设置为缩放的最大值,再缩小到最小值,最后根据当前的titleLabelZoomScale值,进行缩放更新
newCell.titleLabel.font = _titleSelectedFont;
oldCell.titleLabel.font = _titleSelectedFont;
CGFloat baseScale = _titleFont.lineHeight/_titleSelectedFont.lineHeight;
CGFloat upRatio = (_titleFont.pointSize+fontRuntimeDifferenceSize)/_titleFont.pointSize;
CGFloat downRatio = (_titleSelectedFont.pointSize-fontRuntimeDifferenceSize)/_titleFont.pointSize;
newCell.titleLabel.transform = CGAffineTransformMakeScale(baseScale*upRatio, baseScale*upRatio);
oldCell.titleLabel.transform = CGAffineTransformMakeScale(baseScale*downRatio, baseScale*downRatio);
[_pageCells enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull view, NSUInteger idx, BOOL * _Nonnull stop) {
if ([view isKindOfClass:[XXPageItemCell class]]) {
XXPageItemCell *cell = view;
if (idx != pageIndex && idx != pageIndex+1) {
cell.titleLabel.transform = CGAffineTransformIdentity;
cell.titleLabel.font = _titleFont;
}
}
}];
}
if (_pageTitleColorChangeType == PageTitleColorChangeTypeScrolling) {
NSArray *rgba0 = [self getRGBValueFromColor:_titleColor];
NSArray *rgba1 = [self getRGBValueFromColor:_titleSelectedColor];
CGFloat diffR = xInScreen / kScreenWidth * ([rgba1[0] floatValue] - [rgba0[0] floatValue]);
CGFloat diffG = xInScreen / kScreenWidth * ([rgba1[1] floatValue] - [rgba0[1] floatValue]);
CGFloat diffB = xInScreen / kScreenWidth * ([rgba1[2] floatValue] - [rgba0[2] floatValue]);
CGFloat runingRed0 = [rgba0[0] floatValue] + diffR;
CGFloat runingGreen0 = [rgba0[1] floatValue] + diffG;
CGFloat runingBlue0 = [rgba0[2] floatValue] + diffB;
CGFloat runingred1 = [rgba1[0] floatValue] - diffR;
CGFloat runinGreen1 = [rgba1[1] floatValue] - diffG;
CGFloat runingBlue1 = [rgba1[2] floatValue] - diffB;
UIColor *runtimeColor0 = [UIColor colorWithRed:runingRed0 green:runingGreen0 blue:runingBlue0 alpha:1.0];
UIColor *runtimeColor1 = [UIColor colorWithRed:runingred1 green:runinGreen1 blue:runingBlue1 alpha:1.0];
oldCell.titleLabel.textColor = runtimeColor1;
newCell.titleLabel.textColor = runtimeColor0;
}
}
/** 系统API获取UIColor的RGBA值 */
- (NSArray *)getRGBValueFromColor:(UIColor *)color {
CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
[color getRed:&red green:&green blue:&blue alpha:&alpha];
return @[@(red), @(green), @(blue), @(alpha)];
}
/** 需要在滑动结束后处理的各UI type */
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if (_didSelectCollectionPageItem) return;
if (scrollView == _collectionMain) {
CGFloat x = scrollView.contentOffset.x ;
int index = (x + kScreenWidth*0.5) / kScreenWidth; //滑动切换基准选择: kScreenWidth*0.5(半屏)
// ScrollViewPage 处理偏移:setContentOffset
[self updateCurrentScrollViewPageContentOffsetByIndex:index];
// 下划线线性动画
if ( _lineScrollType == LineScrollTypeScrollEndLinear) {
[UIView animateWithDuration:kAnimateDuration animations:^{
[self updateLineFrameWithIndex:index];
}];
}
if (_pageTitleFontChangeType == PageTitleFontChangeTypeScrolling) {
//FIXME: 防止 cell 在复用时取到未复位的 cell
int pageIndex = ABS(x) / kScreenWidth;
[_pageCells enumerateObjectsUsingBlock:^(__kindof XXPageItemCell * _Nonnull cell, NSUInteger idx, BOOL * _Nonnull stop) {
if (idx != pageIndex) {
cell.titleLabel.transform = CGAffineTransformIdentity;
cell.titleLabel.font = _titleFont;
}
}];
}
}
}
/// 更新当前使用的分页ScrollView偏移量,复现UICollectionView滑动到view边缘处理的大致流程
/// @param index 当前位置
- (void)updateCurrentScrollViewPageContentOffsetByIndex:(NSInteger)index {
NSArray *currentArray = [_pageCellWs subarrayWithRange:NSMakeRange(0, index)];
CGFloat currentOffX = [[currentArray valueForKeyPath:@"@sum.floatValue"] floatValue]; //↑
CGFloat contentWidth = [[_pageCellWs valueForKeyPath:@"@sum.floatValue"] floatValue]; // -
if (contentWidth <= _pageMenuW) return; //contentSize宽度小于_pageMenuW时,不偏移
if (currentOffX < _pageMenuW*0.5) {
[self.scrollViewPage setContentOffset:CGPointMake(0, 0) animated:YES];
} else if (currentOffX >= contentWidth-_pageMenuW*0.6) {
[self.scrollViewPage setContentOffset:CGPointMake(contentWidth-_pageMenuW, 0) animated:YES];
} else {
[self.scrollViewPage setContentOffset:CGPointMake(currentOffX-_pageMenuW*0.4, 0) animated:YES];
}
}
@end
//
// WhiteNoiseRequestModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface WhiteNoiseRequestModel : DSNetworkTool
/// 所有白噪音类型数据
@property (nonatomic, strong) NSArray *noiseTypeArr;
/// 白噪音列表数据
@property (nonatomic, strong) NSArray *noiseAudioArr;
/// 睡眠-放松训练-噪声分类请求
/// @param completion completion
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseTypeWithCompletion:(void (^)(WhiteNoiseRequestModel *requestModel))completion;
/// 睡眠-放松训练-白噪声列表请求接口
/// @param typeID 白噪音类型id
/// @param completion completion
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseAudiosWithTypeID:(NSInteger)typeID completion:(void (^)(WhiteNoiseRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// WhiteNoiseRequestModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "WhiteNoiseRequestModel.h"
#import "NoiseTypeModel.h"
#import "NoiseAudioModel.h"
@implementation WhiteNoiseRequestModel
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseTypeWithCompletion:(void (^)(WhiteNoiseRequestModel *requestModel))completion {
WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init];
NSString *api = @"query_relax_white_noise_type";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"睡眠-放松训练-噪声分类接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
NoiseTypeModel *noiseTypeModel = [NoiseTypeModel yy_modelWithJSON:resultArr[i]];
// if (i == 0) {
// noiseTypeModel.is_lock = 0;
// } else {
// noiseTypeModel.is_lock = ![LoginUtils getUserLoginData];
// }
[tmpArr addObject:noiseTypeModel];
}
requestModel.noiseTypeArr = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseAudiosWithTypeID:(NSInteger)typeID completion:(void (^)(WhiteNoiseRequestModel *requestModel))completion {
WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init];
NSString *api = @"query_relax_white_noise_audios_for_IOS";
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) {
DSLog(@"睡眠-放松训练-白噪声列表接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
NoiseAudioModel *noiseAudioModel = [NoiseAudioModel yy_modelWithJSON:resultArr[i]];
[tmpArr addObject:noiseAudioModel];
}
requestModel.noiseAudioArr = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
[self clearUserData:@"退出成功"]; [self clearUserData:@"退出成功"];
// 刷新我的个人信息相关数据 // 刷新我的个人信息相关数据
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} }
}]; }];
} }
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
[DSProgressHUD showToast:@"登录成功"]; [DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); } if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} else { } else {
[DSProgressHUD showToast:requestModel.errorInfo]; [DSProgressHUD showToast:requestModel.errorInfo];
} }
...@@ -125,6 +127,8 @@ ...@@ -125,6 +127,8 @@
[DSProgressHUD showToast:@"登录成功"]; [DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); } if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} else { } else {
[DSProgressHUD showToast:requestModel.errorInfo]; [DSProgressHUD showToast:requestModel.errorInfo];
} }
......
{
"images" : [
{
"filename" : "dk_ic_voice_lock_unselected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_voice_lock_unselected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_voice_lock_unselected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!