Commit 26389133 cgx

完成安睡准备功能模块

1 个父辈 42e0760a
......@@ -2591,7 +2591,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
......@@ -2673,7 +2673,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO;
......@@ -2814,7 +2814,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
......
......@@ -8,13 +8,13 @@
#import "ReadyListController.h"
#import "SleepReadyRequestModel.h"
#import "RelaxItemsView.h"
#import "ReadyItem.h"
#import "PrepareItemsCell.h"
@interface ReadyListController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) RelaxItemsView *relaxItemsView;
@property (nonatomic, strong) UITableView *prepareItemsView;
@property (nonatomic, strong) NSArray *prepare_items;
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
@end
@implementation ReadyListController
......@@ -37,30 +37,28 @@
[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];
[self.view addSubview:self.relaxItemsView];
[self.view addSubview:self.prepareItemsView];
[self queryPreparePeaceListRequest];
}
- (void)queryPreparePeaceListRequest {
[SleepReadyRequestModel queryPreparePeaceListWithCompletion:^(SleepReadyRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self.prepareItemsView.mj_header endRefreshing];
self.exceptionView.hidden = YES;
self.prepare_items = requestModel.prepare_items;
[self.view addSubview:self.relaxItemsView];
[self.view addSubview:self.prepareItemsView];
[self.relaxItemsView adjustRelax:requestModel.relax_items relaxTime:requestModel.relax_time];
[self.prepareItemsView reloadData];
} else {
self.exceptionView.hidden = NO;
[self.exceptionView showServerErrInfo:requestModel.errMessage];
}
}];
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
#pragma mark - UITableViewDataSource && UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.prepare_items.count;
......@@ -118,6 +116,8 @@
_prepareItemsView.dataSource = self;
_prepareItemsView.delegate = self;
[_prepareItemsView registerClass:[PrepareItemsCell class] forCellReuseIdentifier:NSStringFromClass([PrepareItemsCell class])];
_prepareItemsView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 12)];
_prepareItemsView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 12)];
}
return _prepareItemsView;
}
......@@ -129,6 +129,17 @@
return _prepare_items;
}
- (ExceptionDefaultView *)exceptionView {
if (!_exceptionView) {
WS(weakSelf);
_exceptionView = [[ExceptionDefaultView alloc] initWithType:ExceptionTypeNet block:^{
weakSelf.exceptionView.hidden = YES;
[weakSelf queryPreparePeaceListRequest];
} superView:self.view];
}
return _exceptionView;
}
#pragma mark - others
- (NSUInteger)getIndex:(int)itemID {
NSArray *relax_items = self.relaxItemsView.has_relax_items;
......@@ -143,7 +154,13 @@
}
- (void)backAction {
if (self.prepare_items.count == 0) {
[super backAction];
return;
}
[DSProgressHUD showProgressHUDWithInfo:@""];
[SleepReadyRequestModel userSetupPrepareItems:self.relaxItemsView.has_relax_items completion:^(SleepReadyRequestModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
if (self.delegate && [self.delegate respondsToSelector:@selector(passAdjustedReadyItems:)]) {
[self.delegate passAdjustedReadyItems:self.relaxItemsView.has_relax_items];
......@@ -154,4 +171,9 @@
}];
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
@end
......@@ -14,6 +14,7 @@
#import "StartReadyView.h"
#import "ReadyItemView.h"
#import "RelaxTrainController.h"
#import "SleepReadyRequestModel.h"
@interface SleepReadyController () <ReadyListControllerDelegate, StartReadyViewDelegate, ReadyItemViewDelegate>
@property (nonatomic, strong) UIButton *tipsBtn;
......@@ -37,6 +38,8 @@
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
// 获取白噪音类型请求
[self queryRelaxWhiteNoiseType];
// 获取睡前准备任务items数据
[self getUserPrepareSleepItemsRequest];
}
- (void)queryRelaxWhiteNoiseType {
......@@ -48,16 +51,27 @@
}];
}
- (void)getUserPrepareSleepItemsRequest {
[SleepReadyRequestModel userPrepareSleepItemsWithCompletion:^(SleepReadyRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.adjustedItems = requestModel.relax_items;
[self.startReadyView updateAdjustView:self.adjustedItems];
}
}];
}
- (void)backAction {
// 暂停白噪音
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
// 刷新AI睡眠教练
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateAICoach object:nil];
// 退出当前页面
[super backAction];
}
#pragma mark - ReadyListControllerDelegate
- (void)passAdjustedReadyItems:(NSArray *)items {
if (items && items.count) {
if (items && [items isKindOfClass:[NSArray class]]) {
self.adjustedItems = items;
[self.startReadyView updateAdjustView:self.adjustedItems];
}
......@@ -100,6 +114,8 @@
}];
self.navigationController.viewControllers = [vcs copy];
}
// 暂停白噪音
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
// 刷新AI睡眠教练
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateAICoach object:nil];
}
......
......@@ -11,6 +11,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface SleepReadyRequestModel : DSNetworkTool
/// 放松准备顶部背景图
@property (nonatomic, copy) NSString *relax_bg;
/// 任务总时长
@property (nonatomic, assign) int relax_time;
/// 睡前规划任务项数据
......@@ -20,6 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 完成睡前准备后返回的数据
@property (nonatomic, strong) SRFinishModel *finishModel;
/// 获取开始睡前准备数据的接口
/// @param completion completion
+ (NSURLSessionDataTask *)userPrepareSleepItemsWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion;
/// 安睡准备设置页面列表数据
/// @param completion completion
+ (NSURLSessionDataTask *)queryPreparePeaceListWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion;
......@@ -32,10 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
/// 做完安睡准备更新状态接口
/// @param completion completion
+ (NSURLSessionDataTask *)userSetupPreparePeaceStatusWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion;
/// 获取开始睡前准备数据的接口
/// @param completion completion
+ (NSURLSessionDataTask *)userPrepareSleepItemsWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
......@@ -10,11 +10,35 @@
@implementation SleepReadyRequestModel
+ (NSURLSessionDataTask *)userPrepareSleepItemsWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion {
SleepReadyRequestModel * requestModel = [[SleepReadyRequestModel alloc] init];
NSString *api = @"user_prepare_sleep_items";
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;
NSDictionary *resultDic = apiDic[@"result"];
requestModel.relax_bg = resultDic[@"relax_bg"];
NSArray *relax_items = resultDic[@"relax_items"];
NSMutableArray *tmp_relax_items = [NSMutableArray array];
for (int i = 0; i < relax_items.count; i++) {
ReadyItem *readyItem = [ReadyItem yy_modelWithJSON:relax_items[i]];
[tmp_relax_items addObject:readyItem];
}
requestModel.relax_items = [tmp_relax_items copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)queryPreparePeaceListWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion {
SleepReadyRequestModel * requestModel = [[SleepReadyRequestModel alloc] init];
NSString *api = @"query_prepare_peace_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) {
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"安睡准备设置页面列表数据接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
......@@ -83,19 +107,4 @@
}];
}
+ (NSURLSessionDataTask *)userPrepareSleepItemsWithCompletion:(void (^)(SleepReadyRequestModel *requestModel))completion {
SleepReadyRequestModel * requestModel = [[SleepReadyRequestModel alloc] init];
NSString *api = @"user_prepare_sleep_items";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@}", 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;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
@end
......@@ -115,6 +115,8 @@
if (requestModel.resCode == DSResCodeSuccess) {
[self.circleProgress stopTimer];
[self.srDoneAlertView showSleepReadyFinishView:requestModel.finishModel];
// 暂停白噪音
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
}
}];
}
......
{
"images" : [
{
"filename" : "ai_anshui_xizao.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ai_anshui_xizao@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ai_anshui_xizao@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ai_anshui_xizao.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ai_anshui_xizao@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ai_anshui_xizao@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!