Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f555a88d
由
cgx
编写于
2022-06-15 16:46:30 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化均衡呼吸法、478呼吸法
1 个父辈
6aa13382
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
64 行增加
和
23 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Basement/EventTrack/DataStatisticsUtil.h
DreamSleep/DreamSleep/Basement/EventTrack/DataStatisticsUtil.m
DreamSleep/DreamSleep/Class/HomeModule/BreathingMethod/BreathTextView.h
DreamSleep/DreamSleep/Class/HomeModule/BreathingMethod/BreatheController.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
f555a88
...
...
@@ -1535,10 +1535,10 @@
children = (
D0F808F42803D4E70097899F /* Track.h */,
D0F808F32803D4E70097899F /* Track.m */,
D0C09EDE28007E5F00709D4C /* BreatheController.h */,
D0C09EDF28007E5F00709D4C /* BreatheController.m */,
D091BBB52808F9DA00487A50 /* BreathTextView.h */,
D091BBB62808F9DA00487A50 /* BreathTextView.m */,
D0C09EDE28007E5F00709D4C /* BreatheController.h */,
D0C09EDF28007E5F00709D4C /* BreatheController.m */,
);
path = BreathingMethod;
sourceTree = "<group>";
...
...
DreamSleep/DreamSleep/Basement/EventTrack/DataStatisticsUtil.h
查看文件 @
f555a88
...
...
@@ -42,7 +42,6 @@ FOUNDATION_EXTERN NSString * const RelaxTrain;
+
(
void
)
event
:(
NSString
*
)
eventId
attributes
:(
NSDictionary
*
)
attributes
;
+
(
void
)
event
:(
NSString
*
)
eventId
label
:(
NSString
*
)
label
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Basement/EventTrack/DataStatisticsUtil.m
查看文件 @
f555a88
...
...
@@ -27,17 +27,9 @@ NSString * const RelaxTrain = @"RelaxTrain";
+
(
void
)
event
:(
NSString
*
)
eventId
attributes
:(
NSDictionary
*
)
attributes
{
// 只统计正式环境的数据
#if OPEN_DATA_STATISTICS == 1
NSLog
(
@"eventId:%@, attributes:%@"
,
eventId
,
attributes
);
//
NSLog(@"eventId:%@, attributes:%@", eventId, attributes);
[
MobClick
event
:
eventId
attributes
:
attributes
];
#endif
}
+
(
void
)
event
:(
NSString
*
)
eventId
label
:(
NSString
*
)
label
{
// 只统计正式环境的数据
#if OPEN_DATA_STATISTICS == 1
NSLog
(
@"eventId:%@, label:%@"
,
eventId
,
label
);
[
MobClick
event
:
eventId
label
:
label
];
#endif
}
@end
DreamSleep/DreamSleep/Class/HomeModule/BreathingMethod/BreathTextView.h
查看文件 @
f555a88
...
...
@@ -8,7 +8,7 @@
typedef
NS_ENUM
(
NSInteger
,
LottieStyle
)
{
// 均衡呼吸法
LottieStyleBalance
,
// 舒睡呼吸法
// 舒睡呼吸法
4-7-8
LottieStyleComfortable
};
...
...
DreamSleep/DreamSleep/Class/HomeModule/BreathingMethod/BreatheController.m
查看文件 @
f555a88
...
...
@@ -23,14 +23,15 @@
// 分钟选择控件
@property
(
nonatomic
,
strong
)
UIPickerView
*
minutePickerView
;
@property
(
nonatomic
,
strong
)
NSArray
*
minuteDatas
;
@property
(
nonatomic
,
assign
)
NSInteger
currentIndex
;
@property
(
nonatomic
,
strong
)
UILabel
*
timeLb
;
@property
(
nonatomic
,
strong
)
UILabel
*
minuteLb
;
@property
(
nonatomic
,
strong
)
UIButton
*
startRelaxBtn
;
@property
(
nonatomic
,
strong
)
UIButton
*
volumeBtn
;
@property
(
nonatomic
,
strong
)
DOUAudioStreamer
*
audioStreamer
;
@property
(
nonatomic
,
strong
)
NSTimer
*
controlTimer
;
@property
(
nonatomic
,
assign
)
NSInteger
minuteTime
;
@property
(
nonatomic
,
assign
)
NSInteger
playDuration
;
@property
(
nonatomic
,
assign
)
NSInteger
currentTime
;
@end
@implementation
BreatheController
...
...
@@ -40,8 +41,10 @@
self
.
view
.
backgroundColor
=
DarkColor
;
self
.
minuteTime
=
1
;
self
.
minuteDatas
=
@[
@"1"
,
@"2"
,
@"3"
,
@"4"
,
@"5"
];
// 默认2分钟
self
.
currentIndex
=
1
;
self
.
currentTime
=
0
;
self
.
minuteDatas
=
@[
@"1"
,
@"2"
,
@"3"
,
@"4"
,
@"5"
];
self
.
rotateLottieFile
=
self
.
style
==
LottieStyleBalance
?
@"relax_normal_lottie.json"
:
@"478normal_lottie.json"
;
self
.
zoomLottieFile
=
self
.
style
==
LottieStyleBalance
?
@"relax_lottie.json"
:
@"478_lottie.json"
;
...
...
@@ -78,6 +81,14 @@
self
.
controlTimer
=
nil
;
if
(
self
.
audioStreamer
)
{
switch
(
self
.
audioStreamer
.
status
)
{
case
DOUAudioStreamerPlaying
:
{
[
self
.
audioStreamer
pause
];
}
break
;
default
:
break
;
}
[
self
.
audioStreamer
stop
];
[
self
.
audioStreamer
removeObserver
:
self
forKeyPath
:
@"status"
context
:
kStatusKVOKey1
];
self
.
audioStreamer
=
nil
;
...
...
@@ -89,6 +100,7 @@
[
self
.
view
addSubview
:
self
.
rotateView
];
[
self
.
view
addSubview
:
self
.
zoomView
];
[
self
.
view
addSubview
:
self
.
minutePickerView
];
[
self
.
minutePickerView
selectRow
:
self
.
currentIndex
inComponent
:
0
animated
:
YES
];
self
.
timeLb
=
[
UILabel
new
];
self
.
timeLb
.
text
=
@"放松时长"
;
...
...
@@ -167,17 +179,56 @@
[
self
.
zoomView
play
];
self
.
zoomView
.
hidden
=
NO
;
self
.
playDuration
=
self
.
minuteTime
*
60
;
self
.
controlTimer
=
[
NSTimer
scheduledTimerWithTimeInterval
:
1
target
:
self
selector
:
@selector
(
timerAction
:
)
userInfo
:
nil
repeats
:
YES
];
NSTimeInterval
interval
=
self
.
style
==
LottieStyleBalance
?
1
.
0
:
0
.
06
;
self
.
playDuration
=
[[
self
.
minuteDatas
objectAtIndex
:
self
.
currentIndex
]
integerValue
]
*
60
;
self
.
controlTimer
=
[
NSTimer
scheduledTimerWithTimeInterval
:
interval
target
:
self
selector
:
@selector
(
timerAction
:
)
userInfo
:
nil
repeats
:
YES
];
[
self
.
controlTimer
fire
];
[
self
.
audioStreamer
play
];
}
-
(
void
)
timerAction
:
(
NSTimer
*
)
timer
{
self
.
playDuration
--
;
if
(
self
.
playDuration
%
4
==
0
&&
self
.
playDuration
>=
0
)
{
if
(
self
.
style
==
LottieStyleBalance
)
{
/*
第0s、第5s震动,10s为一个周期,以s为单位
*/
// 周期数
NSInteger
cycle
=
self
.
currentTime
/
10
;
// 周期总时间
NSInteger
cycleTotalTime
=
10
*
cycle
;
if
(
self
.
currentTime
==
cycleTotalTime
||
self
.
currentTime
==
(
5
+
cycleTotalTime
))
{
AudioServicesPlaySystemSound
(
1520
);
DSLog
(
@"当前时间:%lds, 第%ld个周期->第1个震动时间点:%lds, 第2个震动时间点:%lds"
,
self
.
currentTime
,
cycle
+
1
,
cycleTotalTime
,
5
+
cycleTotalTime
);
}
if
(
self
.
playDuration
==
0
)
{
self
.
currentTime
++
;
if
(
self
.
currentTime
==
self
.
playDuration
)
{
[
self
stopBreathe
];
}
}
else
if
(
self
.
style
==
LottieStyleComfortable
)
{
/*
第0s、第3.06s、第8.16s这3个点需要震动,15s一个周期
第0ms、第3060ms、第8160ms,以ms为单位
求3者最大公约数:
3060 8160 1500
306 816 150 10
102 272 50 30
51 136 25 60
最大公约数:60ms,每间隔60ms执行
*/
// 周期数
NSInteger
cycle
=
self
.
currentTime
/
15000
;
// 周期总时间
NSInteger
cycleTotalTime
=
15000
*
cycle
;
if
(
self
.
currentTime
==
cycleTotalTime
||
self
.
currentTime
==
(
51
*
60
+
cycleTotalTime
)
||
self
.
currentTime
==
(
136
*
60
+
cycleTotalTime
))
{
AudioServicesPlaySystemSound
(
1520
);
DSLog
(
@"当前时间:%ldms, 第%ld个周期->第1个震动时间点:%ldms, 第2个震动时间点:%ldms, 第3个震动时间点:%ldms"
,
self
.
currentTime
,
cycle
+
1
,
cycleTotalTime
,
51
*
60
+
cycleTotalTime
,
136
*
60
+
cycleTotalTime
);
}
self
.
currentTime
+=
60
;
if
(
self
.
currentTime
>=
self
.
playDuration
*
1000
)
{
[
self
stopBreathe
];
}
}
}
-
(
void
)
stopBreathe
{
self
.
zoomView
.
animationProgress
=
0
;
self
.
zoomView
.
hidden
=
YES
;
self
.
rotateView
.
hidden
=
NO
;
...
...
@@ -187,7 +238,6 @@
self
.
minutePickerView
.
hidden
=
NO
;
[
self
cancelAudioStreamer
];
}
}
-
(
void
)
volumeControlAction
:
(
UIButton
*
)
sender
{
...
...
@@ -241,7 +291,7 @@
}
-
(
void
)
pickerView
:
(
UIPickerView
*
)
pickerView
didSelectRow
:
(
NSInteger
)
row
inComponent
:
(
NSInteger
)
component
{
self
.
minuteTime
=
[[
self
.
minuteDatas
objectAtIndex
:
row
]
integerValue
]
;
self
.
currentIndex
=
row
;
}
-
(
UIView
*
)
pickerView
:
(
UIPickerView
*
)
pickerView
viewForRow
:
(
NSInteger
)
row
forComponent
:
(
NSInteger
)
component
reusingView
:
(
UIView
*
)
view
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论