Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 7a52bcf4
由
cgx
编写于
2022-05-06 17:41:17 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成舒眠课程和助眠音乐课程列表页
1 个父辈
4fcb2bc6
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
436 行增加
和
14 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseCollectionCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseCollectionCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.h
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.m
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.h
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.m
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
7a52bcf
...
...
@@ -53,6 +53,8 @@
D0506B1828054ECD00229278 /* SafeHelperCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0506B1728054ECD00229278 /* SafeHelperCollectionView.m */; };
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0506B1A2805500E00229278 /* SafeHelperCollectionViewCell.m */; };
D053BEE9280F9E310028CCFC /* CloseAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D053BEE8280F9E310028CCFC /* CloseAlertView.m */; };
D055BEB928250D3400BC11A4 /* CourseCollectionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEB828250D3400BC11A4 /* CourseCollectionCell.m */; };
D055BEBC28250E8F00BC11A4 /* CourseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D055BEBB28250E8F00BC11A4 /* CourseModel.m */; };
D062A09E281838B800B4F48A /* FeedbackRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A09D281838B800B4F48A /* FeedbackRequestModel.m */; };
D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = D062A0A028183FE000B4F48A /* FeedbackDetailController.m */; };
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */ = {isa = PBXBuildFile; fileRef = D070509928071BAF006D72E1 /* DSNetworkTool.m */; };
...
...
@@ -245,6 +247,10 @@
D0506B1A2805500E00229278 /* SafeHelperCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SafeHelperCollectionViewCell.m; sourceTree = "<group>"; };
D053BEE7280F9E310028CCFC /* CloseAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CloseAlertView.h; sourceTree = "<group>"; };
D053BEE8280F9E310028CCFC /* CloseAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CloseAlertView.m; sourceTree = "<group>"; };
D055BEB728250D3400BC11A4 /* CourseCollectionCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CourseCollectionCell.h; sourceTree = "<group>"; };
D055BEB828250D3400BC11A4 /* CourseCollectionCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CourseCollectionCell.m; sourceTree = "<group>"; };
D055BEBA28250E8F00BC11A4 /* CourseModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CourseModel.h; sourceTree = "<group>"; };
D055BEBB28250E8F00BC11A4 /* CourseModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CourseModel.m; sourceTree = "<group>"; };
D062A09C281838B800B4F48A /* FeedbackRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackRequestModel.h; sourceTree = "<group>"; };
D062A09D281838B800B4F48A /* FeedbackRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackRequestModel.m; sourceTree = "<group>"; };
D062A09F28183FE000B4F48A /* FeedbackDetailController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedbackDetailController.h; sourceTree = "<group>"; };
...
...
@@ -1016,6 +1022,10 @@
D0D69ED2282360F100A0D5EB /* LookAllController.m */,
D0D69ED428236E0800A0D5EB /* SafeSleepListController.h */,
D0D69ED528236E0800A0D5EB /* SafeSleepListController.m */,
D055BEB728250D3400BC11A4 /* CourseCollectionCell.h */,
D055BEB828250D3400BC11A4 /* CourseCollectionCell.m */,
D055BEBA28250E8F00BC11A4 /* CourseModel.h */,
D055BEBB28250E8F00BC11A4 /* CourseModel.m */,
);
path = Home;
sourceTree = "<group>";
...
...
@@ -1471,7 +1481,9 @@
D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */,
D07DACA92810557D0067A1BF /* UIImage+RSKImageCropper.m in Sources */,
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */,
D055BEB928250D3400BC11A4 /* CourseCollectionCell.m in Sources */,
D01814E227FFDBB800583D4E /* HomeHeaderView.m in Sources */,
D055BEBC28250E8F00BC11A4 /* CourseModel.m in Sources */,
D09BF33A280E94E300E5F06C /* LoginUtils.m in Sources */,
D0F808F52803D4E70097899F /* Track.m in Sources */,
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */,
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseCollectionCell.h
0 → 100644
查看文件 @
7a52bcf
//
// CourseCollectionCell.h
// DreamSleep
//
// Created by peter on 2022/5/6.
//
#import <UIKit/UIKit.h>
#import "CourseModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程和助眠音乐课程列表Cell
@interface
CourseCollectionCell
:
UICollectionViewCell
@property
(
nonatomic
,
strong
)
CourseModel
*
model
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseCollectionCell.m
0 → 100644
查看文件 @
7a52bcf
//
// CourseCollectionCell.m
// DreamSleep
//
// Created by peter on 2022/5/6.
//
#import "CourseCollectionCell.h"
@interface
CourseCollectionCell
()
@property
(
nonatomic
,
strong
)
UIImageView
*
templeImgView
;
@property
(
nonatomic
,
strong
)
UILabel
*
templeNameLb
;
@end
@implementation
CourseCollectionCell
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
{
if
(
self
=
[
super
initWithFrame
:
frame
])
{
_templeImgView
=
[
UIImageView
new
];
_templeImgView
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
5
,
.
5
);
[
self
.
contentView
addSubview
:
_templeImgView
];
_templeNameLb
=
[
UILabel
new
];
_templeNameLb
.
textAlignment
=
NSTextAlignmentLeft
;
_templeNameLb
.
font
=
SysFont
(
14
);
_templeNameLb
.
textAlignment
=
0
;
_templeNameLb
.
dk_textColorPicker
=
DKColorPickerWithColors
(
SubTitleColor
,
ColorFromHex
(
0x7E8392
),
DSWhite
);
[
self
.
contentView
addSubview
:
_templeNameLb
];
[
_templeImgView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
contentView
.
mas_top
).
offset
(
5
);
make
.
centerX
.
equalTo
(
self
.
contentView
.
mas_centerX
);
make
.
height
.
equalTo
(
@90
);
make
.
width
.
equalTo
(
@90
);
}];
[
_templeNameLb
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
templeImgView
.
mas_left
);
make
.
right
.
equalTo
(
self
.
contentView
.
mas_right
);
make
.
top
.
equalTo
(
self
.
templeImgView
.
mas_bottom
).
offset
(
8
);
}];
}
return
self
;
}
-
(
void
)
setModel
:(
CourseModel
*
)
model
{
_model
=
model
;
[
self
.
templeImgView
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
audio_img
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
templeNameLb
.
text
=
model
.
audio_name
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.h
0 → 100644
查看文件 @
7a52bcf
//
// CourseModel.h
// DreamSleep
//
// Created by peter on 2022/5/6.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程和助眠音乐课程数据model
@interface
CourseModel
:
NSObject
@property
(
nonatomic
,
assign
)
int
course_id
;
// 名称
@property
(
nonatomic
,
copy
)
NSString
*
audio_name
;
// 音频描述信息
@property
(
nonatomic
,
copy
)
NSString
*
audio_desc
;
// 二级页面封面图
@property
(
nonatomic
,
copy
)
NSString
*
audio_img
;
// 播放图
@property
(
nonatomic
,
copy
)
NSString
*
audio_pic
;
// 背景图
@property
(
nonatomic
,
copy
)
NSString
*
bg_url
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.m
0 → 100644
查看文件 @
7a52bcf
//
// CourseModel.m
// DreamSleep
//
// Created by peter on 2022/5/6.
//
#import "CourseModel.h"
@implementation
CourseModel
+
(
nullable
NSDictionary
<
NSString
*
,
id
>
*
)
modelCustomPropertyMapper
{
return
@{
@"course_id"
:
@"id"
};
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.h
0 → 100644
查看文件 @
7a52bcf
//
// LookAllController.h
// DreamSleep
//
// Created by peter on 2022/5/5.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 查看全部控制器
@interface
LookAllController
:
UIViewController
-
(
instancetype
)
initWithIndexPath
:(
NSIndexPath
*
)
indexPath
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.m
0 → 100644
查看文件 @
7a52bcf
//
// LookAllController.m
// DreamSleep
//
// Created by peter on 2022/5/5.
//
#import "LookAllController.h"
#import "SafeSleepListController.h"
@interface
LookAllController
()
<
UIScrollViewDelegate
>
@property
(
nonatomic
,
strong
)
UIView
*
headView
;
@property
(
nonatomic
,
strong
)
UIScrollView
*
bodyView
;
@end
@implementation
LookAllController
{
NSIndexPath
*
_indexPath
;
UIView
*
_indicatorView
;
NSArray
*
_btns
;
NSInteger
_selectedIndex
;
}
-
(
instancetype
)
initWithIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
self
=
[
super
init
])
{
_indexPath
=
indexPath
;
_selectedIndex
=
_indexPath
.
row
;
self
.
navigationItem
.
title
=
indexPath
.
row
==
0
?
@"舒眠课程"
:
@"助眠音乐"
;
}
return
self
;
}
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
view
addSubview
:
self
.
headView
];
[
self
.
view
addSubview
:
self
.
bodyView
];
}
#pragma mark - 品牌模式
-
(
NaviStyle
)
navigationBarStyle
{
return
NaviStyleDefault
;
}
#pragma mark - Actions
-
(
void
)
adjustUI
{
for
(
UIButton
*
btn
in
_btns
)
{
if
(
_selectedIndex
==
btn
.
tag
)
{
[
btn
.
titleLabel
setFont
:
BoldFont
(
16
)];
[
btn
dk_setTitleColorPicker
:
DKColorPickerWithColors
(
MainTextColor
,
ColorFromHex
(
0xE8E9E9
),
DSWhite
)
forState
:
UIControlStateNormal
];
}
else
{
[
btn
.
titleLabel
setFont
:
SysFont
(
15
)];
[
btn
dk_setTitleColorPicker
:
DKColorPickerWithColors
(
SubTitleColor
,
ColorFromHex
(
0x7A7F8E
),
DSWhite
)
forState
:
UIControlStateNormal
];
}
}
}
-
(
void
)
switchViewcontrollerAction
:
(
UIButton
*
)
sender
{
_selectedIndex
=
sender
.
tag
;
[
UIView
animateWithDuration
:.
3
animations
:
^
{
self
->
_indicatorView
.
x
=
sender
.
x
;
[
self
->
_bodyView
setContentOffset
:
CGPointMake
(
sender
.
tag
*
self
->
_bodyView
.
width
,
0
)];
}];
[
self
adjustUI
];
}
-
(
UIButton
*
)
btnWithTitle
:
(
NSString
*
)
title
font
:
(
UIFont
*
)
font
tag
:
(
NSInteger
)
tag
sView
:
(
UIView
*
)
sView
{
UIButton
*
btn
=
[
UIButton
btnWithTitle
:
title
font
:
font
];
btn
.
tag
=
tag
;
[
btn
addTarget
:
self
action
:
@selector
(
switchViewcontrollerAction
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
sView
addSubview
:
btn
];
return
btn
;
}
-
(
void
)
addSubControllerView
{
SafeSleepListController
*
safeVC
=
[[
SafeSleepListController
alloc
]
initWithSubID
:
6
];
safeVC
.
view
.
frame
=
CGRectMake
(
0
,
0
,
kScreenWidth
,
self
.
bodyView
.
height
);
[
self
.
bodyView
addSubview
:
safeVC
.
view
];
[
self
addChildViewController
:
safeVC
];
SafeSleepListController
*
relaxVC
=
[[
SafeSleepListController
alloc
]
initWithSubID
:
18
];
relaxVC
.
view
.
frame
=
CGRectMake
(
kScreenWidth
,
0
,
kScreenWidth
,
self
.
bodyView
.
height
);
[
self
.
bodyView
addSubview
:
relaxVC
.
view
];
[
self
addChildViewController
:
relaxVC
];
}
#pragma mark - UIScrollViewDelegate
-
(
void
)
scrollViewDidEndDecelerating
:
(
UIScrollView
*
)
scrollView
{
NSInteger
index
=
scrollView
.
contentOffset
.
x
/
scrollView
.
width
;
[
scrollView
setContentOffset
:
CGPointMake
(
index
*
scrollView
.
width
,
0
)];
_selectedIndex
=
index
;
UIButton
*
btn
=
_btns
[
index
];
[
UIView
animateWithDuration
:.
3
animations
:
^
{
self
->
_indicatorView
.
x
=
btn
.
x
;
}];
[
self
adjustUI
];
}
#pragma mark - lazy
-
(
UIView
*
)
headView
{
if
(
!
_headView
)
{
_headView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
15
,
0
,
kScreenWidth
-
30
,
40
)];
UIButton
*
btn1
=
[
self
btnWithTitle
:
@"舒眠课程"
font
:
BoldFont
(
16
)
tag
:
0
sView
:
_headView
];
UIButton
*
btn2
=
[
self
btnWithTitle
:
@"放松音乐"
font
:
SysFont
(
15
)
tag
:
1
sView
:
_headView
];
_indicatorView
=
[
UIView
new
];
_indicatorView
.
backgroundColor
=
BrandColor
;
[
_headView
addSubview
:
_indicatorView
];
[
btn1
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
_headView
);
make
.
bottom
.
equalTo
(
_headView
).
offset
(
1
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
70
,
30
));
}];
[
btn2
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
btn1
.
mas_right
).
offset
(
26
);
make
.
centerY
.
equalTo
(
btn1
);
make
.
size
.
equalTo
(
btn1
);
}];
[
_indicatorView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
width
.
equalTo
(
btn1
);
make
.
centerX
.
equalTo
(
_indexPath
.
row
==
0
?
btn1
:
btn2
);
make
.
height
.
equalTo
(
@4
);
make
.
bottom
.
equalTo
(
_headView
);
}];
_btns
=
@[
btn1
,
btn2
];
[
self
adjustUI
];
}
return
_headView
;
}
-
(
UIScrollView
*
)
bodyView
{
if
(
!
_bodyView
)
{
_bodyView
=
[[
UIScrollView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
CGRectGetMaxY
(
_headView
.
frame
),
kScreenWidth
,
kScreenHeight
-
kTopHeight
(
0
)
-
_headView
.
height
)];
_bodyView
.
contentSize
=
CGSizeMake
(
2
*
kScreenWidth
,
_bodyView
.
height
);
_bodyView
.
pagingEnabled
=
YES
;
_bodyView
.
showsHorizontalScrollIndicator
=
NO
;
_bodyView
.
delegate
=
self
;
[
self
addSubControllerView
];
}
return
_bodyView
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.h
查看文件 @
7a52bcf
...
...
@@ -11,10 +11,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface
SafeSleepRequestModel
:
DSNetworkTool
/// 舒眠课程和助眠音乐课程列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
courseListData
;
/// 获取舒眠课程、助眠音乐列表数据
/// @param subID 6:舒眠课程,18:助眠音乐
/// @isHome isHome YES:主页横向列表数据,NO:查看所有列表数据
/// @param completion SafeSleepRequestModel
+
(
NSURLSessionDataTask
*
)
getCourseListDataWithSubID
:(
int
)
subID
completion
:(
void
(
^
)(
SafeSleepRequestModel
*
requestModel
))
completion
;
+
(
NSURLSessionDataTask
*
)
getCourseListDataWithSubID
:(
int
)
subID
isHome
:(
BOOL
)
isHome
completion
:(
void
(
^
)(
SafeSleepRequestModel
*
requestModel
))
completion
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.m
查看文件 @
7a52bcf
...
...
@@ -6,22 +6,28 @@
//
#import "SafeSleepRequestModel.h"
#import "CourseModel.h"
@implementation
SafeSleepRequestModel
+
(
NSURLSessionDataTask
*
)
getCourseListDataWithSubID
:(
int
)
subID
completion
:(
void
(
^
)(
SafeSleepRequestModel
*
requestModel
))
completion
{
SafeSleepRequestModel
*
requestModel
=
[[
SafeSleepRequestModel
alloc
]
init
];
+
(
NSURLSessionDataTask
*
)
getCourseListDataWithSubID
:(
int
)
subID
isHome
:(
BOOL
)
isHome
completion
:(
void
(
^
)(
SafeSleepRequestModel
*
requestModel
))
completion
{
NSString
*
api
=
@"query_relax_meditation_type"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"query{%@(sub_id:%d,is_home:%@)}"
,
api
,
subID
,
@"true"
];
return
[
self
httpPostBodyRequestWithParam
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
YES
success
:^
(
id
_Nonnull
responseObj
)
{
// 数据解析字典转模型
DSLog
(
@"获取舒眠课程、助眠音乐列表数据接口dataDic:%@"
,
responseObj
);
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"query{%@(sub_id:%d,is_home:%@)}"
,
api
,
subID
,
isHome
?
@"true"
:
@"false"
];
SafeSleepRequestModel
*
requestModel
=
[[
SafeSleepRequestModel
alloc
]
init
];
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
YES
success
:^
(
NSDictionary
*
apiDic
)
{
requestModel
.
resCode
=
DSResCodeSuccess
;
DSLog
(
@"获取舒眠课程、助眠音乐列表数据接口dataDic:%@"
,
apiDic
);
NSArray
*
resultArr
=
apiDic
[
@"result"
];
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
courseDic
in
resultArr
)
{
CourseModel
*
model
=
[
CourseModel
yy_modelWithDictionary
:
courseDic
];
[
tmpArr
addObject
:
model
];
}
requestModel
.
courseListData
=
[
tmpArr
copy
];
completion
(
requestModel
);
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
}
failure
:^
(
id
failure
)
{
requestModel
.
resCode
=
DSResCodeNetFail
;
requestModel
.
errorInfo
=
failure
Info
;
requestModel
.
errorInfo
=
failure
;
completion
(
requestModel
);
}];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.h
0 → 100644
查看文件 @
7a52bcf
//
// SafeSleepListController.h
// DreamSleep
//
// Created by peter on 2022/5/5.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程和助眠音乐列表控制器
@interface
SafeSleepListController
:
UIViewController
-
(
instancetype
)
initWithSubID
:(
int
)
subID
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.m
0 → 100644
查看文件 @
7a52bcf
//
// SafeSleepListController.m
// DreamSleep
//
// Created by peter on 2022/5/5.
//
#import "SafeSleepListController.h"
#import "SafeSleepRequestModel.h"
#import "CourseCollectionCell.h"
#import "CourseModel.h"
@interface
SafeSleepListController
()
<
UICollectionViewDataSource
,
UICollectionViewDelegate
>
@property
(
nonatomic
,
strong
)
UICollectionView
*
courseListView
;
@property
(
nonatomic
,
strong
)
NSArray
*
listArr
;
@end
@implementation
SafeSleepListController
{
int
_sub_id
;
}
-
(
instancetype
)
initWithSubID
:
(
int
)
subID
{
if
(
self
=
[
super
init
])
{
_sub_id
=
subID
;
_listArr
=
@[];
}
return
self
;
}
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
view
addSubview
:
self
.
courseListView
];
self
.
courseListView
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
[
self
getCourseDataRequest
];
}];
[
self
.
courseListView
.
mj_header
beginRefreshing
];
}
-
(
void
)
getCourseDataRequest
{
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
self
->
_sub_id
isHome
:
NO
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
courseListView
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
.
listArr
=
requestModel
.
courseListData
;
[
self
.
courseListView
reloadData
];
}
}];
}
#pragma mark - lazy
-
(
UICollectionView
*
)
courseListView
{
if
(
!
_courseListView
)
{
UICollectionViewFlowLayout
*
layout
=
[[
UICollectionViewFlowLayout
alloc
]
init
];
layout
.
sectionFootersPinToVisibleBounds
=
YES
;
layout
.
scrollDirection
=
UICollectionViewScrollDirectionVertical
;
CGFloat
width
=
(
kScreenWidth
-
60
)
/
3
;
layout
.
itemSize
=
CGSizeMake
(
width
,
130
);
layout
.
minimumInteritemSpacing
=
15
;
_courseListView
=
[[
UICollectionView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
self
.
view
.
height
-
Bottom_SafeArea_Height
-
kTopHeight
(
0
)
-
40
)
collectionViewLayout
:
layout
];
_courseListView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_courseListView
.
showsVerticalScrollIndicator
=
NO
;
_courseListView
.
delegate
=
self
;
_courseListView
.
dataSource
=
self
;
[
_courseListView
registerClass
:[
CourseCollectionCell
class
]
forCellWithReuseIdentifier
:
@"CourseCollectionCellID"
];
}
return
_courseListView
;
}
#pragma mark - UICollectionViewDataSource && UICollectionViewDelegate
-
(
NSInteger
)
collectionView
:
(
UICollectionView
*
)
collectionView
numberOfItemsInSection
:
(
NSInteger
)
section
{
return
self
.
listArr
.
count
;
}
-
(
__kindof
UICollectionViewCell
*
)
collectionView
:
(
UICollectionView
*
)
collectionView
cellForItemAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
CourseCollectionCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"CourseCollectionCellID"
forIndexPath
:
indexPath
];
CourseModel
*
model
=
[
self
.
listArr
objectAtIndex
:
indexPath
.
row
];
if
(
indexPath
.
row
<
self
.
listArr
.
count
)
{
cell
.
model
=
model
;
}
return
cell
;
}
-
(
UIEdgeInsets
)
collectionView
:
(
UICollectionView
*
)
collectionView
layout
:
(
UICollectionViewLayout
*
)
collectionViewLayout
insetForSectionAtIndex
:
(
NSInteger
)
section
{
return
UIEdgeInsetsMake
(
24
,
15
,
24
,
15
);
}
-
(
void
)
collectionView
:
(
UICollectionView
*
)
collectionView
didSelectItemAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
self
.
listArr
.
count
>
indexPath
.
row
)
{
CourseModel
*
model
=
[
self
.
listArr
objectAtIndex
:
indexPath
.
row
];
// MusicCourseDetailVC *coureDetailVC = [[MusicCourseDetailVC alloc] init];
// coureDetailVC.typeId = model.identify;
// coureDetailVC.hidesBottomBarWhenPushed = YES;
// [self.navigationController pushViewController:coureDetailVC animated:YES];
}
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.m
查看文件 @
7a52bcf
...
...
@@ -33,10 +33,10 @@
[
self
.
headerView
updateBannerWithListData
:
requestModel
.
bannerListData
];
}
}];
// [SafeSleepRequestModel getCourseListDataWithSubID:6 completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [SafeSleepRequestModel getCourseListDataWithSubID:6
isHome:YES
completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
// [SafeSleepRequestModel getCourseListDataWithSubID:18 completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [SafeSleepRequestModel getCourseListDataWithSubID:18
isHome:Yes
completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
}];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
查看文件 @
7a52bcf
...
...
@@ -8,6 +8,7 @@
#import "SafeSleepCell.h"
#import "SafeHelperCollectionView.h"
#import "SafeHelperCollectionViewCell.h"
#import "LookAllController.h"
@interface
SafeSleepCell
()
@property
(
nonatomic
,
strong
)
UIView
*
leftIV
;
...
...
@@ -129,7 +130,8 @@
}
-
(
void
)
lookMore
:
(
UIButton
*
)
sender
{
DSLog
(
@"cellIndexPath:%ld"
,
self
.
indexPath
.
row
);
LookAllController
*
lookAllVC
=
[[
LookAllController
alloc
]
initWithIndexPath
:
self
.
indexPath
];
[
self
.
ds_viewController
.
navigationController
pushViewController
:
lookAllVC
animated
:
YES
];
}
@end
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论