Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f86335be
由
cgx
编写于
2022-05-07 15:54:38 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化登录模块(登录成功回调)
1 个父辈
c848f239
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
160 行增加
和
13 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioCourseCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.m
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.h
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.m
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginUtils.h
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginUtils.m
DreamSleep/DreamSleep/Resource/Assets.xcassets/.DS_Store
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock@3x.png
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
f86335b
...
...
@@ -157,6 +157,7 @@
D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F8090328042A0B0097899F /* SafeSleepCell.m */; };
D0F80907280431100097899F /* UILabel+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F80906280431100097899F /* UILabel+Extras.m */; };
D0F82286280C44D10039F586 /* SetTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F82285280C44D10039F586 /* SetTableView.m */; };
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F9AC532826563400FD7A3B /* MusicPlayerController.m */; };
D0FAC41C281B817D00D4B859 /* GKLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC406281B817D00D4B859 /* GKLoadingView.m */; };
D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC40C281B817D00D4B859 /* GKPhotoBrowser.m */; };
D0FAC41E281B817D00D4B859 /* GKPhotoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC40F281B817D00D4B859 /* GKPhotoManager.m */; };
...
...
@@ -460,6 +461,8 @@
D0F80906280431100097899F /* UILabel+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Extras.m"; sourceTree = "<group>"; };
D0F82284280C44D10039F586 /* SetTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SetTableView.h; sourceTree = "<group>"; };
D0F82285280C44D10039F586 /* SetTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SetTableView.m; sourceTree = "<group>"; };
D0F9AC522826563400FD7A3B /* MusicPlayerController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MusicPlayerController.h; sourceTree = "<group>"; };
D0F9AC532826563400FD7A3B /* MusicPlayerController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MusicPlayerController.m; sourceTree = "<group>"; };
D0FAC406281B817D00D4B859 /* GKLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKLoadingView.m; sourceTree = "<group>"; };
D0FAC407281B817D00D4B859 /* GKWebImageProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKWebImageProtocol.h; sourceTree = "<group>"; };
D0FAC408281B817D00D4B859 /* GKPhotoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKPhotoManager.h; sourceTree = "<group>"; };
...
...
@@ -1049,6 +1052,8 @@
D055BEC728252D8200BC11A4 /* AudioCourseCell.m */,
D055BEC928252E4000BC11A4 /* SubAudioModel.h */,
D055BECA28252E4000BC11A4 /* SubAudioModel.m */,
D0F9AC522826563400FD7A3B /* MusicPlayerController.h */,
D0F9AC532826563400FD7A3B /* MusicPlayerController.m */,
);
path = Home;
sourceTree = "<group>";
...
...
@@ -1480,6 +1485,7 @@
D08F79E0281A1838000D99DD /* TZImagePickerController.m in Sources */,
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */,
D0AEFE812817DD1500230DC6 /* MyFeedCell.m in Sources */,
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */,
D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */,
D0874BBF2816E61000CECB3C /* RescuePlanView.m in Sources */,
D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */,
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioCourseCell.m
查看文件 @
f86335b
...
...
@@ -101,8 +101,6 @@
self
.
pleyerBtn
=
[
UIButton
new
];
[
self
.
bigView
addSubview
:
self
.
pleyerBtn
];
[
self
.
pleyerBtn
addTarget
:
self
action
:
@selector
(
playerBtnClick
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
pleyerBtn
dk_setImage
:
DKImagePickerWithNames
(
@"ic_list_play_normal"
,
@"dk_ic_list_play_normal"
,
@"dk_ic_list_play_normal"
)
forState
:
UIControlStateNormal
];
[
self
.
pleyerBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
bigView
.
mas_right
).
offset
(
-
15
);
make
.
width
.
equalTo
(
@40
);
...
...
@@ -130,11 +128,18 @@
self
.
numberLb
.
text
=
[
NSString
stringWithFormat
:
@"%ld"
,
indexPath
.
row
+
1
];
self
.
timeLb
.
text
=
model
.
play_time
;
self
.
titleLb
.
text
=
model
.
audio_name
;
UIColor
*
normalTitleColor
=
model
.
is_lock
==
1
?
ColorFromHex
(
0x848484
)
:
MainTextColor
;
self
.
titleLb
.
dk_textColorPicker
=
DKColorPickerWithColors
(
normalTitleColor
,
ColorFromHex
(
0xE8E9E9
),
DSWhite
);
if
(
model
.
is_lock
==
0
&&
indexPath
.
row
==
0
)
{
self
.
pleyerBtn
.
hidden
=
YES
;
self
.
tryLab
.
hidden
=
NO
;
UIColor
*
darkTitleColor
=
model
.
is_lock
==
1
?
ColorFromHex
(
0xBBBBBB
)
:
ColorFromHex
(
0xE8E9E9
);
NSString
*
normalImgName
=
model
.
is_lock
==
1
?
@"dk_ic_list_play_normal"
:
@"ic_list_play_normal"
;
NSString
*
darkImgName
=
model
.
is_lock
==
1
?
@"dk_ic_list_play_normal"
:
@"dk_ic_list_play_normal_unlock"
;
self
.
titleLb
.
dk_textColorPicker
=
DKColorPickerWithColors
(
normalTitleColor
,
darkTitleColor
,
DSWhite
);
[
self
.
pleyerBtn
dk_setImage
:
DKImagePickerWithNames
(
normalImgName
,
darkImgName
,
@"dk_ic_list_play_normal"
)
forState
:
UIControlStateNormal
];
// 音频未🔒
if
(
model
.
is_lock
==
0
)
{
self
.
tryLab
.
hidden
=
[
LoginUtils
getUserLoginData
];
self
.
pleyerBtn
.
hidden
=
!
self
.
tryLab
.
hidden
;
}
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
查看文件 @
f86335b
...
...
@@ -9,6 +9,7 @@
#import "SafeSleepRequestModel.h"
#import "AudioDetailHeaderView.h"
#import "AudioCourseCell.h"
#import "MusicPlayerController.h"
@interface
CourseDetailController
()
<
UITableViewDelegate
,
UITableViewDataSource
>
@property
(
nonatomic
,
strong
)
UITableView
*
audioListView
;
...
...
@@ -45,10 +46,9 @@
}];
}
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
self
.
navigationController
.
navigationBarHidden
=
YES
;
[
self
.
unlockBtn
setTitle
:[
LoginUtils
getUserLoginData
]
?
@"开始第一节"
:
@"登录解锁全部章节"
forState
:
UIControlStateNormal
];
#pragma mark - 隐藏导航栏
-
(
BOOL
)
isShowNavigationBar
{
return
YES
;
}
#pragma mark - 设置状态栏文字颜色
...
...
@@ -69,10 +69,15 @@
-
(
void
)
unlockAction
{
if
([
LoginUtils
getUserLoginData
])
{
}
else
{
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
];
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
selector
:
@selector
(
updateAfterLoginSuccess
)
];
}
}
-
(
void
)
updateAfterLoginSuccess
{
[
self
.
unlockBtn
setTitle
:
@"开始第一节"
forState
:
UIControlStateNormal
];
[
self
getAudiosData
];
}
#pragma mark - UITableViewDelegate, UITableViewDataSource
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
return
self
.
subAudioArr
.
count
;
...
...
@@ -95,6 +100,23 @@
return
100
;
}
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
self
.
subAudioArr
.
count
>
indexPath
.
row
)
{
SubAudioModel
*
model
=
self
.
subAudioArr
[
indexPath
.
row
];
if
(
model
.
is_lock
==
1
)
{
if
(
!
[
LoginUtils
getUserLoginData
])
{
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
selector
:
@selector
(
updateAfterLoginSuccess
)];
}
}
else
{
// 跳转到播放页面
MusicPlayerController
*
playerVC
=
[[
MusicPlayerController
alloc
]
init
];
UINavigationController
*
naviVC
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
playerVC
];
[
self
presentViewController
:
naviVC
animated
:
YES
completion
:
nil
];
}
}
}
#pragma mark - UIScrollViewDelegate
-
(
void
)
scrollViewDidScroll
:
(
UIScrollView
*
)
scrollView
{
CGFloat
offset
=
scrollView
.
contentOffset
.
y
;
if
(
offset
>=
kTopHeight
(
0
))
{
...
...
@@ -134,7 +156,7 @@
-
(
UIButton
*
)
unlockBtn
{
if
(
!
_unlockBtn
)
{
_unlockBtn
=
[
UIButton
btnWithTitle
:
@"
"
titleColor
:
DSWhite
font
:
BoldFont
(
16
)
bgColor
:
BrandColor
];
_unlockBtn
=
[
UIButton
btnWithTitle
:
[
LoginUtils
getUserLoginData
]
?
@"开始第一节"
:
@"登录解锁全部章节
"
titleColor
:
DSWhite
font
:
BoldFont
(
16
)
bgColor
:
BrandColor
];
[
_unlockBtn
addTarget
:
self
action
:
@selector
(
unlockAction
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_unlockBtn
cornerRadius
:
20
];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.h
0 → 100644
查看文件 @
f86335b
//
// MusicPlayerController.h
// DreamSleep
//
// Created by peter on 2022/5/7.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 音频播放界面
@interface
MusicPlayerController
:
UIViewController
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.m
0 → 100644
查看文件 @
f86335b
//
// MusicPlayerController.m
// DreamSleep
//
// Created by peter on 2022/5/7.
//
#import "MusicPlayerController.h"
@interface
MusicPlayerController
()
@property
(
nonatomic
,
strong
)
UIButton
*
dismissBtn
;
@end
@implementation
MusicPlayerController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
view
addSubview
:
self
.
dismissBtn
];
}
#pragma mark - 隐藏导航栏
-
(
BOOL
)
isShowNavigationBar
{
return
YES
;
}
#pragma mark - 设置状态栏文字颜色
-
(
UIStatusBarStyle
)
preferredStatusBarStyle
{
return
[
self
.
dk_manager
.
themeVersion
isEqualToString
:
DKThemeVersionNormal
]
?
UIStatusBarStyleDefault
:
UIStatusBarStyleLightContent
;
}
-
(
void
)
dismiss
{
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
#pragma mark - lazy
-
(
UIButton
*
)
dismissBtn
{
if
(
!
_dismissBtn
)
{
_dismissBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
15
,
kStatusBarHeight
+
19
,
30
,
30
)];
[
_dismissBtn
dk_setImage
:
DKImagePickerWithNames
(
@"home_close"
,
@"dk_home_close"
,
@"home_close"
)
forState
:
UIControlStateNormal
];
[
_dismissBtn
addTarget
:
self
action
:
@selector
(
dismiss
)
forControlEvents
:
UIControlEventTouchUpInside
];
}
return
_dismissBtn
;
}
@end
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.h
查看文件 @
f86335b
...
...
@@ -9,8 +9,11 @@
NS_ASSUME_NONNULL_BEGIN
@interface
LoginController
:
UIViewController
/// 登录成功block回调
typedef
void
(
^
LoginSuccessBlock
)(
void
);
@interface
LoginController
:
UIViewController
@property
(
nonatomic
,
copy
)
LoginSuccessBlock
successBlock
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginController.m
查看文件 @
f86335b
...
...
@@ -46,6 +46,7 @@
[
UserRequestModel
wxLoginWithCode
:
code
completion
:
^
(
UserRequestModel
*
_Nonnull
requestModel
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
DSProgressHUD
showToast
:
@"登录成功"
];
if
(
self
.
successBlock
)
{
self
.
successBlock
();
}
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
...
...
@@ -122,6 +123,7 @@
[
UserRequestModel
appleLoginWithUser
:
userID
identityToken
:
identityToken
authorizationCode
:
authorizationCode
completion
:^
(
UserRequestModel
*
_Nonnull
requestModel
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
DSProgressHUD
showToast
:
@"登录成功"
];
if
(
self
.
successBlock
)
{
self
.
successBlock
();
}
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errorInfo
];
...
...
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginUtils.h
查看文件 @
f86335b
...
...
@@ -50,8 +50,14 @@ NS_ASSUME_NONNULL_BEGIN
/// 清除用户登录数据
+
(
void
)
clearUserLoginData
;
/// 跳转到登录模块
/// @param target 入口控制器
+
(
void
)
jumpToLoginControllerWithTarget
:(
UIViewController
*
)
target
;
/// 跳转到登录模块,并且登录成功后发送消息给入口控制器
/// @param target 入口控制器
/// @param sel 消息
+
(
void
)
jumpToLoginControllerWithTarget
:(
UIViewController
*
)
target
selector
:(
SEL
)
sel
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/ProfileModule/UserLogin/LoginUtils.m
查看文件 @
f86335b
...
...
@@ -93,4 +93,20 @@
}
}
+
(
void
)
jumpToLoginControllerWithTarget
:
(
UIViewController
*
)
target
selector
:
(
SEL
)
sel
{
if
(
target
&&
[
target
isKindOfClass
:[
UIViewController
class
]])
{
LoginController
*
loginVC
=
[[
LoginController
alloc
]
init
];
loginVC
.
successBlock
=
^
{
if
([
target
respondsToSelector
:
sel
])
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[
target
performSelector
:
sel
];
#pragma clang diagnostic pop
}
};
BaseNaviController
*
navi
=
[[
BaseNaviController
alloc
]
initWithRootViewController
:
loginVC
];
[
target
presentViewController
:
navi
animated
:
YES
completion
:
nil
];
}
}
@end
DreamSleep/DreamSleep/Resource/Assets.xcassets/.DS_Store
查看文件 @
f86335b
此文件类型无法预览
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/Contents.json
0 → 100644
查看文件 @
f86335b
{
"images"
:
[
{
"filename"
:
"dk_ic_list_play_normal_unlock.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"dk_ic_list_play_normal_unlock@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"dk_ic_list_play_normal_unlock@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock.png
0 → 100644
查看文件 @
f86335b
874 字节
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock@2x.png
0 → 100644
查看文件 @
f86335b
1.9 KB
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_play_normal_unlock.imageset/dk_ic_list_play_normal_unlock@3x.png
0 → 100644
查看文件 @
f86335b
3.5 KB
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论