Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 03525e60
由
cgx
编写于
2022-06-07 11:37:32 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
梳理业务逻辑
1 个父辈
4ff6808d
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
81 行增加
和
33 行删除
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
DreamSleep/DreamSleep/Class/AISleepModule/RelaxBodyView.m
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainCell.h
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainCell.m
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainController.h
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainController.m
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/MusicPlayerController.m
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show@3x.png
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
查看文件 @
03525e6
...
...
@@ -13,7 +13,7 @@
#import "ThreeMinuteController.h"
#import "UserRequestModel.h"
@interface
AISleepCoachController
()
<
WKNavigationDelegate
,
WKScriptMessageHandler
,
DsWebControllerDelegate
>
@interface
AISleepCoachController
()
<
WKNavigationDelegate
,
WKScriptMessageHandler
,
DsWebControllerDelegate
,
RelaxTrainControllerDelegate
>
@property
(
strong
,
nonatomic
)
WKWebView
*
aiWebView
;
@property
(
strong
,
nonatomic
)
NSMutableURLRequest
*
request
;
@property
(
strong
,
nonatomic
)
UIProgressView
*
progressView
;
...
...
@@ -87,7 +87,7 @@
}
}
#pragma mark - DsWebControllerDelegate
#pragma mark - DsWebControllerDelegate
&& RelaxTrainControllerDelegate
-
(
void
)
reloadAIPage
{
[
self
.
aiWebView
reload
];
}
...
...
@@ -171,6 +171,7 @@
case
5
:
// 练习腹式呼吸法
{
RelaxTrainController
*
relaxVC
=
[
RelaxTrainController
new
];
relaxVC
.
refreshDelegate
=
self
;
[
self
.
navigationController
pushViewController
:
relaxVC
animated
:
YES
];
}
break
;
...
...
DreamSleep/DreamSleep/Class/AISleepModule/RelaxBodyView.m
查看文件 @
03525e6
...
...
@@ -9,6 +9,7 @@
#import "RelaxTrainModel.h"
#import <FSAudioController.h>
#import "RelaxTrainCell.h"
#import "RelaxTrainRequestModel.h"
@interface
RelaxBodyView
()
<
UIGestureRecognizerDelegate
,
UICollectionViewDelegate
,
UICollectionViewDataSource
>
@property
(
nonatomic
,
strong
)
UIButton
*
playerBtn
;
...
...
@@ -25,6 +26,7 @@
@property
(
nonatomic
,
strong
)
UICollectionView
*
relaxCollectionView
;
@property
(
nonatomic
,
strong
)
NSArray
*
relaxList
;
@property
(
nonatomic
,
assign
)
NSInteger
curIndex
;
@property
(
nonatomic
,
assign
)
BOOL
isUpdateTask
;
@end
@implementation
RelaxBodyView
{
...
...
@@ -103,7 +105,7 @@
}
-
(
void
)
playControlAction
:
(
UIButton
*
)
sender
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
)
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
||
self
.
streamState
==
kFsAudioStreamRetrievingURL
)
{
[
self
.
audioStream
play
];
}
else
if
(
self
.
streamState
==
kFsAudioStreamPlaying
)
{
// 暂停播放
...
...
@@ -144,15 +146,7 @@
if
(
listArr
.
count
&&
index
<
listArr
.
count
)
{
self
.
curIndex
=
index
;
RelaxTrainModel
*
relaxModel
=
listArr
[
index
];
[
self
refreshTopData
:
relaxModel
];
// self.titleLab.text = relaxModel.audio_name;
// NSString *audio_desc = [[NSString stringWithFormat:@"%@", relaxModel.audio_desc] stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"];
// self.tipsLab.height = [NSString getHeightWithText:audio_desc withFont:SysFont(14.0) withMaxWidth:kScreenWidth - 30];
// self.tipsLab.text = audio_desc;
//
// // 不是正在播放的状态需要先停止
// if (self.audioStream.isPlaying == NO) { [self.audioStream stop]; }
// [self.audioStream playFromURL:[NSURL URLWithString:relaxModel.audio_url]];
[
self
refreshTopData
:
relaxModel
isStartPlay
:
NO
];
self
.
relaxList
=
listArr
;
[
self
.
relaxCollectionView
reloadData
];
...
...
@@ -166,7 +160,7 @@
[
self
.
audioStream
stop
];
}
-
(
void
)
refreshTopData
:
(
RelaxTrainModel
*
)
relaxModel
{
-
(
void
)
refreshTopData
:
(
RelaxTrainModel
*
)
relaxModel
isStartPlay
:
(
BOOL
)
isStartPlay
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
updateNaviTitleAndBgImg
:)])
{
[
self
.
delegate
updateNaviTitleAndBgImg
:
relaxModel
];
}
...
...
@@ -178,7 +172,8 @@
// 不是正在播放的状态需要先停止
if
(
self
.
audioStream
.
isPlaying
==
NO
)
{
[
self
.
audioStream
stop
];
}
[
self
.
audioStream
playFromURL
:[
NSURL
URLWithString
:
relaxModel
.
audio_url
]];
self
.
audioStream
.
url
=
[
NSURL
URLWithString
:
relaxModel
.
audio_url
];
if
(
isStartPlay
)
{
[
self
.
audioStream
play
];
}
}
#pragma mark - UIGestureRecognizerDelegate
...
...
@@ -224,7 +219,7 @@
-
(
UICollectionViewCell
*
)
collectionView
:
(
UICollectionView
*
)
collectionView
cellForItemAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
RelaxTrainCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
NSStringFromClass
([
RelaxTrainCell
class
])
forIndexPath
:
indexPath
];
cell
.
trainModel
=
self
.
relaxList
[
indexPath
.
row
];
[
cell
updateRelaxCell
:
self
.
relaxList
[
indexPath
.
row
]
isShowPlayIcon
:(
self
.
curIndex
==
indexPath
.
row
)
];
return
cell
;
}
...
...
@@ -234,7 +229,8 @@
}
self
.
curIndex
=
indexPath
.
row
;
RelaxTrainModel
*
relaxModel
=
[
self
.
relaxList
objectAtIndex
:
indexPath
.
row
];
[
self
refreshTopData
:
relaxModel
];
[
self
refreshTopData
:
relaxModel
isStartPlay
:
YES
];
[
self
.
relaxCollectionView
reloadData
];
}
#pragma mark - lazy
...
...
@@ -337,6 +333,17 @@
case
kFsAudioStreamPlaying
:
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
DSLog
(
@"播放ing..."
);
// 更新腹式呼吸放松法任务状态
if
(
weakSelf
.
isUpdateTask
==
NO
)
{
#warning - 需要梳理业务逻辑
[
RelaxTrainRequestModel
userCurTaskStateWithParams
:@{
@"title"
:
@"腹式呼吸放松法"
,
@"step"
:
@2
}
completion
:
^
(
RelaxTrainRequestModel
*
_Nonnull
requestModel
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
weakSelf
.
isUpdateTask
=
YES
;
}
}];
}
break
;
case
kFsAudioStreamFailed
:
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
...
...
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainCell.h
查看文件 @
03525e6
...
...
@@ -12,7 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
/// 放松训练音频cell
@interface
RelaxTrainCell
:
UICollectionViewCell
@property
(
nonatomic
,
strong
)
RelaxTrainModel
*
trainModel
;
-
(
void
)
updateRelaxCell
:(
RelaxTrainModel
*
)
trainModel
isShowPlayIcon
:(
BOOL
)
isShowPlayIcon
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainCell.m
查看文件 @
03525e6
...
...
@@ -14,20 +14,22 @@
@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
addSubview
:
self
.
homeIV
];
[
self
addSubview
:
self
.
audioNameLab
];
[
self
addSubview
:
self
.
recIcon
];
[
self
addSubview
:
self
.
recLab
];
[
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
);
make
.
left
.
equalTo
(
self
.
contentView
);
make
.
width
.
height
.
equalTo
(
@
(
120
));
}];
[
self
.
audioNameLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
...
...
@@ -41,16 +43,19 @@
[
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
)
setTrainModel
:(
RelaxTrainModel
*
)
trainModel
{
_trainModel
=
trainModel
;
-
(
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
...
...
@@ -87,4 +92,11 @@
return
_recLab
;
}
-
(
UIImageView
*
)
playIcon
{
if
(
!
_playIcon
)
{
_playIcon
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamed
:
@"relax_play_show"
]];
}
return
_playIcon
;
}
@end
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainController.h
查看文件 @
03525e6
...
...
@@ -9,9 +9,14 @@
NS_ASSUME_NONNULL_BEGIN
@protocol
RelaxTrainControllerDelegate
<
NSObject
>
/// 刷新AI睡眠教练页面
-
(
void
)
reloadAIPage
;
@end
/// 放松训练、腹式呼吸法页面
@interface
RelaxTrainController
:
DSBaseViewController
@property
(
nonatomic
,
weak
)
id
<
RelaxTrainControllerDelegate
>
refreshDelegate
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/AISleepModule/RelaxTrainController.m
查看文件 @
03525e6
...
...
@@ -53,17 +53,15 @@
}
}
}];
#warning - 需要梳理业务逻辑
[
RelaxTrainRequestModel
userCurTaskStateWithParams
:@{
@"title"
:
@"腹式呼吸放松法"
,
@"step"
:
@2
}
completion
:
^
(
RelaxTrainRequestModel
*
_Nonnull
requestModel
)
{
}];
}
#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
];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/MusicPlayerController.m
查看文件 @
03525e6
...
...
@@ -180,7 +180,7 @@
break
;
case
2
:
// 播放暂停
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
)
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
||
self
.
streamState
==
kFsAudioStreamRetrievingURL
)
{
[
self
.
audioStream
play
];
}
else
if
(
self
.
streamState
==
kFsAudioStreamPlaying
)
{
// 暂停播放
...
...
@@ -237,7 +237,7 @@
// 点击当前传过来音频
if
(
self
.
currentIndex
==
index
)
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
)
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
||
self
.
streamState
==
kFsAudioStreamRetrievingURL
)
{
[
self
.
audioStream
play
];
}
else
if
(
self
.
streamState
==
kFsAudioStreamPaused
)
{
// 恢复播放
...
...
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/Contents.json
0 → 100644
查看文件 @
03525e6
{
"images"
:
[
{
"filename"
:
"relax_play_show.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"relax_play_show@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"relax_play_show@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show.png
0 → 100644
查看文件 @
03525e6
250 字节
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show@2x.png
0 → 100644
查看文件 @
03525e6
471 字节
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/relax_play_show.imageset/relax_play_show@3x.png
0 → 100644
查看文件 @
03525e6
756 字节
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论