Commit 29f857b2 cgx

启动安睡准备功能模块

1 个父辈 f16cf4d5
正在显示 61 个修改的文件 包含 1169 行增加8 行删除
......@@ -43,6 +43,9 @@
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; };
D02D0827287BBEDE005C3A00 /* SleepReadyController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0826287BBEDE005C3A00 /* SleepReadyController.m */; };
D02D082A287BCEF3005C3A00 /* SRTipsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0829287BCEF3005C3A00 /* SRTipsView.m */; };
D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D082C287BD05D005C3A00 /* ReadyListController.m */; };
D030C1B8284775930014946F /* RelaxTrainController.m in Sources */ = {isa = PBXBuildFile; fileRef = D030C1B7284775930014946F /* RelaxTrainController.m */; };
D0336163285035AB005573CF /* DailyBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0336162285035AB005573CF /* DailyBgView.m */; };
D037B11228752A7E00236753 /* IndividualController.m in Sources */ = {isa = PBXBuildFile; fileRef = D037B11128752A7E00236753 /* IndividualController.m */; };
......@@ -323,6 +326,12 @@
D027EE2827FB51D0004BBA61 /* DSGifHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSGifHeader.m; sourceTree = "<group>"; };
D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+Extras.h"; sourceTree = "<group>"; };
D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Extras.m"; sourceTree = "<group>"; };
D02D0825287BBEDE005C3A00 /* SleepReadyController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SleepReadyController.h; sourceTree = "<group>"; };
D02D0826287BBEDE005C3A00 /* SleepReadyController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SleepReadyController.m; sourceTree = "<group>"; };
D02D0828287BCEF3005C3A00 /* SRTipsView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SRTipsView.h; sourceTree = "<group>"; };
D02D0829287BCEF3005C3A00 /* SRTipsView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SRTipsView.m; sourceTree = "<group>"; };
D02D082B287BD05D005C3A00 /* ReadyListController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReadyListController.h; sourceTree = "<group>"; };
D02D082C287BD05D005C3A00 /* ReadyListController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReadyListController.m; sourceTree = "<group>"; };
D030C1B6284775930014946F /* RelaxTrainController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RelaxTrainController.h; sourceTree = "<group>"; };
D030C1B7284775930014946F /* RelaxTrainController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RelaxTrainController.m; sourceTree = "<group>"; };
D0336161285035AB005573CF /* DailyBgView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DailyBgView.h; sourceTree = "<group>"; };
......@@ -992,6 +1001,30 @@
path = Category;
sourceTree = "<group>";
};
D02D0823287BBE4E005C3A00 /* SleepCoach */ = {
isa = PBXGroup;
children = (
D0E41B5928519D05005A7DA4 /* View */,
D0E41B5A28519D1F005A7DA4 /* Model */,
D0E41B5728519CD1005A7DA4 /* Controller */,
D0E41B5828519CF2005A7DA4 /* RequestModel */,
);
path = SleepCoach;
sourceTree = "<group>";
};
D02D0824287BBE9A005C3A00 /* SleepReady */ = {
isa = PBXGroup;
children = (
D02D0825287BBEDE005C3A00 /* SleepReadyController.h */,
D02D0826287BBEDE005C3A00 /* SleepReadyController.m */,
D02D082B287BD05D005C3A00 /* ReadyListController.h */,
D02D082C287BD05D005C3A00 /* ReadyListController.m */,
D02D0828287BCEF3005C3A00 /* SRTipsView.h */,
D02D0829287BCEF3005C3A00 /* SRTipsView.m */,
);
path = SleepReady;
sourceTree = "<group>";
};
D043DD52285B101A0043A4CE /* AppUpdate */ = {
isa = PBXGroup;
children = (
......@@ -1062,10 +1095,8 @@
D04567AC27F6D0BA009F0A82 /* AISleepModule */ = {
isa = PBXGroup;
children = (
D0E41B5928519D05005A7DA4 /* View */,
D0E41B5A28519D1F005A7DA4 /* Model */,
D0E41B5728519CD1005A7DA4 /* Controller */,
D0E41B5828519CF2005A7DA4 /* RequestModel */,
D02D0823287BBE4E005C3A00 /* SleepCoach */,
D02D0824287BBE9A005C3A00 /* SleepReady */,
);
path = AISleepModule;
sourceTree = "<group>";
......@@ -2113,6 +2144,7 @@
D01C9D7028168BFC00163567 /* NSDate+Extension.m in Sources */,
D0F9AC582826602400FD7A3B /* SPButton.m in Sources */,
D0DB33A528204E7C00E15914 /* FirstLeadAlertView.m in Sources */,
D02D0827287BBEDE005C3A00 /* SleepReadyController.m in Sources */,
D054CCB82830E3AC00420DC4 /* NoisePlayItem.m in Sources */,
D0C50B3027FD1BEB00DC68F0 /* PrivacyView.m in Sources */,
D0BE53712845AFD8007F15B3 /* NewTaskModel.m in Sources */,
......@@ -2156,6 +2188,7 @@
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */,
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */,
D01BD42E282C06D200BA86B3 /* NoiseListController.m in Sources */,
D02D082A287BCEF3005C3A00 /* SRTipsView.m in Sources */,
D03AE82B281A9010001C0726 /* MyFeedDetailModel.m in Sources */,
D0A750FC282DE21D00589B0E /* NoiseAudioCell.m in Sources */,
D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */,
......@@ -2186,6 +2219,7 @@
D091E671283F2E6F00D3279E /* ScoreDetailListController.m in Sources */,
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */,
D0AEFE812817DD1500230DC6 /* MyFeedCell.m in Sources */,
D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */,
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */,
D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */,
D054CCB52830DE5600420DC4 /* NoisePlayerManager.m in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="JOD-MV-Pim">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Sleep Coach Controller-->
<scene sceneID="mSr-VG-EoP">
<objects>
<viewController id="dDK-KA-sPQ" customClass="AISleepCoachController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="1eu-Nn-5E0">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Pf1-fh-l6V"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="05K-ik-z2W"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8JB-OR-j2U" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2786" y="201"/>
</scene>
<!--AI睡眠教练-->
<scene sceneID="zZV-8x-0UY">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="JOD-MV-Pim" customClass="BaseNaviController" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="AI睡眠教练" image="aisleep" selectedImage="aisleep_selected" id="Il3-d5-iMT"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="IbM-gj-oZu">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="dDK-KA-sPQ" kind="relationship" relationship="rootViewController" id="ACD-cx-BP7"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="hMf-jH-a0Q" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2021.7391304347827" y="200.89285714285714"/>
</scene>
</scenes>
<resources>
<image name="aisleep" width="25" height="25"/>
<image name="aisleep_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// AISleepCoachController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface AISleepCoachController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainController.h
// DreamSleep
//
// Created by peter on 2022/6/1.
//
#import "DSBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@protocol RelaxTrainControllerDelegate <NSObject>
/// 刷新AI睡眠教练页面
- (void)reloadAIPage;
@end
/// 放松训练、腹式呼吸法页面
@interface RelaxTrainController : DSBaseViewController
@property (nonatomic, weak) id<RelaxTrainControllerDelegate> refreshDelegate;
/// title和step参数
@property (nonatomic, strong) NSDictionary *params;
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainController.m
// DreamSleep
//
// Created by peter on 2022/6/1.
//
#import "RelaxTrainController.h"
#import "RelaxTrainRequestModel.h"
#import "RelaxBodyView.h"
@interface RelaxTrainController () <RelaxBodyViewDelegate, UIScrollViewDelegate>
@property (nonatomic, strong) UIImageView *bgIV;
@property (nonatomic, strong) UILabel *cusTitleLab;
@property (nonatomic, strong) NSArray *listArr;
@property (nonatomic, strong) UIScrollView *lucencyView;
@property (nonatomic, strong) RelaxBodyView *bodyView;
@end
@implementation RelaxTrainController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view addSubview:self.bgIV];
[self.view addSubview:self.lucencyView];
[self.lucencyView addSubview:self.bodyView];
[self.view addSubview:self.dsNaviBar];
[self.view addSubview:self.dkBackBtn];
[self.dkBackBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"cus_back_icon", @"dk_cus_back_icon") forState:UIControlStateNormal];
[self.view addSubview:self.cusTitleLab];
CGFloat iv_h = kScreenWidth*1233/1125.0;
[self.bgIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.height.equalTo(@(iv_h));
}];
[self.cusTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.dsNaviBar);
make.bottom.equalTo(self.dsNaviBar).offset(-9);
}];
[self.lucencyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.bottom.equalTo(self.view);
}];
[RelaxTrainRequestModel queryRelaxAudioListWithCompletion:^(RelaxTrainRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
if (requestModel.trainAudioList.count) {
self.listArr = requestModel.trainAudioList;
if (self.listArr && self.listArr.count > 0) {
NSInteger currentIndex = [self getIndexWithListData:self.listArr];
[self.bodyView refreshData:self.listArr currentIndex:currentIndex];
}
}
}
}];
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
[DataStatisticsUtil event:RelaxTrain attributes:@{@"data":@"腹式放松法页面"}];
}
#pragma mark - 根据title匹配下标索引
- (NSInteger)getIndexWithListData:(NSArray *)listData {
__block NSInteger currentIndex = 0;
NSString *title = self.params[@"title"];
// 放松音频随机选一个
if ([title isEqualToString:@"练习放松训练"]) {
currentIndex = arc4random() % listData.count;
} else {
[listData enumerateObjectsUsingBlock:^(RelaxTrainModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.audio_name containsString:title]) {
currentIndex = idx;
*stop = YES;
}
}];
}
return currentIndex;
}
#pragma mark - Actions
- (void)backAction {
[super backAction];
[self.bodyView stopAudio];
if (self.refreshDelegate && [self.refreshDelegate respondsToSelector:@selector(reloadAIPage)]) {
[self.refreshDelegate reloadAIPage];
}
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - RelaxBodyViewDelegate
- (void)updateNaviTitleAndBgImg:(RelaxTrainModel *)trainModel {
[self.bgIV setImageWithURL:[NSURL URLWithString:trainModel.bg_url] placeholderImage:[UIImage imageNamed:@"basicPlaceholder"]];
self.cusTitleLab.text = trainModel.audio_name;
self.titleLab.text = trainModel.audio_name;
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
CGFloat offset = scrollView.contentOffset.y;
if (offset >= self.lucencyView.contentSize.height - kScreenHeight) {
self.dkBackBtn.hidden = YES;
self.dsNaviBar.alpha = 1;
self.titleLab.hidden = NO;
self.cusTitleLab.hidden = YES;
self.isNeedUpdateStatusBarStyle = YES;
}
if (offset <= 0) {
self.dkBackBtn.hidden = NO;
self.dsNaviBar.alpha = 0;
self.titleLab.hidden = YES;
self.cusTitleLab.hidden = NO;
self.isNeedUpdateStatusBarStyle = NO;
}
}
#pragma mark - lazy
- (UIImageView *)bgIV {
if (!_bgIV) {
_bgIV = [UIImageView new];
}
return _bgIV;
}
- (UILabel *)cusTitleLab {
if (!_cusTitleLab) {
_cusTitleLab = [UILabel labWithTextColor:MainTextColor font:BoldFont(18)];
_cusTitleLab.textAlignment = NSTextAlignmentCenter;
}
return _cusTitleLab;
}
- (NSArray *)listArr {
if (!_listArr) {
_listArr = [NSArray array];
}
return _listArr;
}
- (UIScrollView *)lucencyView {
if (!_lucencyView) {
_lucencyView = [UIScrollView new];
_lucencyView.showsVerticalScrollIndicator = NO;
_lucencyView.delegate = self;
CGFloat bodyTopMargin = 351;
CGFloat bodyH = 420 + Bottom_SafeArea_Height;
_lucencyView.contentSize = CGSizeMake(kScreenWidth, bodyH + bodyTopMargin);
_lucencyView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
return _lucencyView;
}
- (RelaxBodyView *)bodyView {
if (!_bodyView) {
_bodyView = [[RelaxBodyView alloc] initWithFrame:CGRectMake(0, 351, kScreenWidth, 420 + Bottom_SafeArea_Height)];
_bodyView.delegate = self;
_bodyView.updateParams = self.params;
}
return _bodyView;
}
#pragma mark - 设置状态栏文字颜色(重写父类)
- (UIStatusBarStyle)preferredStatusBarStyle {
if (self.isNeedUpdateStatusBarStyle) {
return UIStatusBarStyleLightContent;
}
return UIStatusBarStyleDefault;
}
@end
//
// RelaxTrainModel.h
// DreamSleep
//
// Created by peter on 2022/6/2.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 放松训练数据model
@interface RelaxTrainModel : NSObject
/// 音频id
@property (nonatomic, assign) int audio_id;
/// 播放背景图
@property (nonatomic, copy) NSString *bg_url;
/// 音频封面
@property (nonatomic, copy) NSString *audio_img;
/// 音频名称
@property (nonatomic, copy) NSString *audio_name;
/// 音频播放链接
@property (nonatomic, copy) NSString *audio_url;
/// 是否推荐(1:推荐,0:不推荐)
@property (nonatomic, copy) NSString *is_recommend;
/// 描述信息
@property (nonatomic, copy) NSString *audio_desc;
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainModel.m
// DreamSleep
//
// Created by peter on 2022/6/2.
//
#import "RelaxTrainModel.h"
@implementation RelaxTrainModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"audio_id" : @"id"};
}
@end
//
// RelaxTrainRequestModel.h
// DreamSleep
//
// Created by peter on 2022/6/2.
//
#import "DSNetworkTool.h"
#import "RelaxTrainModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface RelaxTrainRequestModel : DSNetworkTool
/// 训练音频列表
@property (nonatomic, strong) NSArray *trainAudioList;
/// 获取放松音频列表数据
/// @param completion completion
+ (NSURLSessionDataTask *)queryRelaxAudioListWithCompletion:(void (^)(RelaxTrainRequestModel *requestModel))completion;
/// 睡眠-AI教练任务更新操作步骤接口
/// @param params @{@"title":xxx, @"step":xxx}
/// @param completion completion
+ (NSURLSessionDataTask *)userCurTaskStateWithParams:(NSDictionary *)params completion:(void (^)(RelaxTrainRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainRequestModel.m
// DreamSleep
//
// Created by peter on 2022/6/2.
//
#import "RelaxTrainRequestModel.h"
@implementation RelaxTrainRequestModel
+ (NSURLSessionDataTask *)queryRelaxAudioListWithCompletion:(void (^)(RelaxTrainRequestModel *requestModel))completion {
RelaxTrainRequestModel * requestModel = [[RelaxTrainRequestModel alloc] init];
NSString *api = @"query_relax_audio_list";
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 (NSDictionary *audioDic in resultArr) {
RelaxTrainModel *trainModel = [RelaxTrainModel yy_modelWithDictionary:audioDic];
[tmpArr addObject:trainModel];
}
requestModel.trainAudioList = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)userCurTaskStateWithParams:(NSDictionary *)params completion:(void (^)(RelaxTrainRequestModel *requestModel))completion {
RelaxTrainRequestModel * requestModel = [[RelaxTrainRequestModel alloc] init];
NSString *api = @"user_cur_task_state";
NSString *title = params[@"title"];
int step = [params[@"step"] intValue];
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(title:\"%@\",step:%d)}", api, title, step];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"睡眠-AI教练任务更新操作步骤接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
@end
//
// RelaxBodyView.h
// DreamSleep
//
// Created by peter on 2022/6/6.
//
#import <UIKit/UIKit.h>
#import "RelaxTrainModel.h"
NS_ASSUME_NONNULL_BEGIN
@protocol RelaxBodyViewDelegate <NSObject>
- (void)updateNaviTitleAndBgImg:(RelaxTrainModel *)trainModel;
@end
/// 放松body主视图
@interface RelaxBodyView : UIView
@property (nonatomic, weak) id<RelaxBodyViewDelegate> delegate;
- (void)refreshData:(NSArray *)listArr currentIndex:(NSInteger)index;
/// title和step参数
@property (nonatomic, strong) NSDictionary *updateParams;
/// 页面退出时停止音频播放
- (void)stopAudio;
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainCell.h
// DreamSleep
//
// Created by peter on 2022/6/6.
//
#import <UIKit/UIKit.h>
#import "RelaxTrainModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 放松训练音频cell
@interface RelaxTrainCell : UICollectionViewCell
- (void)updateRelaxCell:(RelaxTrainModel *)trainModel isShowPlayIcon:(BOOL)isShowPlayIcon;
@end
NS_ASSUME_NONNULL_END
//
// RelaxTrainCell.m
// DreamSleep
//
// Created by peter on 2022/6/6.
//
#import "RelaxTrainCell.h"
@interface RelaxTrainCell ()
// 主圆角图片
@property (nonatomic, strong) UIImageView *homeIV;
// 音频名标签
@property (nonatomic, strong) UILabel *audioNameLab;
@property (nonatomic, strong) UIImageView *recIcon;
@property (nonatomic, strong) UILabel *recLab;
@property (nonatomic, strong) UIImageView *playIcon;
@end
@implementation RelaxTrainCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self.contentView addSubview:self.homeIV];
[self.contentView addSubview:self.audioNameLab];
[self.contentView addSubview:self.recIcon];
[self.contentView addSubview:self.recLab];
[self.contentView addSubview:self.playIcon];
[self.homeIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView);
make.left.equalTo(self.contentView);
make.width.height.equalTo(@(120));
}];
[self.audioNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.homeIV);
make.top.equalTo(self.homeIV.mas_bottom).offset(8);
}];
[self.recIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.homeIV);
make.left.equalTo(self.homeIV).offset(11);
}];
[self.recLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.equalTo(self.recIcon);
}];
[self.playIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.homeIV);
}];
}
return self;
}
- (void)updateRelaxCell:(RelaxTrainModel *)trainModel isShowPlayIcon:(BOOL)isShowPlayIcon {
[self.homeIV yy_setImageWithURL:[NSURL URLWithString:trainModel.bg_url] placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
self.audioNameLab.text = trainModel.audio_name;
self.recIcon.hidden = [trainModel.is_recommend isEqualToString:@"0"];
self.recLab.hidden = [trainModel.is_recommend isEqualToString:@"0"];
self.playIcon.hidden = !isShowPlayIcon;
}
#pragma mark - lazy
- (UIImageView *)homeIV {
if (!_homeIV) {
_homeIV = [UIImageView new];
_homeIV.contentMode = UIViewContentModeScaleAspectFill;
[_homeIV cornerRadius:12.0];
_homeIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, .5);
}
return _homeIV;
}
- (UILabel *)audioNameLab {
if (!_audioNameLab) {
_audioNameLab = [UILabel labWithFont:SysFont(15)];
_audioNameLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite);
}
return _audioNameLab;
}
- (UIImageView *)recIcon {
if (!_recIcon) {
_recIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"relax_rec_icon"]];
}
return _recIcon;
}
- (UILabel *)recLab {
if (!_recLab) {
_recLab = [UILabel labWithText:@"优选" textColor:DSWhite font:SysFont(12.0)];
_recLab.textAlignment = NSTextAlignmentCenter;
}
return _recLab;
}
- (UIImageView *)playIcon {
if (!_playIcon) {
_playIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"relax_play_show"]];
}
return _playIcon;
}
@end
//
// ReadyListController.h
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "DSNaviBarViewController.h"
NS_ASSUME_NONNULL_BEGIN
@protocol ReadyListControllerDelegate <NSObject>
@end
/// 睡前准备设置列表页
@interface ReadyListController : DSNaviBarViewController
@property (nonatomic, weak) id<ReadyListControllerDelegate> delegate;
- (instancetype)initWithDelegate:(id<ReadyListControllerDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END
//
// ReadyListController.m
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "ReadyListController.h"
@interface ReadyListController ()
@end
@implementation ReadyListController
- (instancetype)initWithDelegate:(id<ReadyListControllerDelegate>)delegate {
if (self = [super init]) {
_delegate = delegate;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.naviTitle = @"设置睡前准备";
self.naviBarAlpha = 1.0;
self.dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(BrandColor, SubNaviDarkColor, BrandColor);
[self.dsNaviBar addSubview:self.backBtn];
self.titleLab.dk_textColorPicker = DKColorPickerWithKey(Sub_Navi_TITLE);
[self.backBtn dk_setImage:DKImagePickerWithNames(@"sys_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
@end
//
// SRTipsView.h
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 睡前准备建议弹框
@interface SRTipsView : UIView
- (void)showTipsAlertView;
@end
NS_ASSUME_NONNULL_END
//
// SRTipsView.m
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "SRTipsView.h"
@interface SRTipsView ()
@property (nonatomic, strong) UIView *alertView;
@property (nonatomic, strong) UIImageView *topIV;
@property (nonatomic, strong) UIImageView *midIV;
@property (nonatomic, strong) UILabel *tipsLab;
@property (nonatomic, strong) UIButton *gotBtn;
@property (nonatomic, strong) UIButton *closeBtn;
@end
@implementation SRTipsView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
self.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0x6F7587), DSClearColor, DSWhite);
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
[self addSubview:self.alertView];
[self.alertView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.equalTo(@280);
make.height.mas_greaterThanOrEqualTo(100);
}];
}
return self;
}
- (void)showTipsAlertView {
[DSKeyWindow addSubview:self];
}
- (void)dismissTipsAlertView {
[self removeFromSuperview];
}
#pragma mark - lazy
- (UIView *)alertView {
if (!_alertView) {
_alertView = [UIView new];
_alertView.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, AlertDarkColor, DSWhite);
[_alertView cornerRadius:23.0];
[_alertView addSubview:self.topIV];
[_alertView addSubview:self.midIV];
[_alertView addSubview:self.tipsLab];
[_alertView addSubview:self.gotBtn];
[_alertView addSubview:self.closeBtn];
[self.topIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(_alertView);
}];
[self.midIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_alertView);
make.top.equalTo(@75);
}];
[self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_alertView).offset(15);
make.right.equalTo(_alertView).offset(-15);
make.top.equalTo(self.midIV.mas_bottom).offset(15);
}];
[self.gotBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_alertView);
make.top.equalTo(self.tipsLab.mas_bottom).offset(30);
make.bottom.equalTo(_alertView).offset(-24);
make.size.mas_equalTo(CGSizeMake(155, 40));
}];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_alertView).offset(15);
make.right.equalTo(_alertView).offset(-15);
}];
}
return _alertView;
}
- (UIImageView *)topIV {
if (!_topIV) {
_topIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_pop"]];
}
return _topIV;
}
- (UIImageView *)midIV {
if (!_midIV) {
_midIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_pop_light"]];
}
return _midIV;
}
- (UILabel *)tipsLab {
if (!_tipsLab) {
NSString *tips = @"我们无法掌握入睡后的行动,却可以通过睡前30分钟的放松活动帮助放松大脑和身体,从而高效入眠。长期坚持,可有效改善睡眠质量。";
_tipsLab = [UILabel labWithText:tips font:SysFont(14.0) fit:YES];
_tipsLab.numberOfLines = 0;
_tipsLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
}
return _tipsLab;
}
- (UIButton *)gotBtn {
if (!_gotBtn) {
WS(weakSelf);
_gotBtn = [UIButton btnWithTitle:@"我知道了" font:BoldFont(16.0)];
[_gotBtn cornerRadius:20.0];
[_gotBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)];
[_gotBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_gotBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf dismissTipsAlertView];
}];
}
return _gotBtn;
}
- (UIButton *)closeBtn {
if (!_closeBtn) {
WS(weakSelf);
_closeBtn = [UIButton new];
[_closeBtn dk_setImage:DKImagePickerWithNames(@"dk_home_close", @"home_close", @"home_close") forState:UIControlStateNormal];
[_closeBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf dismissTipsAlertView];
}];
}
return _closeBtn;
}
@end
//
// SleepReadyController.h
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "DSNaviBarViewController.h"
NS_ASSUME_NONNULL_BEGIN
/// 安睡准备页面
@interface SleepReadyController : DSNaviBarViewController
@end
NS_ASSUME_NONNULL_END
//
// SleepReadyController.m
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "SleepReadyController.h"
#import "SRTipsView.h"
#import "ReadyListController.h"
#import "SRTipsView.h"
@interface SleepReadyController () <ReadyListControllerDelegate>
@property (nonatomic, strong) UIImageView *headIV;
@property (nonatomic, strong) UIButton *tipsBtn;
@property (nonatomic, strong) UIButton *setBtn;
@property (nonatomic, strong) SRTipsView *sRTipsView;
@property (nonatomic, strong) UIButton *startBtn;
@property (nonatomic, strong) UIButton *musicBtn;
@end
@implementation SleepReadyController
- (void)viewDidLoad {
[super viewDidLoad];
self.naviTitle = @"睡前准备";
self.naviBarAlpha = 1.0;
self.dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(DSClearColor, DSClearColor, DSWhite);
[self.dsNaviBar addSubview:self.backBtn];
self.titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
[self.dsNaviBar addSubview:self.tipsBtn];
[self.dsNaviBar addSubview:self.setBtn];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view insertSubview:self.headIV atIndex:0];
[self.view addSubview:self.startBtn];
[self.view addSubview:self.musicBtn];
[self.tipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.titleLab);
}];
[self.setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.tipsBtn);
make.left.equalTo(self.tipsBtn.mas_right).offset(24);
make.right.equalTo(self.view).offset(-15);
}];
[self.headIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
}];
[self.startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(155, 40));
make.centerX.equalTo(self.view);
make.bottom.equalTo(self.view).offset(-94-Bottom_SafeArea_Height);
}];
[self.musicBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.startBtn);
make.right.equalTo(self.view).offset(-15);
}];
}
#pragma mark - ReadyListControllerDelegate
#pragma mark - lazy
- (UIImageView *)headIV {
if (!_headIV) {
_headIV = [UIImageView new];
_headIV.dk_imagePicker = DKImagePickerWithNames(@"bg_anshui_start", @"dk_bg_anshui_start", @"bg_anshui_start");
}
return _headIV;
}
- (UIButton *)tipsBtn {
if (!_tipsBtn) {
WS(weakSelf);
_tipsBtn = [UIButton new];
[_tipsBtn dk_setImage:DKImagePickerWithNames(@"ic_zhunbei_zhushi", @"dk_ic_zhunbei_zhushi", @"ic_zhunbei_zhushi") forState:UIControlStateNormal];
[_tipsBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf.sRTipsView showTipsAlertView];
}];
}
return _tipsBtn;
}
- (UIButton *)setBtn {
if (!_setBtn) {
WS(weakSelf);
_setBtn = [UIButton new];
[_setBtn dk_setImage:DKImagePickerWithNames(@"ic_zhunbei_set", @"dk_ic_zhunbei_set", @"ic_zhunbei_set") forState:UIControlStateNormal];
[_setBtn addTouchUpInsideHandler:^(NSInteger tag) {
ReadyListController *setListVC = [[ReadyListController alloc] initWithDelegate:weakSelf];
[weakSelf.navigationController pushViewController:setListVC animated:YES];
}];
}
return _setBtn;
}
- (SRTipsView *)sRTipsView {
if (!_sRTipsView) {
_sRTipsView = [SRTipsView new];
}
return _sRTipsView;
}
- (UIButton *)startBtn {
if (!_startBtn) {
WS(weakSelf);
_startBtn = [UIButton btnWithTitle:@"开始仪式" font:BoldFont(16.0)];
[_startBtn cornerRadius:20.0];
[_startBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)];
[_startBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_startBtn addTouchUpInsideHandler:^(NSInteger tag) {
// [weakSelf dismissTipsAlertView];
}];
}
return _startBtn;
}
- (UIButton *)musicBtn {
if (!_musicBtn) {
_musicBtn = [UIButton new];
[_musicBtn setImage:[UIImage imageNamed:@"ic_zhunbei_baizaoyin"] forState:UIControlStateNormal];
[_musicBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
}
return _musicBtn;
}
@end
......@@ -124,7 +124,7 @@
UIButton *modifyBtn = [UIButton btnWithTitle:@"点击修改信息" font:SysFont(12)];
modifyBtn.userInteractionEnabled = NO;
[modifyBtn dk_setTitleColorPicker:DKColorPickerWithColors(BrandColor, ColorFromHex(0x45A4B5), DSWhite) forState:UIControlStateNormal];
[modifyBtn dk_setTitleColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite) forState:UIControlStateNormal];
[modifyBtn dk_setImage:DKImagePickerWithNames(@"ic_person_more_normal", @"dk_ic_person_more_normal", @"ic_person_more_normal") forState:UIControlStateNormal];
[modifyBtn adjustLayoutWithType:UIButtonLayoutTypeLeftTitleRightImage midSpace:4 sizeToFit:YES];
CGFloat width = modifyBtn.titleLabel.width + 30 + 4;
......
......@@ -129,7 +129,7 @@
self.state = state;
BOOL isEnable = YES;
NSString *btn_title = @"去完成";
DKColorPicker dk_bg_color = DKColorPickerWithColors(BrandColor, ColorFromHex(0x45A4B5), DSWhite);
DKColorPicker dk_bg_color = DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite);
DKColorPicker dk_title_color = DKColorPickerWithColors(DSWhite, DSWhite, DSWhite);
if (state == 1) {
btn_title = @"待领取";
......
......@@ -176,8 +176,8 @@
if (!_endBtn) {
WS(weakSelf);
_endBtn = [UIButton btnWithTitle:@"我知道了" font:BoldFont(16.0)];
[_endBtn cornerRadius:22.0];
[_endBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, ColorFromHex(0x45A4B5), DSWhite)];
[_endBtn cornerRadius:20.0];
[_endBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)];
[_endBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_endBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf dismissRulesAlertView];
......
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "bg_anshui_start.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "bg_anshui_start@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "bg_anshui_start@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "bg_pop.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "bg_pop@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "bg_pop@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_bg_anshui_start.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_bg_anshui_start@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_bg_anshui_start@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_zhunbei_set.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_zhunbei_set@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_zhunbei_set@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_zhunbei_zhushi.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_zhunbei_zhushi@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_zhunbei_zhushi@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_pop_light.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_pop_light@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_pop_light@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_zhunbei_baizaoyin.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_zhunbei_baizaoyin@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_zhunbei_baizaoyin@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_zhunbei_set.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_zhunbei_set@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_zhunbei_set@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_zhunbei_zhushi.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_zhunbei_zhushi@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_zhunbei_zhushi@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -10,6 +10,8 @@ NORMAL NIGHT RED
#AAAAAA #FFFFFF #000000 SubTEXT
#FFFFFF #333333 #000000 APPLE_TEXT
#333333 #E8E9E9 #000000 Dk_TITLE
#FFFFFF #E8E9E9 #000000 Sub_Navi_TITLE
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!