Commit 70a9c53e cgx

完成睡眠故事模块

1 个父辈 313f96ea
正在显示 42 个修改的文件 包含 696 行增加38 行删除
...@@ -113,6 +113,9 @@ ...@@ -113,6 +113,9 @@
D055BEC528252B8900BC11A4 /* AudioDetailHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEC428252B8900BC11A4 /* AudioDetailHeaderView.m */; }; D055BEC528252B8900BC11A4 /* AudioDetailHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEC428252B8900BC11A4 /* AudioDetailHeaderView.m */; };
D055BEC828252D8200BC11A4 /* AudioCourseCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEC728252D8200BC11A4 /* AudioCourseCell.m */; }; D055BEC828252D8200BC11A4 /* AudioCourseCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEC728252D8200BC11A4 /* AudioCourseCell.m */; };
D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BECA28252E4000BC11A4 /* SubAudioModel.m */; }; D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BECA28252E4000BC11A4 /* SubAudioModel.m */; };
D0622434290793A900E1C89E /* SleepStoryHomeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0622433290793A900E1C89E /* SleepStoryHomeModel.m */; };
D06224372907C92000E1C89E /* UIColor+Extra.m in Sources */ = {isa = PBXBuildFile; fileRef = D06224362907C92000E1C89E /* UIColor+Extra.m */; };
D062243D2907D3D400E1C89E /* RelaxBubbleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D062243C2907D3D400E1C89E /* RelaxBubbleView.m */; };
D062A09E281838B800B4F48A /* FeedbackRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A09D281838B800B4F48A /* FeedbackRequestModel.m */; }; D062A09E281838B800B4F48A /* FeedbackRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A09D281838B800B4F48A /* FeedbackRequestModel.m */; };
D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A0A028183FE000B4F48A /* FeedbackDetailController.m */; }; D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A0A028183FE000B4F48A /* FeedbackDetailController.m */; };
D06381A428D012420074515B /* SleepStoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = D06381A328D012420074515B /* SleepStoryController.m */; }; D06381A428D012420074515B /* SleepStoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = D06381A328D012420074515B /* SleepStoryController.m */; };
...@@ -534,6 +537,12 @@ ...@@ -534,6 +537,12 @@
D055BEC728252D8200BC11A4 /* AudioCourseCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AudioCourseCell.m; sourceTree = "<group>"; }; D055BEC728252D8200BC11A4 /* AudioCourseCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AudioCourseCell.m; sourceTree = "<group>"; };
D055BEC928252E4000BC11A4 /* SubAudioModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SubAudioModel.h; sourceTree = "<group>"; }; D055BEC928252E4000BC11A4 /* SubAudioModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SubAudioModel.h; sourceTree = "<group>"; };
D055BECA28252E4000BC11A4 /* SubAudioModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SubAudioModel.m; sourceTree = "<group>"; }; D055BECA28252E4000BC11A4 /* SubAudioModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SubAudioModel.m; sourceTree = "<group>"; };
D0622432290793A900E1C89E /* SleepStoryHomeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SleepStoryHomeModel.h; sourceTree = "<group>"; };
D0622433290793A900E1C89E /* SleepStoryHomeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SleepStoryHomeModel.m; sourceTree = "<group>"; };
D06224352907C92000E1C89E /* UIColor+Extra.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIColor+Extra.h"; sourceTree = "<group>"; };
D06224362907C92000E1C89E /* UIColor+Extra.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Extra.m"; sourceTree = "<group>"; };
D062243B2907D3D400E1C89E /* RelaxBubbleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RelaxBubbleView.h; sourceTree = "<group>"; };
D062243C2907D3D400E1C89E /* RelaxBubbleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RelaxBubbleView.m; sourceTree = "<group>"; };
D062A09C281838B800B4F48A /* FeedbackRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackRequestModel.h; sourceTree = "<group>"; }; D062A09C281838B800B4F48A /* FeedbackRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackRequestModel.h; sourceTree = "<group>"; };
D062A09D281838B800B4F48A /* FeedbackRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackRequestModel.m; sourceTree = "<group>"; }; D062A09D281838B800B4F48A /* FeedbackRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackRequestModel.m; sourceTree = "<group>"; };
D062A09F28183FE000B4F48A /* FeedbackDetailController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackDetailController.h; sourceTree = "<group>"; }; D062A09F28183FE000B4F48A /* FeedbackDetailController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackDetailController.h; sourceTree = "<group>"; };
...@@ -1254,6 +1263,8 @@ ...@@ -1254,6 +1263,8 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D0930F142801874B006B497A /* DSNavigationTools */, D0930F142801874B006B497A /* DSNavigationTools */,
D06224352907C92000E1C89E /* UIColor+Extra.h */,
D06224362907C92000E1C89E /* UIColor+Extra.m */,
D0C50B3D27FD381000DC68F0 /* UIView+Extras.h */, D0C50B3D27FD381000DC68F0 /* UIView+Extras.h */,
D0C50B3E27FD381000DC68F0 /* UIView+Extras.m */, D0C50B3E27FD381000DC68F0 /* UIView+Extras.m */,
D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */, D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */,
...@@ -1620,6 +1631,8 @@ ...@@ -1620,6 +1631,8 @@
D0CCB09C2902A2E800B81141 /* StoryPlayController.m */, D0CCB09C2902A2E800B81141 /* StoryPlayController.m */,
D077AF6429066D1100F41394 /* PlayerManger.h */, D077AF6429066D1100F41394 /* PlayerManger.h */,
D077AF6529066D1100F41394 /* PlayerManger.m */, D077AF6529066D1100F41394 /* PlayerManger.m */,
D0622432290793A900E1C89E /* SleepStoryHomeModel.h */,
D0622433290793A900E1C89E /* SleepStoryHomeModel.m */,
); );
path = SleepStory; path = SleepStory;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2327,6 +2340,8 @@ ...@@ -2327,6 +2340,8 @@
D0A72E38282B566200EED7BE /* HomeBasicCell.m */, D0A72E38282B566200EED7BE /* HomeBasicCell.m */,
D0A72E40282B8BA600EED7BE /* CourseMusicCell.h */, D0A72E40282B8BA600EED7BE /* CourseMusicCell.h */,
D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */, D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */,
D062243B2907D3D400E1C89E /* RelaxBubbleView.h */,
D062243C2907D3D400E1C89E /* RelaxBubbleView.m */,
D0506B1628054ECD00229278 /* SafeHelperCollectionView.h */, D0506B1628054ECD00229278 /* SafeHelperCollectionView.h */,
D0506B1728054ECD00229278 /* SafeHelperCollectionView.m */, D0506B1728054ECD00229278 /* SafeHelperCollectionView.m */,
D0506B192805500E00229278 /* SafeHelperCollectionViewCell.h */, D0506B192805500E00229278 /* SafeHelperCollectionViewCell.h */,
...@@ -2823,6 +2838,7 @@ ...@@ -2823,6 +2838,7 @@
D0D4107C2844B8DB00009638 /* DailyTaskController.m in Sources */, D0D4107C2844B8DB00009638 /* DailyTaskController.m in Sources */,
D0E6600828080F97006562F2 /* SystemSetController.m in Sources */, D0E6600828080F97006562F2 /* SystemSetController.m in Sources */,
D0D96FE52848698F00461839 /* SomeProxy.m in Sources */, D0D96FE52848698F00461839 /* SomeProxy.m in Sources */,
D0622434290793A900E1C89E /* SleepStoryHomeModel.m in Sources */,
D0BDDFFC28618123006558D4 /* DisableAllTextView.m in Sources */, D0BDDFFC28618123006558D4 /* DisableAllTextView.m in Sources */,
D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */, D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */,
D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */, D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */,
...@@ -2874,6 +2890,7 @@ ...@@ -2874,6 +2890,7 @@
D091E671283F2E6F00D3279E /* ScoreDetailListController.m in Sources */, D091E671283F2E6F00D3279E /* ScoreDetailListController.m in Sources */,
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */, D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */,
D070A78828DEED640039C5A7 /* DynamicController.m in Sources */, D070A78828DEED640039C5A7 /* DynamicController.m in Sources */,
D06224372907C92000E1C89E /* UIColor+Extra.m in Sources */,
D0AEFE812817DD1500230DC6 /* MyFeedCell.m in Sources */, D0AEFE812817DD1500230DC6 /* MyFeedCell.m in Sources */,
D0A3BB9228D95A2B00F58781 /* CommunityView.m in Sources */, D0A3BB9228D95A2B00F58781 /* CommunityView.m in Sources */,
D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */, D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */,
...@@ -2995,6 +3012,7 @@ ...@@ -2995,6 +3012,7 @@
D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */, D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */,
D01814E8280020F900583D4E /* CWPageControl.m in Sources */, D01814E8280020F900583D4E /* CWPageControl.m in Sources */,
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */, D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */,
D062243D2907D3D400E1C89E /* RelaxBubbleView.m in Sources */,
D030796F28E3E32A00ED96BF /* LikeButton.m in Sources */, D030796F28E3E32A00ED96BF /* LikeButton.m in Sources */,
D037C49A284F4F0D000F3089 /* DailyTaskCell.m in Sources */, D037C49A284F4F0D000F3089 /* DailyTaskCell.m in Sources */,
D043DD55285B11860043A4CE /* VersionUpdateBox.m in Sources */, D043DD55285B11860043A4CE /* VersionUpdateBox.m in Sources */,
......
//
// UIColor+Extra.h
// DreamSleep
//
// Created by peter on 2022/10/25.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIColor (Extra)
/**
* @biref 十六进制颜色值转UIColor
* @param hexStr 十六进制字符(#3C3C3C或者3C3C3C)
* @return UIColor
*/
+ (UIColor *)colorWithHexStr:(NSString *)hexStr;
/**
* @biref 十六进制颜色值转UIColor
* @param hexStr 十六进制字符(#3C3C3C或者3C3C3C)
* @param alpha alpha
* @return UIColor
*/
+ (UIColor *)colorWithHexStr:(NSString *)hexStr alpha:(CGFloat)alpha;
@end
NS_ASSUME_NONNULL_END
//
// UIColor+Extra.m
// DreamSleep
//
// Created by peter on 2022/10/25.
//
#import "UIColor+Extra.h"
@implementation UIColor (Extra)
+ (UIColor *)colorWithHexStr:(NSString *)hexStr
{
return [self colorWithHexStr:hexStr alpha:1.0];
}
+ (UIColor *)colorWithHexStr:(NSString *)hexStr alpha:(CGFloat)alpha
{
NSString *cString = [[hexStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
if ([cString hasPrefix:@"#"]) {
cString = [cString substringFromIndex:1];
}
if ([cString length] != 6) {
return UIColor.whiteColor;
}
NSRange range;
range.location = 0;
range.length = 2;
NSString *rString = [cString substringWithRange:range];
range.location = 2;
NSString *gString = [cString substringWithRange:range];
range.location = 4;
NSString *bString = [cString substringWithRange:range];
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return [UIColor colorWithRed:((float) r / 255.0f)
green:((float) g / 255.0f)
blue:((float) b / 255.0f)
alpha:alpha];
}
@end
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import <YYModel/YYModel.h> #import <YYModel/YYModel.h>
#import <YYWebImage/YYWebImage.h> #import <YYWebImage/YYWebImage.h>
#import "UIColor+Extra.h"
#import "UIView+Extras.h" #import "UIView+Extras.h"
#import "UILabel+Extras.h" #import "UILabel+Extras.h"
#import "UIButton+Extras.h" #import "UIButton+Extras.h"
......
...@@ -12,21 +12,30 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,21 +12,30 @@ NS_ASSUME_NONNULL_BEGIN
/// 音频数据model /// 音频数据model
@interface SubAudioModel : NSObject @interface SubAudioModel : NSObject
// 类别id // 类别id
@property (nonatomic,assign) int type_id; @property (nonatomic, assign) int type_id;
// 音频id // 音频id
@property (nonatomic,assign) int audio_id; @property (nonatomic, assign) int audio_id;
// 音频播放图片 // 音频播放图片
@property (nonatomic,copy) NSString *audio_pic; @property (nonatomic, copy) NSString *audio_pic;
// 音频描述 // 音频描述
@property (nonatomic,copy) NSString *audio_desc; @property (nonatomic, copy) NSString *audio_desc;
// 音频名称 // 音频名称
@property (nonatomic,copy) NSString *audio_name; @property (nonatomic, copy) NSString *audio_name;
// 音频播放url // 音频播放url
@property (nonatomic,copy) NSString *audio_url; @property (nonatomic, copy) NSString *audio_url;
// 播放时长 // 播放时长
@property (nonatomic,copy) NSString *play_time; @property (nonatomic, copy) NSString *play_time;
// 加锁标记 // 加锁标记
@property (nonatomic,assign) int is_lock; @property (nonatomic, assign) int is_lock;
// 音频封面图
@property (nonatomic, copy) NSString *audio_img;
// 睡眠故事音频播放次数
@property (nonatomic, assign) int play_count;
// 颜色值
@property (nonatomic, copy) NSString *day_bg_color;
@property (nonatomic, copy) NSString *night_bg_color;
@property (nonatomic, copy) NSString *day_title_color;
@property (nonatomic, copy) NSString *night_title_color;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
#import "DSNetworkTool.h" #import "DSNetworkTool.h"
#import "SleepStoryHomeModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
...@@ -27,10 +28,14 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -27,10 +28,14 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion SafeSleepRequestModel /// @param completion SafeSleepRequestModel
+ (NSURLSessionDataTask *)getCourseListDataWithSubID:(int)subID isHome:(BOOL)isHome completion:(void (^)(SafeSleepRequestModel *requestModel))completion; + (NSURLSessionDataTask *)getCourseListDataWithSubID:(int)subID isHome:(BOOL)isHome completion:(void (^)(SafeSleepRequestModel *requestModel))completion;
/// 冥想分类详情 /// 冥想分类详情(舒眠课程和助眠音乐子课程列表、睡眠故事列表)
/// @param type_id 课程ID /// @param type_id 课程ID
/// @param completion SafeSleepRequestModel /// @param completion SafeSleepRequestModel
+ (NSURLSessionDataTask *)queryRelaxMeditationAudiosWithTypeID:(int)type_id completion:(void (^)(SafeSleepRequestModel *requestModel))completion; + (NSURLSessionDataTask *)queryRelaxMeditationAudiosWithTypeID:(int)type_id completion:(void (^)(SafeSleepRequestModel *requestModel))completion;
/// 获取首页睡眠故事数据
/// @param completion completion
+ (NSURLSessionDataTask *)querySleepAudioStoryWithCompletion:(void (^)(SafeSleepRequestModel *requestModel, SleepStoryHomeModel * sshModel))completion;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -71,4 +71,21 @@ ...@@ -71,4 +71,21 @@
}]; }];
} }
+ (NSURLSessionDataTask *)querySleepAudioStoryWithCompletion:(void (^)(SafeSleepRequestModel *requestModel, SleepStoryHomeModel * sshModel))completion {
NSString *api = @"query_sleep_audio_story";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
SafeSleepRequestModel * requestModel = [[SafeSleepRequestModel alloc] init];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary *apiDic) {
requestModel.resCode = DSResCodeSuccess;
DSLog(@"首页睡眠故事数据接口dataDic:%@", apiDic);
NSDictionary *resultDic = apiDic[@"result"];
SleepStoryHomeModel *homeStoryModel = [SleepStoryHomeModel yy_modelWithDictionary:resultDic];
completion(requestModel, homeStoryModel);
} failure:^(id failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel, nil);
}];
}
@end @end
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
@property (nonatomic, strong) NSArray *helpListData; @property (nonatomic, strong) NSArray *helpListData;
/// 所有白噪音类型数据 /// 所有白噪音类型数据
@property (nonatomic, strong) NSArray *noiseTypeArr; @property (nonatomic, strong) NSArray *noiseTypeArr;
/// 首页睡眠故事数据
@property (nonatomic, strong) SleepStoryHomeModel *sshModel;
/// APP更新弹框 /// APP更新弹框
@property (nonatomic, strong) VersionUpdateBox *updateBox; @property (nonatomic, strong) VersionUpdateBox *updateBox;
@property (nonatomic, assign) int update_Way; @property (nonatomic, assign) int update_Way;
...@@ -116,7 +118,6 @@ ...@@ -116,7 +118,6 @@
dispatch_group_t group = dispatch_group_create(); dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, queue, ^{ dispatch_group_async(group, queue, ^{
// 获取首页banner数据
[HomeRequestModel queryBannerListWithCompletion:^(HomeRequestModel * _Nonnull requestModel) { [HomeRequestModel queryBannerListWithCompletion:^(HomeRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取首页banner数据成功..."); DSLog(@"获取首页banner数据成功...");
...@@ -128,7 +129,6 @@ ...@@ -128,7 +129,6 @@
}]; }];
}); });
dispatch_group_async(group, queue, ^{ dispatch_group_async(group, queue, ^{
// 获取首页舒眠课程数据
[SafeSleepRequestModel getCourseListDataWithSubID:6 isHome:YES completion:^(SafeSleepRequestModel * _Nonnull requestModel) { [SafeSleepRequestModel getCourseListDataWithSubID:6 isHome:YES completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取首页舒眠课程数据成功..."); DSLog(@"获取首页舒眠课程数据成功...");
...@@ -140,7 +140,6 @@ ...@@ -140,7 +140,6 @@
}]; }];
}); });
dispatch_group_async(group, queue, ^{ dispatch_group_async(group, queue, ^{
// 获取首页助眠音乐数据
[SafeSleepRequestModel getCourseListDataWithSubID:18 isHome:YES completion:^(SafeSleepRequestModel * _Nonnull requestModel) { [SafeSleepRequestModel getCourseListDataWithSubID:18 isHome:YES completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取首页助眠音乐数据成功..."); DSLog(@"获取首页助眠音乐数据成功...");
...@@ -152,7 +151,6 @@ ...@@ -152,7 +151,6 @@
}]; }];
}); });
dispatch_group_async(group, queue, ^{ dispatch_group_async(group, queue, ^{
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) { [WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取白噪音类型请求成功..."); DSLog(@"获取白噪音类型请求成功...");
...@@ -163,9 +161,21 @@ ...@@ -163,9 +161,21 @@
} }
}]; }];
}); });
dispatch_group_async(group, queue, ^{
[SafeSleepRequestModel querySleepAudioStoryWithCompletion:^(SafeSleepRequestModel * _Nonnull requestModel, SleepStoryHomeModel * _Nonnull sshModel) {
if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取首页睡眠故事数据请求成功...");
dispatch_semaphore_signal(semaphore);
self.sshModel = sshModel;
} else {
[self.homeTV.mj_header endRefreshing];
}
}];
});
dispatch_group_notify(group, queue, ^{ dispatch_group_notify(group, queue, ^{
// 四个请求对应四次信号等待 // 5个请求对应5次信号等待
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
...@@ -180,6 +190,7 @@ ...@@ -180,6 +190,7 @@
[self.homeTV updateCourseMusicCell:CellTypeCourse data:self.safeListData]; [self.homeTV updateCourseMusicCell:CellTypeCourse data:self.safeListData];
[self.homeTV updateCourseMusicCell:CellTypeMusic data:self.helpListData]; [self.homeTV updateCourseMusicCell:CellTypeMusic data:self.helpListData];
[self.homeTV updateNoiseAllTypeData:self.noiseTypeArr]; [self.homeTV updateNoiseAllTypeData:self.noiseTypeArr];
[self.homeTV updateSleepStoryView:self.sshModel];
// 重置白噪音播放 // 重置白噪音播放
[[NoisePlayerManager sharedNoisePlayerManager] removeAllNoisePlayItem]; [[NoisePlayerManager sharedNoisePlayerManager] removeAllNoisePlayItem];
......
...@@ -27,6 +27,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -27,6 +27,9 @@ NS_ASSUME_NONNULL_BEGIN
/// 更新白噪音类型数据 /// 更新白噪音类型数据
/// @param typeDataArr typeDataArr /// @param typeDataArr typeDataArr
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr; - (void)updateNoiseAllTypeData:(NSArray *)typeDataArr;
/// 更新首页睡眠故事view
- (void)updateSleepStoryView:(id)model;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -58,6 +58,10 @@ ...@@ -58,6 +58,10 @@
} }
} }
- (void)updateSleepStoryView:(id)model {
[self.headerView updateStory:model];
}
#pragma mark - UITableViewDelegate && UITableViewDataSource #pragma mark - UITableViewDelegate && UITableViewDataSource
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
NSString *cellID = [NSString stringWithFormat:@"CourseMusicCell_%zd", indexPath.row]; NSString *cellID = [NSString stringWithFormat:@"CourseMusicCell_%zd", indexPath.row];
...@@ -101,9 +105,10 @@ ...@@ -101,9 +105,10 @@
CGFloat bannerH = 2*(kScreenWidth - 48)/5.0; CGFloat bannerH = 2*(kScreenWidth - 48)/5.0;
// 哄睡按钮宽度 // 哄睡按钮宽度
CGFloat width = kScreenWidth - 2*15 - 12; CGFloat width = kScreenWidth - 2*15 - 12;
CGFloat coaxH = 170*.3*width/104.0;
// 睡前故事区域高度 // 睡前故事区域高度
CGFloat sleepStoryH = 64; CGFloat sleepStoryH = 185;
CGFloat height = 15 + bannerH + 24 + (170*.3*width/104.0) + sleepStoryH; CGFloat height = 15 + bannerH + 24 + coaxH + 26 + sleepStoryH;
_headerView = [[HomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, height)]; _headerView = [[HomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, height)];
_headerView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); _headerView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
} }
......
...@@ -25,10 +25,9 @@ ...@@ -25,10 +25,9 @@
CGFloat width = kScreenWidth - 2*15 - 12; CGFloat width = kScreenWidth - 2*15 - 12;
[self.coaxIV mas_makeConstraints:^(MASConstraintMaker *make) { [self.coaxIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self); make.top.bottom.equalTo(self);
make.leftMargin.equalTo(self).offset(15); make.leftMargin.equalTo(self).offset(15);
make.width.equalTo(@(.3*width)); make.width.equalTo(@(.3*width));
make.height.equalTo(@(170*.3*width/104.0));
}]; }];
[self.mbsrIV mas_makeConstraints:^(MASConstraintMaker *make) { [self.mbsrIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.coaxIV); make.top.equalTo(self.coaxIV);
...@@ -48,7 +47,6 @@ ...@@ -48,7 +47,6 @@
make.top.bottom.equalTo(self.balanceIV); make.top.bottom.equalTo(self.balanceIV);
make.left.equalTo(self.balanceIV.mas_right).offset(13); make.left.equalTo(self.balanceIV.mas_right).offset(13);
}]; }];
self.height = self.coaxIV.height;
} }
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
......
...@@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)controllerWillAppear; - (void)controllerWillAppear;
- (void)controllerWillDisAppear; - (void)controllerWillDisAppear;
- (void)updateStory:(id)model;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,22 +6,38 @@ ...@@ -6,22 +6,38 @@
// //
#import "HomeHeaderView.h" #import "HomeHeaderView.h"
#import "BannerModel.h"
#import "CWCarousel.h" #import "CWCarousel.h"
#import "CWPageControl.h" #import "CWPageControl.h"
#import "HeaderDataModel.h"
#import "DsMiddleView.h" #import "DsMiddleView.h"
#import "RelaxBubbleView.h"
#import "BannerModel.h"
#import "HeaderDataModel.h"
#import "SleepStoryHomeModel.h"
#import "UnityGameController.h" #import "UnityGameController.h"
#import "SleepStoryController.h" #import "SleepStoryController.h"
#import "StoryPlayController.h"
@interface HomeHeaderView () <CWCarouselDatasource, CWCarouselDelegate> @interface HomeHeaderView () <CWCarouselDatasource, CWCarouselDelegate, UIScrollViewDelegate>
// 轮播图 // 轮播图
@property (nonatomic, strong) CWCarousel *barnnerView; @property (nonatomic, strong) CWCarousel *barnnerView;
@property (nonatomic, strong) NSArray *bannerDatas; @property (nonatomic, strong) NSArray *bannerDatas;
// 哄睡、呼吸法区域 // 哄睡、呼吸法区域
@property (nonatomic, strong) DsMiddleView *dsMiddleView; @property (nonatomic, strong) DsMiddleView *dsMiddleView;
// 睡前故事区域 // 睡前故事区域
@property (nonatomic, strong) UIButton *storyView; @property (nonatomic, strong) UIScrollView *storyView;
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) UIImageView *audioIV;
@property (nonatomic, strong) UILabel *audioLab;
@property (nonatomic, strong) UILabel *audioDescLab;
@property (nonatomic, strong) UIImageView *timeIcon;
@property (nonatomic, strong) UILabel *playTimeLab;
@property (nonatomic, strong) UILabel *playCountLab;
@property (nonatomic, strong) UIButton *playBtn;
@property (nonatomic, strong) SubAudioModel *audioModel;
@property (nonatomic, strong) RelaxBubbleView *bubbleView;
@end @end
@implementation HomeHeaderView @implementation HomeHeaderView
...@@ -41,12 +57,20 @@ ...@@ -41,12 +57,20 @@
[self.barnnerView mas_makeConstraints:^(MASConstraintMaker *make) { [self.barnnerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(15); make.top.equalTo(self).offset(15);
make.width.mas_equalTo(self); make.width.equalTo(self);
make.height.mas_equalTo(2*(kScreenWidth - 48)/5); make.height.mas_equalTo(2*(kScreenWidth - 48)/5);
}]; }];
[self.dsMiddleView mas_makeConstraints:^(MASConstraintMaker *make) { [self.dsMiddleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.topMargin.equalTo(self.barnnerView.mas_bottom).offset(24); make.top.equalTo(self.barnnerView.mas_bottom).offset(24);
make.width.mas_equalTo(self); make.width.equalTo(self);
CGFloat width = kScreenWidth - 2*15 - 12;
make.height.equalTo(@(170*.3*width/104.0));
}];
[self.storyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.height.equalTo(@185);
make.bottom.equalTo(self);
}]; }];
} }
...@@ -64,6 +88,40 @@ ...@@ -64,6 +88,40 @@
[self.barnnerView controllerWillDisAppear]; [self.barnnerView controllerWillDisAppear];
} }
- (void)updateStory:(id)model {
SleepStoryHomeModel *storyModel = (SleepStoryHomeModel *)model;
self.audioModel = storyModel.audio;
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:storyModel.audio.audio_img] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]];
self.audioLab.text = storyModel.audio.audio_name;
self.audioDescLab.text = storyModel.audio.audio_desc;
self.playTimeLab.text = storyModel.audio.play_time;
self.playCountLab.text = [NSString stringWithFormat:@"%d次", storyModel.audio.play_count];
UIColor *dayBgColor = [UIColor colorWithHexStr:storyModel.audio.day_bg_color];
UIColor *nightBgColor = [UIColor colorWithHexStr:storyModel.audio.night_bg_color];
UIColor *dayTitleColor = [UIColor colorWithHexStr:storyModel.audio.day_title_color];
UIColor *nightTitleColor = [UIColor colorWithHexStr:storyModel.audio.night_title_color];
UIColor *dayDescColor = [UIColor colorWithHexStr:storyModel.audio.day_title_color alpha:.5];
UIColor *nightDescColor = [UIColor colorWithHexStr:storyModel.audio.night_title_color alpha:.5];
UIColor *dayTimeColor = [UIColor colorWithHexStr:storyModel.audio.day_title_color alpha:.3];
UIColor *nightTimeColor = [UIColor colorWithHexStr:storyModel.audio.night_title_color alpha:.3];
self.topView.dk_backgroundColorPicker = DKColorPickerWithColors(dayBgColor, nightBgColor, DSWhite);
self.audioLab.dk_textColorPicker = DKColorPickerWithColors(dayTitleColor, nightTitleColor, DSWhite);
self.audioDescLab.dk_textColorPicker = DKColorPickerWithColors(dayDescColor, nightDescColor, DSWhite);
self.playTimeLab.dk_textColorPicker = DKColorPickerWithColors(dayTimeColor, nightTimeColor, DSWhite);
[self.bubbleView removeFromSuperview];
self.bubbleView = nil;
self.bubbleView = [[RelaxBubbleView alloc] initWithFrame:CGRectMake(0, 0, 99, 40)];
[self.bottomView addSubview:self.bubbleView];
self.bubbleView.dataArr_net = storyModel.user_imgs;
}
#pragma mark - CWCarouselDatasource #pragma mark - CWCarouselDatasource
- (NSInteger)numbersForCarousel { - (NSInteger)numbersForCarousel {
return self.bannerDatas.count; return self.bannerDatas.count;
...@@ -128,6 +186,22 @@ ...@@ -128,6 +186,22 @@
} }
} }
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (scrollView.contentOffset.x >= 30) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.ds_viewController.navigationController pushViewController:[SleepStoryController new] animated:YES];
});
}
}
#pragma private
- (void)playAction {
StoryPlayController *playVC = [StoryPlayController new];
playVC.audioModel = self.audioModel;
[self.ds_viewController presentViewController:playVC animated:YES completion:nil];
}
#pragma mark - lazy #pragma mark - lazy
- (CWCarousel *)barnnerView { - (CWCarousel *)barnnerView {
if (!_barnnerView) { if (!_barnnerView) {
...@@ -161,18 +235,151 @@ ...@@ -161,18 +235,151 @@
return _dsMiddleView; return _dsMiddleView;
} }
- (UIButton *)storyView { - (UIScrollView *)storyView {
if (!_storyView) { if (!_storyView) {
CGFloat height = 40; _storyView = [UIScrollView new];
WS(weakSelf); _storyView.pagingEnabled = YES;
#warning -待开发... _storyView.delegate = self;
_storyView = [[UIButton alloc] initWithFrame:CGRectMake(15, self.height - height, kScreenWidth - 30, 40)]; _storyView.contentSize = CGSizeMake(kScreenWidth - 30 + 1, 185);
[_storyView setTitle:@"睡前故事" forState:UIControlStateNormal];
[_storyView setTitleColor:MainTextColor forState:UIControlStateNormal]; UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 30, 185)];
[_storyView debugViewShowBorder]; [_storyView addSubview:tmpView];
[_storyView cornerRadius:8.0];
[_storyView addTouchUpInsideHandler:^(NSInteger tag) { UIImageView *icon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_home_shuiqiangushi", @"dk_ic_home_shuiqiangushi", @"ic_home_shuiqiangushi")];
[weakSelf.ds_viewController.navigationController pushViewController:[SleepStoryController new] animated:YES]; [tmpView addSubview:icon];
UILabel *titleLab = [UILabel labWithText:@"睡前故事" font:BoldFont(16) fit:YES];
titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
[tmpView addSubview:titleLab];
UILabel *tipsLab = [UILabel labWithText:@"左滑进入全部故事" font:SysFont(12) fit:YES];
tipsLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
[tmpView addSubview:tipsLab];
UIView *line = [UIView new];
line.dk_backgroundColorPicker = DKColorPickerWithKey(BrandBG);
[line cornerRadius:2];
[tmpView addSubview:line];
UIView *topView = [UIView new];
[tmpView addSubview:topView];
self.topView = topView;
UIView *bottomView = [UIView new];
bottomView.dk_backgroundColorPicker = DKColorPickerWithKey(CornerViewBG);
[tmpView addSubview:bottomView];
self.bottomView = bottomView;
self.audioIV = [[UIImageView alloc] initWithImage:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]];
[self.audioIV cornerRadius:12];
self.audioIV.contentMode = UIViewContentModeScaleAspectFit;
[tmpView addSubview:self.audioIV];
UIView *maskView = [UIView new];
maskView.dk_backgroundColorPicker = DKColorPickerWithColors(DSClearColor, ColorFromHexA(0x161e38, .35), DSWhite);
[self.audioIV addSubview:maskView];
self.audioLab = [UILabel labWithFont:BoldFont(16)];
[tmpView addSubview:self.audioLab];
self.audioDescLab = [UILabel labWithFont:SysFont(14)];
[tmpView addSubview:self.audioDescLab];
self.timeIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"sleep_story_home_time", @"dk_sleep_story_home_time", @"sleep_story_home_time")];
[tmpView addSubview:self.timeIcon];
self.playTimeLab = [UILabel labWithFont:SysFont(12)];
[tmpView addSubview:self.playTimeLab];
self.playBtn = [UIButton btnWithTitle:@"播放" font:BoldFont(16)];
self.playBtn.size = (CGSizeMake(64, 34));
[self.playBtn addTarget:self action:@selector(playAction) forControlEvents:UIControlEventTouchUpInside];
[self.playBtn dk_setTitleColorPicker:DKColorPickerWithKey(Sub_Navi_TITLE) forState:UIControlStateNormal];
[self.playBtn cornerRadius:17];
CGPoint start = CGPointMake(0, 0.5);
CGPoint end = CGPointMake(0.5, 0.5);
UIView *normal_tmp_view = [_playBtn genGradientWithStart:start end:end colors:@[(__bridge id)ColorFromHex(0x9BE3EC).CGColor, (__bridge id)ColorFromHex(0x62C3D5).CGColor] locations:@[@(0), @(1.0f)]];
UIView *dk_tmp_view = [_playBtn genGradientWithStart:start end:end colors:@[(__bridge id)ColorFromHex(0x77A6AE).CGColor, (__bridge id)ColorFromHex(0x45A4B5).CGColor] locations:@[@(0), @(1.0f)]];
[self.playBtn dk_setBackgroundImage:DKImagePickerWithImages([normal_tmp_view snapshotImage], [dk_tmp_view snapshotImage], [normal_tmp_view snapshotImage]) forState:UIControlStateNormal];
[tmpView addSubview:self.playBtn];
UIImageView *moreIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_touxiang", @"dk_ic_touxiang", @"ic_touxiang")];
[self.bottomView addSubview:moreIcon];
self.playCountLab = [UILabel labWithFont:SysFont(12)];
self.playCountLab.dk_textColorPicker = DKColorPickerWithColors(ColorFromHex(0xC7D1D7), ColorFromHexA(0xFFFFFF, .3), DSWhite);
[self.bottomView addSubview:self.playCountLab];
[icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(tmpView);
make.size.mas_equalTo(CGSizeMake(30, 30));
}];
[titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(icon.mas_right).offset(8);
make.top.equalTo(icon).offset(7);
}];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(titleLab);
make.top.equalTo(titleLab.mas_bottom).offset(-3);
make.height.equalTo(@4);
}];
[tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(tmpView);
make.centerY.equalTo(titleLab);
}];
[topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(tmpView);
make.top.equalTo(icon.mas_bottom).offset(26);
make.height.equalTo(@90);
}];
[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(tmpView);
make.top.equalTo(topView.mas_bottom);
make.bottom.equalTo(tmpView);
}];
[tmpView layoutIfNeeded];
[topView setCornerRadiusRect:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadius:12];
[bottomView setCornerRadiusRect:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadius:12];
[self.audioIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(topView).offset(-10);
make.left.equalTo(topView).offset(15);
make.size.mas_equalTo(CGSizeMake(76, 90));
}];
[maskView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.audioIV);
}];
[self.audioLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(topView).offset(8);
make.left.equalTo(self.audioIV.mas_right).offset(12);
make.right.equalTo(tmpView).offset(-15);
}];
[self.audioDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(topView).offset(36);
make.left.equalTo(self.audioLab);
make.right.equalTo(tmpView).offset(-32);
}];
[self.timeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.audioLab);
make.size.mas_equalTo(CGSizeMake(14, 14));
make.bottom.equalTo(self.audioIV).offset(-1);
}];
[self.playTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeIcon.mas_right).offset(8);
make.centerY.equalTo(self.timeIcon);
make.right.equalTo(tmpView).offset(-84);
}];
[self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(topView).offset(18);
make.right.equalTo(tmpView).offset(-15);
}];
[moreIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.bubbleView);
make.size.mas_equalTo(CGSizeMake(20, 20));
make.left.equalTo(self.bottomView).offset(95);
}];
[self.playCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(moreIcon.mas_right).offset(11);
make.centerY.equalTo(moreIcon);
make.right.equalTo(self.bottomView).offset(-84);
}]; }];
} }
return _storyView; return _storyView;
......
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface RelaxBubbleView : UIView
// 加载网络图片地址
@property (nonatomic, strong) NSArray * dataArr_net;
@end
NS_ASSUME_NONNULL_END
#import "RelaxBubbleView.h"
#define MaxHeadCount 6
#define kHeadWidth 18
#define kOverlapOffset 4
#define kRightMargin 0
@interface RelaxBubbleView ()
@property (nonatomic, strong) UIImageView * activeImg;
@property (nonatomic, strong) NSMutableArray * dataImgArr_net;
@property (nonatomic, assign) int jsh_index;
@property (nonatomic, assign) int jsh_img;
@property (nonatomic, assign) int overlapSpace;
@end
@implementation RelaxBubbleView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = DSClearColor;
self.overlapSpace = kHeadWidth - kOverlapOffset;
self.dataImgArr_net = [NSMutableArray array];
self.userInteractionEnabled = NO;
[self createUI];
}
return self;
}
- (void)createUI {
for (int i = 0; i < MaxHeadCount; i++) {
UIImageView * imgv = [[UIImageView alloc] initWithFrame:CGRectMake(self.width - kRightMargin - kHeadWidth - self.overlapSpace*i, 0, kHeadWidth, kHeadWidth)];
imgv.tag = 10 + i;
imgv.centerY = self.centerY;
[imgv cornerRadius:kHeadWidth/2];
imgv.layer.dk_borderColorPicker = DKColorPickerWithColors(DSWhite, ColorFromHex(0x263154), DSWhite);
imgv.layer.borderWidth = 1;
imgv.backgroundColor = [UIColor lightGrayColor];
[self addSubview:imgv];
if (i == 0) {
self.jsh_index = 0;
self.activeImg = imgv;
}
}
}
- (void)setDataArr_net:(NSArray *)dataArr_net {
if (_dataArr_net != dataArr_net) {
_dataArr_net = dataArr_net;
}
[self checkData_net];
}
- (void)checkData_net {
WS(weakSelf);
[self.layer removeAllAnimations];
[self.dataImgArr_net removeAllObjects];
if (_dataArr_net.count < MaxHeadCount) {
[DSProgressHUD showToast:[NSString stringWithFormat:@"传入图片个数不能少于%d个", MaxHeadCount]];
return;
}
int __block jsh_dataImg = 0;
for (int i = 0; i < _dataArr_net.count; i++) {
UIImageView *dataImgV = [[UIImageView alloc] init];
NSDictionary *face_img_dic = _dataArr_net[i];
[dataImgV yy_setImageWithURL:[NSURL URLWithString:face_img_dic[@"face_img"]] placeholder:nil options:YYWebImageOptionRefreshImageCache completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
jsh_dataImg = jsh_dataImg + 1;
if (jsh_dataImg == weakSelf.dataImgArr_net.count) {
for (int i = 0; i < MaxHeadCount; i++) {
UIImageView * imgv = [weakSelf viewWithTag:10+i];
UIImageView * dataImgV_net = weakSelf.dataImgArr_net[i];
imgv.image = dataImgV_net.image;
}
self.jsh_img = MaxHeadCount - 1;
[self startAnimation_net];
}
}];
[self.dataImgArr_net addObject:dataImgV];
}
}
- (void)startAnimation_net {
WS(weakSelf);
[UIView animateWithDuration:1 animations:^{
NSInteger activeTag = weakSelf.activeImg.tag;
for (int i = 0; i < MaxHeadCount; i++) {
NSInteger aTag = 10+i;
if (aTag != activeTag) {
UIImageView * imgg = [weakSelf viewWithTag:10+i];
imgg.centerX = imgg.centerX + self.overlapSpace;
}
}
} completion:^(BOOL finished) {
weakSelf.activeImg.centerX = kHeadWidth / 2.0;
weakSelf.activeImg.transform = CGAffineTransformScale(weakSelf.activeImg.transform, 0.1, 0.1);
if (weakSelf.jsh_img < weakSelf.dataArr_net.count - 1) {
weakSelf.jsh_img = weakSelf.jsh_img + 1;
} else {
weakSelf.jsh_img = 0;
}
UIImageView * dataImg_net = weakSelf.dataImgArr_net[weakSelf.jsh_img];
weakSelf.activeImg.image = dataImg_net.image;
[UIView animateWithDuration:1 animations:^{
weakSelf.activeImg.transform = CGAffineTransformScale(weakSelf.activeImg.transform, 10, 10);
} completion:^(BOOL finished) {
[weakSelf bringSubviewToFront:weakSelf.activeImg];
[UIView animateWithDuration:1 animations:^{
weakSelf.activeImg.x = self.width - kRightMargin - kHeadWidth - self.overlapSpace * (MaxHeadCount - 1);
} completion:^(BOOL finished) {
weakSelf.jsh_index = weakSelf.jsh_index + 1;
if (weakSelf.jsh_index > (MaxHeadCount - 1)) {
weakSelf.jsh_index = 0;
}
weakSelf.activeImg = [weakSelf viewWithTag:10+weakSelf.jsh_index];
[weakSelf startAnimation_net];
}];
}];
}];
}
@end
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
- (void)setStoryModel:(SubAudioModel *)storyModel { - (void)setStoryModel:(SubAudioModel *)storyModel {
_storyModel = storyModel; _storyModel = storyModel;
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:storyModel.audio_pic] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]]; [self.audioIV yy_setImageWithURL:[NSURL URLWithString:storyModel.audio_img] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]];
self.audioLab.text = storyModel.audio_name; self.audioLab.text = storyModel.audio_name;
self.audioDescLab.text = storyModel.audio_desc; self.audioDescLab.text = storyModel.audio_desc;
self.playTimeLab.text = storyModel.play_time; self.playTimeLab.text = storyModel.play_time;
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
_audioIV = [UIImageView new]; _audioIV = [UIImageView new];
_audioIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, 1); _audioIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, 1);
_audioIV.contentMode = UIViewContentModeScaleAspectFit; _audioIV.contentMode = UIViewContentModeScaleAspectFit;
[_audioIV cornerRadius:12];
} }
return _audioIV; return _audioIV;
} }
......
//
// SleepStoryHomeModel.h
// DreamSleep
//
// Created by peter on 2022/10/25.
//
#import <Foundation/Foundation.h>
#import "SubAudioModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 首页睡眠故事数据model
@interface SleepStoryHomeModel : NSObject
@property (nonatomic, strong) SubAudioModel *audio;
@property (nonatomic, strong) NSArray *user_imgs;
@end
NS_ASSUME_NONNULL_END
//
// SleepStoryHomeModel.m
// DreamSleep
//
// Created by peter on 2022/10/25.
//
#import "SleepStoryHomeModel.h"
@implementation SleepStoryHomeModel
@end
{
"images" : [
{
"filename" : "dk_ic_home_shuiqiangushi.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_home_shuiqiangushi@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_home_shuiqiangushi@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_touxiang.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_touxiang@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_touxiang@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_sleep_story_home_time.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_sleep_story_home_time@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_sleep_story_home_time@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_home_shuiqiangushi.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_home_shuiqiangushi@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_home_shuiqiangushi@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_touxiang.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_touxiang@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_touxiang@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sleep_story_home_time.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sleep_story_home_time@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sleep_story_home_time@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!