Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 8762676d
由
cgx
编写于
2022-05-23 17:46:59 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
AI睡眠教练添加遮罩
1 个父辈
56e45afb
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
76 行增加
和
14 行删除
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.m
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.h
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.m
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
DreamSleep/DreamSleep/Class/ProfileModule/Account/Controller/AccountController.m
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.m
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
查看文件 @
8762676
...
@@ -44,6 +44,11 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -44,6 +44,11 @@ NS_ASSUME_NONNULL_BEGIN
// 添加遮罩
// 添加遮罩
-
(
void
)
addMaskWithType
:(
MaskType
)
type
cornerRadius
:(
CGFloat
)
cornerRadius
;
-
(
void
)
addMaskWithType
:(
MaskType
)
type
cornerRadius
:(
CGFloat
)
cornerRadius
;
// 添加遮罩
-
(
void
)
addMask
;
// 移除遮罩
-
(
void
)
removeMask
;
-
(
void
)
setCornerRadiusRect
:(
UIRectCorner
)
rectCorner
cornerRadius
:(
CGFloat
)
cornerRadius
;
-
(
void
)
setCornerRadiusRect
:(
UIRectCorner
)
rectCorner
cornerRadius
:(
CGFloat
)
cornerRadius
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.m
查看文件 @
8762676
...
@@ -131,6 +131,31 @@
...
@@ -131,6 +131,31 @@
maskView
.
layer
.
mask
=
maskLayer
;
maskView
.
layer
.
mask
=
maskLayer
;
}
}
-
(
void
)
addMask
{
[
self
removeMask
];
UIView
*
maskView
=
[[
UIView
alloc
]
initWithFrame
:
self
.
bounds
];
maskView
.
backgroundColor
=
ColorFromHex
(
0x6B7485
);
maskView
.
alpha
=
.
5
;
maskView
.
tag
=
999
;
maskView
.
userInteractionEnabled
=
NO
;
[
self
addSubview
:
maskView
];
UIBezierPath
*
path
=
[
UIBezierPath
bezierPathWithRoundedRect
:
maskView
.
bounds
byRoundingCorners
:
UIRectCornerAllCorners
cornerRadii
:
CGSizeMake
(
0
,
0
)];
CAShapeLayer
*
maskLayer
=
[[
CAShapeLayer
alloc
]
init
];
maskLayer
.
frame
=
maskView
.
bounds
;
maskLayer
.
path
=
path
.
CGPath
;
maskView
.
layer
.
mask
=
maskLayer
;
}
-
(
void
)
removeMask
{
for
(
UIView
*
maskView
in
self
.
subviews
)
{
if
(
maskView
.
tag
==
999
)
{
[
maskView
removeFromSuperview
];
}
}
}
-
(
void
)
setCornerRadiusRect
:
(
UIRectCorner
)
rectCorner
cornerRadius
:
(
CGFloat
)
cornerRadius
{
-
(
void
)
setCornerRadiusRect
:
(
UIRectCorner
)
rectCorner
cornerRadius
:
(
CGFloat
)
cornerRadius
{
UIBezierPath
*
path
=
[
UIBezierPath
bezierPathWithRoundedRect
:
self
.
bounds
byRoundingCorners
:
rectCorner
cornerRadii
:
CGSizeMake
(
cornerRadius
,
cornerRadius
)];
UIBezierPath
*
path
=
[
UIBezierPath
bezierPathWithRoundedRect
:
self
.
bounds
byRoundingCorners
:
rectCorner
cornerRadii
:
CGSizeMake
(
cornerRadius
,
cornerRadius
)];
CAShapeLayer
*
maskLayer
=
[[
CAShapeLayer
alloc
]
init
];
CAShapeLayer
*
maskLayer
=
[[
CAShapeLayer
alloc
]
init
];
...
...
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.h
查看文件 @
8762676
...
@@ -44,6 +44,8 @@ FOUNDATION_EXTERN NSString * const NoisePlaylistHasChange;
...
@@ -44,6 +44,8 @@ FOUNDATION_EXTERN NSString * const NoisePlaylistHasChange;
FOUNDATION_EXTERN
NSString
*
const
NoiseTimingDidClick
;
FOUNDATION_EXTERN
NSString
*
const
NoiseTimingDidClick
;
// Unity
// Unity
FOUNDATION_EXTERN
NSString
*
const
ExitCoaxSleep
;
FOUNDATION_EXTERN
NSString
*
const
ExitCoaxSleep
;
// 刷新AI睡眠教练通知
FOUNDATION_EXTERN
NSString
*
const
NeedUpdateAICoach
;
// 用户基础信息
// 用户基础信息
FOUNDATION_EXTERN
NSString
*
const
UserBasicInfo
;
FOUNDATION_EXTERN
NSString
*
const
UserBasicInfo
;
...
...
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.m
查看文件 @
8762676
...
@@ -30,6 +30,7 @@ NSString * const NeedUpdateHomePage = @"NeedUpdateHomePageNoti";
...
@@ -30,6 +30,7 @@ NSString * const NeedUpdateHomePage = @"NeedUpdateHomePageNoti";
NSString
*
const
NoisePlaylistHasChange
=
@"NoisePlaylistHasChangeNoti"
;
NSString
*
const
NoisePlaylistHasChange
=
@"NoisePlaylistHasChangeNoti"
;
NSString
*
const
NoiseTimingDidClick
=
@"NoiseTimingDidClickNoti"
;
NSString
*
const
NoiseTimingDidClick
=
@"NoiseTimingDidClickNoti"
;
NSString
*
const
ExitCoaxSleep
=
@"ExitCoaxSleepNoti"
;
NSString
*
const
ExitCoaxSleep
=
@"ExitCoaxSleepNoti"
;
NSString
*
const
NeedUpdateAICoach
=
@"NeedUpdateAICoachNoti"
;
NSString
*
const
UserBasicInfo
=
@"UserBasicInfo"
;
NSString
*
const
UserBasicInfo
=
@"UserBasicInfo"
;
...
...
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
查看文件 @
8762676
...
@@ -11,7 +11,8 @@
...
@@ -11,7 +11,8 @@
@interface
AISleepCoachController
()
<
WKNavigationDelegate
,
WKScriptMessageHandler
,
WKUIDelegate
>
@interface
AISleepCoachController
()
<
WKNavigationDelegate
,
WKScriptMessageHandler
,
WKUIDelegate
>
@property
(
strong
,
nonatomic
)
WKWebView
*
aiWebView
;
@property
(
strong
,
nonatomic
)
WKWebView
*
aiWebView
;
@property
(
nonatomic
,
strong
)
UIProgressView
*
progressView
;
@property
(
strong
,
nonatomic
)
NSURLRequest
*
request
;
@property
(
strong
,
nonatomic
)
UIProgressView
*
progressView
;
@end
@end
@implementation
AISleepCoachController
@implementation
AISleepCoachController
...
@@ -22,10 +23,37 @@
...
@@ -22,10 +23,37 @@
// 创建WKWebView对象,添加到界面(storyboard没有控件)
// 创建WKWebView对象,添加到界面(storyboard没有控件)
[
self
.
view
addSubview
:
self
.
aiWebView
];
[
self
.
view
addSubview
:
self
.
aiWebView
];
[
self
.
view
addSubview
:
self
.
progressView
];
[
self
.
view
addSubview
:
self
.
progressView
];
// 监听AI睡眠教练页面需要刷新数据通知
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
needUpdateAiCoach
)
name
:
NeedUpdateAICoach
object
:
nil
];
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
[
self
.
aiWebView
removeObserver
:
self
forKeyPath
:
@"estimatedProgress"
];
[
self
.
aiWebView
removeObserver
:
self
forKeyPath
:
@"estimatedProgress"
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NeedUpdateAICoach
object
:
nil
];
}
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
// 夜间模式
if
([
self
.
dk_manager
.
themeVersion
isEqualToString
:
DKThemeVersionNight
])
{
[
self
.
aiWebView
addMask
];
}
else
{
[
self
.
aiWebView
removeMask
];
}
}
#pragma mark - js和oc交互
-
(
void
)
startOpen
{
if
(
!
[
LoginUtils
getUserLoginData
])
{
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
];
}
}
#pragma mark - 登录成功后刷新
-
(
void
)
needUpdateAiCoach
{
[
self
.
aiWebView
loadRequest
:
self
.
request
];
}
}
#pragma mark - WKWebView的监听方法
#pragma mark - WKWebView的监听方法
...
@@ -69,8 +97,8 @@
...
@@ -69,8 +97,8 @@
-
(
void
)
userContentController
:
(
WKUserContentController
*
)
userContentController
didReceiveScriptMessage
:
(
WKScriptMessage
*
)
message
{
-
(
void
)
userContentController
:
(
WKUserContentController
*
)
userContentController
didReceiveScriptMessage
:
(
WKScriptMessage
*
)
message
{
if
([
message
.
name
isEqualToString
:
@"click"
])
{
if
([
message
.
name
isEqualToString
:
@"click"
])
{
// NSDictionary *jsData = message.body;
// NSDictionary *jsData = message.body;
// NSLog(@"%@", message.name);
// NSLog(@"%@", message.name);
//读取js function的字符串
//读取js function的字符串
// NSString *jsFunctionString = jsData[@"result"];
// NSString *jsFunctionString = jsData[@"result"];
// //拼接调用该方法的js字符串(convertDictionaryToJson:方法将NSDictionary转成JSON格式的字符串)
// //拼接调用该方法的js字符串(convertDictionaryToJson:方法将NSDictionary转成JSON格式的字符串)
...
@@ -87,37 +115,32 @@
...
@@ -87,37 +115,32 @@
-
(
WKWebView
*
)
aiWebView
{
-
(
WKWebView
*
)
aiWebView
{
if
(
!
_aiWebView
)
{
if
(
!
_aiWebView
)
{
// _aiWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTabBarHeight)];
// _aiWebView.backgroundColor = DSWhite;
// 进行配置控制器
// 进行配置控制器
WKWebViewConfiguration
*
configuration
=
[[
WKWebViewConfiguration
alloc
]
init
];
WKWebViewConfiguration
*
configuration
=
[[
WKWebViewConfiguration
alloc
]
init
];
// 实例化对象
// 实例化对象
configuration
.
userContentController
=
[
WKUserContentController
new
];
configuration
.
userContentController
=
[
WKUserContentController
new
];
// 调用JS方法
// 调用JS方法
[
configuration
.
userContentController
addScriptMessageHandler
:
self
name
:
@"
click
"
];
[
configuration
.
userContentController
addScriptMessageHandler
:
self
name
:
@"
Android.jump2Native(2, 0)
"
];
// 进行偏好设置
// 进行偏好设置
WKPreferences
*
preferences
=
[
WKPreferences
new
];
WKPreferences
*
preferences
=
[
WKPreferences
new
];
preferences
.
javaScriptCanOpenWindowsAutomatically
=
YES
;
preferences
.
javaScriptCanOpenWindowsAutomatically
=
YES
;
preferences
.
javaScriptEnabled
=
YES
;
configuration
.
preferences
=
preferences
;
configuration
.
preferences
=
preferences
;
// 初始化WKWebView
// 初始化WKWebView
_aiWebView
=
[[
WKWebView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
-
kTabBarHeight
)
configuration
:
configuration
];
_aiWebView
=
[[
WKWebView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
-
kTabBarHeight
)
configuration
:
configuration
];
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
UIDelegate
=
self
;
_aiWebView
.
UIDelegate
=
self
;
_aiWebView
.
scrollView
.
bounces
=
NO
;
[
_aiWebView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
[
_aiWebView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
_aiWebView
.
navigationDelegate
=
self
;
_aiWebView
.
navigationDelegate
=
self
;
_aiWebView
.
scrollView
.
showsVerticalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsVerticalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsHorizontalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsHorizontalScrollIndicator
=
NO
;
// 解决页面顶部出现白色问题
// 解决页面顶部出现白色问题
_aiWebView
.
scrollView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
_aiWebView
.
scrollView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
self
.
request
=
[
NSURLRequest
requestWithURL
:[
NSURL
URLWithString
:
AICoachURL
]];
// 测试地址:https://www.cbti.cn/sleep/ai/sleep_aicocah
[
_aiWebView
loadRequest
:
self
.
request
];
NSURL
*
url
=
[
NSURL
URLWithString
:
@"https://cbti.mynatapp.cc/sleep/ai/sleep_aicocah"
];
NSURLRequest
*
request
=
[
NSURLRequest
requestWithURL
:
url
];
[
_aiWebView
loadRequest
:
request
];
}
}
return
_aiWebView
;
return
_aiWebView
;
}
}
...
...
DreamSleep/DreamSleep/Class/ProfileModule/Account/Controller/AccountController.m
查看文件 @
8762676
...
@@ -57,6 +57,8 @@
...
@@ -57,6 +57,8 @@
// 刷新主页数据
// 刷新主页数据
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
// 刷新AI睡眠教练
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateAICoach
object
:
nil
];
}
}
}];
}];
}
}
...
...
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.m
查看文件 @
8762676
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
// 刷新主页数据
// 刷新主页数据
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
// 刷新AI睡眠教练
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateAICoach
object
:
nil
];
}
else
{
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
}
}
...
@@ -129,6 +131,8 @@
...
@@ -129,6 +131,8 @@
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
// 刷新主页数据
// 刷新主页数据
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateHomePage
object
:
nil
];
// 刷新AI睡眠教练
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedUpdateAICoach
object
:
nil
];
}
else
{
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
}
}
...
@@ -175,7 +179,7 @@
...
@@ -175,7 +179,7 @@
#pragma mark - ASAuthorizationControllerPresentationContextProviding
#pragma mark - ASAuthorizationControllerPresentationContextProviding
#pragma mark - 告诉代理应该在哪个window 展示内容给用户
#pragma mark - 告诉代理应该在哪个window 展示内容给用户
-
(
ASPresentationAnchor
)
presentationAnchorForAuthorizationController
:
(
ASAuthorizationController
*
)
controller
API_AVAILABLE
(
ios
(
13
.
0
)){
-
(
ASPresentationAnchor
)
presentationAnchorForAuthorizationController
:
(
ASAuthorizationController
*
)
controller
API_AVAILABLE
(
ios
(
13
.
0
)){
N
SLog
(
@"调用展示window方法:%s"
,
__FUNCTION__
);
D
SLog
(
@"调用展示window方法:%s"
,
__FUNCTION__
);
// 返回window
// 返回window
return
self
.
view
.
window
;
return
self
.
view
.
window
;
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论