Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 1bed1b3e
由
cgx
编写于
2022-05-11 22:12:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成首页舒眠课程和助眠音乐(到时候需要调整)
1 个父辈
1765b8bf
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
392 行增加
和
308 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/LookAllController.h
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/LookAllController.m
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/CourseModel.h
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/SafeSleepModel.h
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/SafeSleepModel.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/CourseMusicCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/CourseMusicCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/DSHomeView.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.m → DreamSleep/DreamSleep/Class/HomeModule/Home/View/DSHomeView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.h → DreamSleep/DreamSleep/Class/HomeModule/Home/View/GoodSleepSoundCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/GoodSleepSoundCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.h → DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeBasicCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeBasicCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test0.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test0.imageset/test0.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test1.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test1.imageset/test1.png
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
1bed1b3
此文件的差异被折叠,
点击展开。
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/LookAllController.h
查看文件 @
1bed1b3
...
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 查看全部控制器
/// 查看全部控制器
@interface
LookAllController
:
UIViewController
@interface
LookAllController
:
UIViewController
-
(
instancetype
)
initWith
IndexPath
:(
NSIndexPath
*
)
indexPath
;
-
(
instancetype
)
initWith
DefaultIndex
:(
NSInteger
)
defaultIndex
;
@end
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Course/Controller/LookAllController.m
查看文件 @
1bed1b3
...
@@ -14,17 +14,17 @@
...
@@ -14,17 +14,17 @@
@end
@end
@implementation
LookAllController
{
@implementation
LookAllController
{
NSIn
dexPath
*
_indexPath
;
NSIn
teger
_defaultIndex
;
UIView
*
_indicatorView
;
UIView
*
_indicatorView
;
NSArray
*
_btns
;
NSArray
*
_btns
;
NSInteger
_selectedIndex
;
NSInteger
_selectedIndex
;
}
}
-
(
instancetype
)
initWith
IndexPath
:
(
NSIndexPath
*
)
indexPath
{
-
(
instancetype
)
initWith
DefaultIndex
:
(
NSInteger
)
defaultIndex
{
if
(
self
=
[
super
init
])
{
if
(
self
=
[
super
init
])
{
_
indexPath
=
indexPath
;
_
defaultIndex
=
defaultIndex
;
_selectedIndex
=
_indexPath
.
row
;
_selectedIndex
=
defaultIndex
;
self
.
navigationItem
.
title
=
indexPath
.
row
==
0
?
@"舒眠课程"
:
@"助眠音乐"
;
self
.
navigationItem
.
title
=
_defaultIndex
==
0
?
@"舒眠课程"
:
@"助眠音乐"
;
}
}
return
self
;
return
self
;
}
}
...
@@ -121,7 +121,7 @@
...
@@ -121,7 +121,7 @@
}];
}];
[
_indicatorView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
_indicatorView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
width
.
equalTo
(
btn1
);
make
.
width
.
equalTo
(
btn1
);
make
.
centerX
.
equalTo
(
_
indexPath
.
row
==
0
?
btn1
:
btn2
);
make
.
centerX
.
equalTo
(
_
defaultIndex
==
0
?
btn1
:
btn2
);
make
.
height
.
equalTo
(
@4
);
make
.
height
.
equalTo
(
@4
);
make
.
bottom
.
equalTo
(
_headView
);
make
.
bottom
.
equalTo
(
_headView
);
}];
}];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/CourseModel.h
查看文件 @
1bed1b3
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*/
*/
typedef
enum
{
typedef
enum
{
CourseTypeSafe
,
// 舒眠课程
CourseTypeSafe
,
// 舒眠课程
CourseTypeRelax
//
发送
音乐
CourseTypeRelax
//
放松
音乐
}
CourseType
;
}
CourseType
;
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
...
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
copy
)
NSString
*
bg_url
;
@property
(
nonatomic
,
copy
)
NSString
*
bg_url
;
// 主页显示图标
// 主页显示图标
@property
(
nonatomic
,
copy
)
NSString
*
home_img
;
@property
(
nonatomic
,
copy
)
NSString
*
home_img
;
// 课程数量
@property
(
nonatomic
,
assign
)
int
count
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/SafeSleepModel.h
查看文件 @
1bed1b3
...
@@ -7,16 +7,23 @@
...
@@ -7,16 +7,23 @@
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
// Cell类型
typedef
NS_ENUM
(
NSInteger
,
CellType
)
{
CellTypeCourse
,
// 舒眠课程
CellTypeMusic
,
// 助眠音乐
CellTypeGood
// 好眠声音
};
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程、助眠音乐、好眠声音数据 model
/// 舒眠课程、助眠音乐、好眠声音数据
通用数据
model
@interface
SafeSleepModel
:
NSObject
@interface
SafeSleepModel
:
NSObject
/// cell标题
/// cell标题
@property
(
nonatomic
,
copy
)
NSString
*
title
;
@property
(
nonatomic
,
copy
)
NSString
*
title
;
///
课程列表数据
///
cell类型
@property
(
nonatomic
,
copy
)
NSArray
*
courseListDatas
;
@property
(
nonatomic
,
assign
)
CellType
type
;
/// 获取所有cell数据
+
(
NSArray
*
)
getDatas
;
+
(
NSArray
*
)
getDatas
;
@end
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Course/Model/SafeSleepModel.m
查看文件 @
1bed1b3
...
@@ -11,11 +11,12 @@
...
@@ -11,11 +11,12 @@
+
(
NSArray
*
)
getDatas
{
+
(
NSArray
*
)
getDatas
{
NSArray
*
titles
=
@[
@"舒眠课程"
,
@"助眠音乐"
,
@"好眠声音"
];
NSArray
*
titles
=
@[
@"舒眠课程"
,
@"助眠音乐"
,
@"好眠声音"
];
NSArray
*
types
=
@[
@
(
CellTypeCourse
),
@
(
CellTypeMusic
),
@
(
CellTypeGood
)];
NSMutableArray
*
tmpDatas
=
[
NSMutableArray
array
];
NSMutableArray
*
tmpDatas
=
[
NSMutableArray
array
];
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
SafeSleepModel
*
m
=
[
SafeSleepModel
new
];
SafeSleepModel
*
m
=
[
SafeSleepModel
new
];
m
.
type
=
[
types
[
i
]
integerValue
];
m
.
title
=
titles
[
i
];
m
.
title
=
titles
[
i
];
m
.
courseListDatas
=
@[];
[
tmpDatas
addObject
:
m
];
[
tmpDatas
addObject
:
m
];
}
}
return
[
tmpDatas
copy
];
return
[
tmpDatas
copy
];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
查看文件 @
1bed1b3
...
@@ -6,15 +6,16 @@
...
@@ -6,15 +6,16 @@
//
//
#import "HomeViewController.h"
#import "HomeViewController.h"
#import "
HomeTabl
eView.h"
#import "
DSHom
eView.h"
#import "RescuePlanView.h"
#import "RescuePlanView.h"
#import "FirstLeadAlertView.h"
#import "FirstLeadAlertView.h"
#import "UserRequestModel.h"
#import "UserRequestModel.h"
#import "HomeRequestModel.h"
#import "HomeRequestModel.h"
#import "ThreeMinuteController.h"
#import "ThreeMinuteController.h"
#import "SafeSleepRequestModel.h"
@interface
HomeViewController
()
@interface
HomeViewController
()
@property
(
nonatomic
,
strong
)
HomeTabl
eView
*
homeTV
;
@property
(
nonatomic
,
strong
)
DSHom
eView
*
homeTV
;
@property
(
nonatomic
,
strong
)
RescuePlanView
*
rescuePlanView
;
@property
(
nonatomic
,
strong
)
RescuePlanView
*
rescuePlanView
;
@end
@end
...
@@ -34,14 +35,43 @@
...
@@ -34,14 +35,43 @@
if
([
LoginUtils
getUserLoginData
])
{
if
([
LoginUtils
getUserLoginData
])
{
// 自动登录请求(调用时机)
// 自动登录请求(调用时机)
[
UserRequestModel
autoLoginRequestWithCompletion
:
^
(
UserRequestModel
*
_Nonnull
requestModel
)
{
[
UserRequestModel
autoLoginRequestWithCompletion
:
^
(
UserRequestModel
*
_Nonnull
requestModel
)
{}];
}];
}
}
// 活动运营弹框(首次启动不弹框,后面每隔24个小时请求后台接口)
// 活动运营弹框(首次启动不弹框,后面每隔24个小时请求后台接口)
[
self
promotionAlert
];
[
self
promotionAlert
];
// APP首次启动弹框(只出现一次)
// APP首次启动弹框(只出现一次)
[
self
showFirstLeadAlertView
];
[
self
showFirstLeadAlertView
];
[
self
requestHomeData
];
}
#pragma mark - banner、舒眠课程、助眠音乐数据获取
-
(
void
)
requestHomeData
{
self
.
homeTV
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
// 获取首页banner数据
[
HomeRequestModel
queryBannerListWithCompletion
:
^
(
HomeRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
refreshBarnner
:
requestModel
.
bannerListData
];
}
}];
// 获取首页舒眠课程数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
6
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeCourse
data
:
requestModel
.
courseListData
];
}
}];
// 获取首页助眠音乐数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
18
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeMusic
data
:
requestModel
.
courseListData
];
}
}];
}];
[
self
.
homeTV
.
mj_header
beginRefreshing
];
}
}
#pragma mark - APP首次启动弹框
#pragma mark - APP首次启动弹框
...
@@ -137,9 +167,9 @@
...
@@ -137,9 +167,9 @@
}
}
#pragma mark - lazy
#pragma mark - lazy
-
(
HomeTabl
eView
*
)
homeTV
{
-
(
DSHom
eView
*
)
homeTV
{
if
(
!
_homeTV
)
{
if
(
!
_homeTV
)
{
_homeTV
=
[[
HomeTabl
eView
alloc
]
init
];
_homeTV
=
[[
DSHom
eView
alloc
]
init
];
}
}
return
_homeTV
;
return
_homeTV
;
}
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/CourseMusicCell.h
0 → 100644
查看文件 @
1bed1b3
//
// CourseMusicCell.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "HomeBasicCell.h"
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程、助眠音乐Cell
@interface
CourseMusicCell
:
HomeBasicCell
/// 刷新首页舒眠课程、助眠音乐列表数据
/// @param dataArr dataArr
/// @param cellIndex cellIndex
-
(
void
)
updateCourseMusicListWithData
:(
NSArray
*
)
dataArr
cellIndex
:(
NSInteger
)
cellIndex
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/View/CourseMusicCell.m
0 → 100644
查看文件 @
1bed1b3
//
// CourseMusicCell.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "CourseMusicCell.h"
#import "LookAllController.h"
#import "SafeHelperCollectionView.h"
@interface
CourseMusicCell
()
@property
(
nonatomic
,
strong
)
UIButton
*
moreBtn
;
@property
(
nonatomic
,
strong
)
SafeHelperCollectionView
*
shCollectionView
;
@end
@implementation
CourseMusicCell
-
(
instancetype
)
initWithStyle
:(
UITableViewCellStyle
)
style
reuseIdentifier
:(
NSString
*
)
reuseIdentifier
{
if
(
self
=
[
super
initWithStyle
:
style
reuseIdentifier
:
reuseIdentifier
])
{
[
self
.
contentView
addSubview
:
self
.
moreBtn
];
[
self
.
contentView
addSubview
:
self
.
shCollectionView
];
[
self
.
moreBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
contentView
.
mas_right
).
offset
(
-
5
);
make
.
width
.
equalTo
(
@100
);
make
.
height
.
equalTo
(
@30
);
make
.
centerY
.
equalTo
(
self
.
verticalView
.
mas_centerY
);
}];
[
self
.
shCollectionView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
titleLab
.
mas_bottom
).
offset
(
17
);
make
.
left
.
equalTo
(
self
.
verticalView
);
make
.
right
.
equalTo
(
self
.
contentView
);
make
.
bottom
.
equalTo
(
self
.
contentView
).
offset
(
0
);
}];
}
return
self
;
}
-
(
void
)
updateCourseMusicListWithData
:(
NSArray
*
)
dataArr
cellIndex
:(
NSInteger
)
cellIndex
{
[
self
.
shCollectionView
reloadWithData
:
dataArr
cellIndex
:
cellIndex
];
}
-
(
void
)
lookAllAction
{
NSInteger
defaultIndex
=
self
.
model
.
type
==
CellTypeCourse
?
0
:
1
;
LookAllController
*
lookAllVC
=
[[
LookAllController
alloc
]
initWithDefaultIndex
:
defaultIndex
];
[
self
.
ds_viewController
.
navigationController
pushViewController
:
lookAllVC
animated
:
YES
];
}
#pragma mark - lazy
-
(
UIButton
*
)
moreBtn
{
if
(
!
_moreBtn
)
{
_moreBtn
=
[
UIButton
dkBtnWithSubTitle
:
@"查看全部"
imgName
:
@"rightRow"
font
:
SysFont
(
12
)];
_moreBtn
.
frame
=
CGRectMake
(
0
,
0
,
100
,
40
);
[
_moreBtn
adjustLayoutWithType
:
UIButtonLayoutTypeLeftTitleRightImage
midSpace
:
4
sizeToFit
:
NO
];
[
_moreBtn
addTarget
:
self
action
:
@selector
(
lookAllAction
)
forControlEvents
:
UIControlEventTouchUpInside
];
}
return
_moreBtn
;
}
-
(
SafeHelperCollectionView
*
)
shCollectionView
{
if
(
!
_shCollectionView
)
{
_shCollectionView
=
[[
SafeHelperCollectionView
alloc
]
initWithCellIndex
:
self
.
cellIndex
];
}
return
_shCollectionView
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/DSHomeView.h
0 → 100644
查看文件 @
1bed1b3
//
// DSHomeView.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <UIKit/UIKit.h>
#import "SafeSleepModel.h"
NS_ASSUME_NONNULL_BEGIN
/// APP首页自定义视图
@interface
DSHomeView
:
UITableView
/// 刷新banner
/// @param bannerListData bannerListData
-
(
void
)
refreshBarnner
:(
NSArray
*
)
bannerListData
;
/// 刷新舒眠课程或者助眠音乐cell
/// @param type type
/// @param dataArr dataArr
-
(
void
)
updateCourseMusicCell
:(
CellType
)
type
data
:(
NSArray
*
)
dataArr
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
HomeTabl
eView.m
→
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
DSHom
eView.m
查看文件 @
1bed1b3
//
//
//
HomeTabl
eView.m
//
DSHom
eView.m
// DreamSleep
// DreamSleep
//
//
// Created by peter on 2022/
4/8
.
// Created by peter on 2022/
5/11
.
//
//
#import "
HomeTabl
eView.h"
#import "
DSHom
eView.h"
#import "HomeHeaderView.h"
#import "HomeHeaderView.h"
#import "SafeSleepCell.h"
#import "CourseMusicCell.h"
#import "HomeRequestModel.h"
#import "GoodSleepSoundCell.h"
#import "SafeSleepRequestModel.h"
@interface
HomeTableView
()
<
UITableViewDelegat
e
>
@interface
DSHomeView
()
<
UITableViewDelegate
,
UITableViewDataSourc
e
>
@property
(
nonatomic
,
strong
)
HomeHeaderView
*
headerView
;
@property
(
nonatomic
,
strong
)
HomeHeaderView
*
headerView
;
@property
(
nonatomic
,
strong
)
DSDataSource
*
homeDataSource
;
@property
(
nonatomic
,
strong
)
NSArray
*
courseMusicArr
;
@property
(
nonatomic
,
strong
)
NSArray
*
dataArr
;
@end
@end
@implementation
HomeTableView
{
@implementation
DSHomeView
// 舒眠课程数据
NSArray
*
_courseSafeArr
;
// 助眠音乐数据
NSArray
*
_courseHelpArr
;
}
-
(
instancetype
)
init
{
-
(
instancetype
)
init
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
)
style
:
UITableViewStylePlain
])
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
)
style
:
UITableViewStylePlain
])
{
_courseSafeArr
=
@[];
_courseHelpArr
=
@[];
self
.
dataArr
=
[
SafeSleepModel
getDatas
];
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
self
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
self
.
showsVerticalScrollIndicator
=
NO
;
self
.
showsVerticalScrollIndicator
=
NO
;
self
.
delegate
=
self
;
[
self
.
homeDataSource
addDataArray
:
self
.
dataArr
];
self
.
dataSource
=
self
;
[
self
registerClass
:[
CourseMusicCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
CourseMusicCell
class
])];
self
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
[
self
registerClass
:[
GoodSleepSoundCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
GoodSleepSoundCell
class
])];
// 获取首页banner数据
self
.
tableHeaderView
=
self
.
headerView
;
[
HomeRequestModel
queryBannerListWithCompletion
:
^
(
HomeRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
headerView
updateBannerWithListData
:
requestModel
.
bannerListData
];
}
}];
// 获取首页舒眠课程数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
6
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
->
_courseSafeArr
=
requestModel
.
courseListData
;
}
}];
// 获取首页助眠音乐数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
18
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
->
_courseHelpArr
=
requestModel
.
courseListData
;
}
}];
}];
[
self
.
mj_header
beginRefreshing
];
}
}
return
self
;
return
self
;
}
}
#pragma mark - lazy
-
(
void
)
refreshBarnner
:
(
NSArray
*
)
bannerListData
{
-
(
DSDataSource
*
)
homeDataSource
{
[
self
.
headerView
updateBannerWithListData
:
bannerListData
];
if
(
!
_homeDataSource
)
{
CellConfigureBlock
cellBlock
=
^
(
SafeSleepCell
*
cell
,
SafeSleepModel
*
model
,
NSIndexPath
*
indexPath
)
{
[
cell
configureCellWithModel
:
model
indexPath
:
indexPath
];
};
NSString
*
const
safeSleepCellID
=
@"safeSleepCellID"
;
_homeDataSource
=
[[
DSDataSource
alloc
]
initWithIdentifier
:
safeSleepCellID
datas
:@[]
isSection
:
NO
configureBlock
:
cellBlock
];
self
.
dataSource
=
_homeDataSource
;
self
.
delegate
=
self
;
[
self
registerClass
:[
SafeSleepCell
class
]
forCellReuseIdentifier
:
safeSleepCellID
];
self
.
tableHeaderView
=
self
.
headerView
;
}
return
_homeDataSource
;
}
}
-
(
HomeHeaderView
*
)
headerView
{
-
(
void
)
updateCourseMusicCell
:
(
CellType
)
type
data
:
(
NSArray
*
)
dataArr
{
if
(
!
_headerView
)
{
NSInteger
index
=
type
==
CellTypeCourse
?
0
:
1
;
// banner高度
CourseMusicCell
*
cell
=
(
CourseMusicCell
*
)[
self
cellForRowAtIndexPath
:[
NSIndexPath
indexPathForRow
:
index
inSection
:
0
]];
CGFloat
bannerH
=
2
*
(
kScreenWidth
-
48
)
/
5
.
0
;
[
cell
updateCourseMusicListWithData
:
dataArr
cellIndex
:
index
];
// 三分钟即刻入睡按钮宽度
}
CGFloat
width
=
(
kScreenWidth
-
2
*
15
-
14
)
/
2
;
CGFloat
height
=
15
+
bannerH
+
24
+
133
*
width
/
165
.
0
;
-
(
NSString
*
)
cellIdentiferAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
_headerView
=
[[
HomeHeaderView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
height
)];
SafeSleepModel
*
item
=
self
.
courseMusicArr
[
indexPath
.
row
];
_headerView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
if
(
item
.
type
==
CellTypeGood
)
{
return
NSStringFromClass
([
GoodSleepSoundCell
class
]);
}
else
{
return
NSStringFromClass
([
CourseMusicCell
class
]);
}
}
return
_headerView
;
}
}
#pragma mark - UITableViewDelegate
#pragma mark - UITableViewDelegate && UITableViewDataSource
-
(
nonnull
UITableViewCell
*
)
tableView
:
(
nonnull
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
nonnull
NSIndexPath
*
)
indexPath
{
HomeBasicCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:[
self
cellIdentiferAtIndexPath
:
indexPath
]
forIndexPath
:
indexPath
];
[
cell
configBasicData
:
self
.
courseMusicArr
[
indexPath
.
row
]
cellIndex
:
indexPath
.
row
];
return
cell
;
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
return
self
.
courseMusicArr
.
count
;
}
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
CGFloat
height
=
300
;
CGFloat
height
=
300
;
if
(
indexPath
.
row
==
0
)
{
if
(
indexPath
.
row
==
0
)
{
...
@@ -119,4 +87,25 @@
...
@@ -119,4 +87,25 @@
return
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
10
,
0
.
001
)];
return
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
10
,
0
.
001
)];
}
}
#pragma mark - lazy
-
(
HomeHeaderView
*
)
headerView
{
if
(
!
_headerView
)
{
// banner高度
CGFloat
bannerH
=
2
*
(
kScreenWidth
-
48
)
/
5
.
0
;
// 三分钟即刻入睡按钮宽度
CGFloat
width
=
(
kScreenWidth
-
2
*
15
-
14
)
/
2
;
CGFloat
height
=
15
+
bannerH
+
24
+
133
*
width
/
165
.
0
;
_headerView
=
[[
HomeHeaderView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
height
)];
_headerView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
}
return
_headerView
;
}
-
(
NSArray
*
)
courseMusicArr
{
if
(
!
_courseMusicArr
)
{
_courseMusicArr
=
[
SafeSleepModel
getDatas
];
}
return
_courseMusicArr
;
}
@end
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
HomeTableView
.h
→
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
GoodSleepSoundCell
.h
查看文件 @
1bed1b3
//
//
//
HomeTableView
.h
//
GoodSleepSoundCell
.h
// DreamSleep
// DreamSleep
//
//
// Created by peter on 2022/
4/8
.
// Created by peter on 2022/
5/11
.
//
//
#import
<UIKit/UIKit.h>
#import
"HomeBasicCell.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
/// 自定义首页tableView
/// 好眠声音cell
@interface
HomeTableView
:
UITableView
@interface
GoodSleepSoundCell
:
HomeBasicCell
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/View/GoodSleepSoundCell.m
0 → 100644
查看文件 @
1bed1b3
//
// GoodSleepSoundCell.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "GoodSleepSoundCell.h"
@interface
GoodSleepSoundCell
()
@property
(
nonatomic
,
strong
)
UIButton
*
timerBtn
;
@end
@implementation
GoodSleepSoundCell
-
(
instancetype
)
initWithStyle
:(
UITableViewCellStyle
)
style
reuseIdentifier
:(
NSString
*
)
reuseIdentifier
{
if
(
self
=
[
super
initWithStyle
:
style
reuseIdentifier
:
reuseIdentifier
])
{
[
self
.
contentView
addSubview
:
self
.
timerBtn
];
[
self
.
timerBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
contentView
.
mas_right
).
offset
(
-
5
);
make
.
width
.
equalTo
(
@100
);
make
.
height
.
equalTo
(
@30
);
make
.
centerY
.
equalTo
(
self
.
verticalView
.
mas_centerY
);
}];
}
return
self
;
}
#pragma mark - Actions
-
(
void
)
timerSetting
:(
UIButton
*
)
sender
{
DSLog
(
@"66666:%ld"
,
self
.
model
.
type
);
DSLog
(
@"timerSetting"
);
}
#pragma mark - lazy
-
(
UIButton
*
)
timerBtn
{
if
(
!
_timerBtn
)
{
_timerBtn
=
[
UIButton
new
];
[
_timerBtn
dk_setImage
:
DKImagePickerWithNames
(
@"timerIcon"
,
@"timerIcon_dk"
,
@"timerIcon_dk"
)
forState
:
UIControlStateNormal
];
[
_timerBtn
addTarget
:
self
action
:
@selector
(
timerSetting
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
}
return
_timerBtn
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
SafeSleep
Cell.h
→
DreamSleep/DreamSleep/Class/HomeModule/Home/View/
HomeBasic
Cell.h
查看文件 @
1bed1b3
//
//
//
SafeSleep
Cell.h
//
HomeBasic
Cell.h
// DreamSleep
// DreamSleep
//
//
// Created by peter on 2022/
4
/11.
// Created by peter on 2022/
5
/11.
//
//
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
...
@@ -10,14 +10,19 @@
...
@@ -10,14 +10,19 @@
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程、助眠音乐、好眠声音静态Cell
/// 首页基础Cell
@interface
SafeSleepCell
:
UITableViewCell
@interface
HomeBasicCell
:
UITableViewCell
/// 左边竖条视图
@property
(
nonatomic
,
strong
)
UIView
*
verticalView
;
/// 标题标签
@property
(
nonatomic
,
strong
)
UILabel
*
titleLab
;
/// 通用数据项
@property
(
nonatomic
,
strong
)
SafeSleepModel
*
model
;
@property
(
nonatomic
,
strong
)
SafeSleepModel
*
model
;
@property
(
nonatomic
,
strong
)
NSIndexPath
*
indexPath
;
/// cellIndex
@property
(
nonatomic
,
assign
)
NSInteger
cellIndex
;
-
(
void
)
configureCellWithModel
:(
SafeSleepModel
*
)
model
indexPath
:(
NSIndexPath
*
)
indexPath
;
-
(
void
)
configBasicData
:(
SafeSleepModel
*
)
model
cellIndex
:(
NSInteger
)
cellIndex
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeBasicCell.m
0 → 100644
查看文件 @
1bed1b3
//
// HomeBasicCell.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "HomeBasicCell.h"
@interface
HomeBasicCell
()
@end
@implementation
HomeBasicCell
-
(
instancetype
)
initWithStyle
:(
UITableViewCellStyle
)
style
reuseIdentifier
:(
NSString
*
)
reuseIdentifier
{
if
(
self
=
[
super
initWithStyle
:
style
reuseIdentifier
:
reuseIdentifier
])
{
self
.
contentView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
contentView
addSubview
:
self
.
verticalView
];
[
self
.
contentView
addSubview
:
self
.
titleLab
];
[
self
.
verticalView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
contentView
.
mas_left
).
offset
(
10
);
make
.
top
.
equalTo
(
self
.
contentView
.
mas_top
).
offset
(
33
);
make
.
width
.
equalTo
(
@4
);
make
.
height
.
equalTo
(
@16
);
}];
}
return
self
;
}
-
(
void
)
configBasicData
:(
SafeSleepModel
*
)
model
cellIndex
:(
NSInteger
)
cellIndex
{
_model
=
model
;
_cellIndex
=
cellIndex
;
self
.
titleLab
.
text
=
model
.
title
;
[
self
.
titleLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
verticalView
.
mas_right
).
offset
(
10
);
make
.
centerY
.
equalTo
(
self
.
verticalView
.
mas_centerY
);
}];
}
#pragma mark - lazy
-
(
UIView
*
)
verticalView
{
if
(
!
_verticalView
)
{
_verticalView
=
[
UIView
new
];
_verticalView
.
backgroundColor
=
BrandColor
;
[
_verticalView
cornerRadius
:
3
];
}
return
_verticalView
;
}
-
(
UILabel
*
)
titleLab
{
if
(
!
_titleLab
)
{
_titleLab
=
[
UILabel
dkLabWithFont
:
BoldFont
(
16
.
0
)];
}
return
_titleLab
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.h
查看文件 @
1bed1b3
...
@@ -12,9 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -12,9 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程、助眠音乐集合视图
/// 舒眠课程、助眠音乐集合视图
@interface
SafeHelperCollectionView
:
UICollectionView
@interface
SafeHelperCollectionView
:
UICollectionView
-
(
instancetype
)
init
CollectionViewWithIndexPath
:(
NSIndexPath
*
)
indexPath
;
-
(
instancetype
)
init
WithCellIndex
:(
NSInteger
)
cellIndex
;
-
(
instancetype
)
initWithIndexPath
:(
NSIndexPath
*
)
indexPath
courseListDatas
:(
NSArray
*
)
courseListDatas
;
-
(
void
)
reloadWithData
:(
NSArray
*
)
dataArr
cellIndex
:(
NSInteger
)
cellIndex
;
@end
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.m
查看文件 @
1bed1b3
...
@@ -7,20 +7,22 @@
...
@@ -7,20 +7,22 @@
#import "SafeHelperCollectionView.h"
#import "SafeHelperCollectionView.h"
#import "SafeHelperCollectionViewCell.h"
#import "SafeHelperCollectionViewCell.h"
#import "CourseDetailController.h"
@interface
SafeHelperCollectionView
()
<
UICollectionViewDelegate
,
UICollectionViewDataSource
>
@interface
SafeHelperCollectionView
()
<
UICollectionViewDelegate
,
UICollectionViewDataSource
>
@property
(
nonatomic
,
strong
)
NSIndexPath
*
cellIndexPath
;
/// 首页传递过来的cell下标
@property
(
nonatomic
,
assign
)
NSInteger
cellIndex
;
/// 首页舒眠课程和助眠音乐课程列表数据
/// 首页舒眠课程和助眠音乐课程列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
courseListData
;
@property
(
nonatomic
,
strong
)
NSArray
*
courseListData
;
@end
@end
@implementation
SafeHelperCollectionView
@implementation
SafeHelperCollectionView
-
(
instancetype
)
initWith
IndexPath
:(
NSIndexPath
*
)
indexPath
courseListDatas
:(
NSArray
*
)
courseListDatas
{
-
(
instancetype
)
initWith
CellIndex
:(
NSInteger
)
cellIndex
{
self
.
c
ourseListData
=
courseListDatas
;
self
.
c
ellIndex
=
cellIndex
;
self
.
c
ellIndexPath
=
indexPath
;
self
.
c
ourseListData
=
@[]
;
CGFloat
width
=
indexPath
.
row
==
0
?
100
:
90
;
CGFloat
width
=
cellIndex
==
0
?
100
:
90
;
CGFloat
height
=
indexPath
.
row
==
0
?
130
:
120
;
CGFloat
height
=
cellIndex
==
0
?
130
:
120
;
UICollectionViewFlowLayout
*
layout
=
[[
UICollectionViewFlowLayout
alloc
]
init
];
UICollectionViewFlowLayout
*
layout
=
[[
UICollectionViewFlowLayout
alloc
]
init
];
layout
.
sectionInset
=
UIEdgeInsetsMake
(
0
,
0
,
0
,
10
);
layout
.
sectionInset
=
UIEdgeInsetsMake
(
0
,
0
,
0
,
10
);
layout
.
itemSize
=
CGSizeMake
(
width
,
height
);
layout
.
itemSize
=
CGSizeMake
(
width
,
height
);
...
@@ -37,6 +39,12 @@
...
@@ -37,6 +39,12 @@
return
self
;
return
self
;
}
}
-
(
void
)
reloadWithData
:(
NSArray
*
)
dataArr
cellIndex
:(
NSInteger
)
cellIndex
{
self
.
cellIndex
=
cellIndex
;
self
.
courseListData
=
dataArr
;
[
self
reloadData
];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
-
(
NSInteger
)
collectionView
:(
UICollectionView
*
)
collectionView
numberOfItemsInSection
:(
NSInteger
)
section
{
-
(
NSInteger
)
collectionView
:(
UICollectionView
*
)
collectionView
numberOfItemsInSection
:(
NSInteger
)
section
{
return
self
.
courseListData
.
count
;
return
self
.
courseListData
.
count
;
...
@@ -44,12 +52,16 @@
...
@@ -44,12 +52,16 @@
-
(
UICollectionViewCell
*
)
collectionView
:(
UICollectionView
*
)
collectionView
cellForItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
-
(
UICollectionViewCell
*
)
collectionView
:(
UICollectionView
*
)
collectionView
cellForItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
SafeHelperCollectionViewCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"shCollectionViewCell"
forIndexPath
:
indexPath
];
SafeHelperCollectionViewCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"shCollectionViewCell"
forIndexPath
:
indexPath
];
cell
.
courseModel
=
self
.
courseListData
[
indexPath
.
row
];
[
cell
updateCellWithCellIndex
:
self
.
cellIndex
model
:
self
.
courseListData
[
indexPath
.
row
]
];
return
cell
;
return
cell
;
}
}
-
(
void
)
collectionView
:(
UICollectionView
*
)
collectionView
didSelectItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
-
(
void
)
collectionView
:(
UICollectionView
*
)
collectionView
didSelectItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
DSLog
(
@"row:%ld"
,
indexPath
.
row
);
CourseModel
*
model
=
[
self
.
courseListData
objectAtIndex
:
indexPath
.
row
];
CourseDetailController
*
coureDetailVC
=
[[
CourseDetailController
alloc
]
init
];
coureDetailVC
.
courseModel
=
model
;
coureDetailVC
.
courseType
=
self
.
cellIndex
==
0
?
CourseTypeSafe
:
CourseTypeRelax
;
[
self
.
ds_viewController
.
navigationController
pushViewController
:
coureDetailVC
animated
:
YES
];
}
}
@end
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.h
查看文件 @
1bed1b3
...
@@ -12,9 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -12,9 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface
SafeHelperCollectionViewCell
:
UICollectionViewCell
@interface
SafeHelperCollectionViewCell
:
UICollectionViewCell
@property
(
nonatomic
,
strong
)
CourseModel
*
courseModel
;
-
(
void
)
updateCellWithCellIndex
:(
NSInteger
)
cellIndex
model
:(
CourseModel
*
)
model
;
-
(
void
)
mockDatas
:(
NSIndexPath
*
)
cellIndexPath
;
@end
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.m
查看文件 @
1bed1b3
...
@@ -30,23 +30,17 @@
...
@@ -30,23 +30,17 @@
return
self
;
return
self
;
}
}
-
(
void
)
setCourseModel
:(
CourseModel
*
)
courseModel
{
-
(
void
)
updateCellWithCellIndex
:(
NSInteger
)
cellIndex
model
:(
CourseModel
*
)
model
{
_courseModel
=
courseModel
;
[
self
.
homeIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
home_img
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
audioTypeLab
.
text
=
model
.
audio_name
;
[
self
.
homeIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
courseModel
.
home_img
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
}
-
(
void
)
mockDatas
:(
NSIndexPath
*
)
cellIndexPath
{
self
.
homeIV
.
image
=
[
UIImage
imageNamed
:
cellIndexPath
.
row
==
0
?
@"test0"
:
@"test1"
];
self
.
audioTypeLab
.
text
=
@"都会浪漫"
;
[
self
.
audioTypeLab
sizeToFit
];
[
self
.
audioTypeLab
sizeToFit
];
if
(
cellIndex
Path
.
row
==
0
)
{
// 舒眠课程
if
(
cellIndex
==
0
)
{
// 舒眠课程
[
self
insertSubview
:
self
.
roundedView
belowSubview
:
self
.
homeIV
];
[
self
insertSubview
:
self
.
roundedView
belowSubview
:
self
.
homeIV
];
[
self
addSubview
:
self
.
courseIcon
];
[
self
addSubview
:
self
.
courseIcon
];
[
self
addSubview
:
self
.
courseLab
];
[
self
addSubview
:
self
.
courseLab
];
self
.
courseLab
.
text
=
@"10课时"
;
self
.
courseLab
.
text
=
[
NSString
stringWithFormat
:
@"%d"
,
model
.
count
]
;
[
self
.
courseLab
sizeToFit
];
[
self
.
courseLab
sizeToFit
];
[
self
.
roundedView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
.
roundedView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
...
@@ -64,9 +58,10 @@
...
@@ -64,9 +58,10 @@
make
.
centerY
.
equalTo
(
self
.
courseIcon
);
make
.
centerY
.
equalTo
(
self
.
courseIcon
);
}];
}];
}
}
CGFloat
width
=
cellIndexPath
.
row
==
0
?
100
:
90
;
CGFloat
bottomSpace
=
cellIndexPath
.
row
==
0
?
0
:
-
3
;
CGFloat
width
=
cellIndex
==
0
?
100
:
90
;
CGFloat
topSpacing
=
cellIndexPath
.
row
==
0
?
4
:
0
;
CGFloat
bottomSpace
=
cellIndex
==
0
?
0
:
-
3
;
CGFloat
topSpacing
=
cellIndex
==
0
?
4
:
0
;
[
self
.
homeIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
.
homeIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
).
offset
(
topSpacing
);
make
.
top
.
equalTo
(
self
).
offset
(
topSpacing
);
make
.
left
.
equalTo
(
self
);
make
.
left
.
equalTo
(
self
);
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
deleted
100644 → 0
查看文件 @
1765b8b
//
// SafeSleepCell.m
// DreamSleep
//
// Created by peter on 2022/4/11.
//
#import "SafeSleepCell.h"
#import "SafeHelperCollectionView.h"
#import "SafeHelperCollectionViewCell.h"
#import "LookAllController.h"
@interface
SafeSleepCell
()
@property
(
nonatomic
,
strong
)
UIView
*
leftIV
;
@property
(
nonatomic
,
strong
)
UILabel
*
recommandLb
;
@property
(
nonatomic
,
strong
)
UIButton
*
moreBtn
;
@property
(
nonatomic
,
strong
)
UIButton
*
timerBtn
;
@property
(
nonatomic
,
strong
)
SafeHelperCollectionView
*
shCollectionView
;
@end
@implementation
SafeSleepCell
-
(
instancetype
)
initWithStyle
:(
UITableViewCellStyle
)
style
reuseIdentifier
:(
NSString
*
)
reuseIdentifier
{
if
(
self
=
[
super
initWithStyle
:
style
reuseIdentifier
:
reuseIdentifier
])
{
self
.
contentView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
contentView
addSubview
:
self
.
leftIV
];
[
self
.
contentView
addSubview
:
self
.
recommandLb
];
}
return
self
;
}
// 隐藏选中Cell时的分割线
-
(
void
)
setSelected
:(
BOOL
)
selected
animated
:(
BOOL
)
animated
{
self
.
selectedBackgroundView
=
[[
UIView
alloc
]
initWithFrame
:
self
.
frame
];
self
.
selectedBackgroundView
.
backgroundColor
=
DSClearColor
;
[
super
setSelected
:
selected
animated
:
animated
];
}
-
(
void
)
configureCellWithModel
:(
SafeSleepModel
*
)
model
indexPath
:(
NSIndexPath
*
)
indexPath
{
_model
=
model
;
_indexPath
=
indexPath
;
self
.
recommandLb
.
text
=
model
.
title
;
[
self
.
leftIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
contentView
.
mas_left
).
offset
(
10
);
make
.
top
.
equalTo
(
self
.
contentView
.
mas_top
).
offset
(
33
);
make
.
width
.
equalTo
(
@4
);
make
.
height
.
equalTo
(
@16
);
}];
[
self
.
recommandLb
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
leftIV
.
mas_right
).
offset
(
10
);
make
.
centerY
.
equalTo
(
self
.
leftIV
.
mas_centerY
);
}];
if
(
indexPath
.
row
==
2
)
{
// 好眠声音区域
[
self
.
contentView
addSubview
:
self
.
timerBtn
];
[
self
.
timerBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
contentView
.
mas_right
).
offset
(
-
5
);
make
.
width
.
equalTo
(
@100
);
make
.
height
.
equalTo
(
@30
);
make
.
centerY
.
equalTo
(
self
.
leftIV
.
mas_centerY
);
}];
}
else
{
// 舒眠课程和助眠音乐
[
self
.
contentView
addSubview
:
self
.
moreBtn
];
[
self
.
contentView
addSubview
:
self
.
shCollectionView
];
[
self
.
moreBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
contentView
.
mas_right
).
offset
(
-
5
);
make
.
width
.
equalTo
(
@100
);
make
.
height
.
equalTo
(
@30
);
make
.
centerY
.
equalTo
(
self
.
leftIV
.
mas_centerY
);
}];
[
self
.
shCollectionView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
recommandLb
.
mas_bottom
).
offset
(
17
);
make
.
left
.
equalTo
(
self
.
leftIV
);
make
.
right
.
equalTo
(
self
.
contentView
);
make
.
bottom
.
equalTo
(
self
.
contentView
).
offset
(
0
);
}];
}
}
#pragma mark - lazy
-
(
UIView
*
)
leftIV
{
if
(
!
_leftIV
)
{
_leftIV
=
[
UIView
new
];
_leftIV
.
backgroundColor
=
BrandColor
;
_leftIV
.
layer
.
cornerRadius
=
3
;
_leftIV
.
layer
.
masksToBounds
=
YES
;
}
return
_leftIV
;
}
-
(
UILabel
*
)
recommandLb
{
if
(
!
_recommandLb
)
{
_recommandLb
=
[
UILabel
dkLabWithText
:
@"助眠音乐"
font
:
BoldFont
(
16
.
0
)];
}
return
_recommandLb
;
}
-
(
UIButton
*
)
moreBtn
{
if
(
!
_moreBtn
)
{
_moreBtn
=
[
UIButton
dkBtnWithSubTitle
:
@"查看全部"
imgName
:
@"rightRow"
font
:
SysFont
(
12
)];
_moreBtn
.
frame
=
CGRectMake
(
0
,
0
,
100
,
40
);
[
_moreBtn
adjustLayoutWithType
:
UIButtonLayoutTypeLeftTitleRightImage
midSpace
:
4
sizeToFit
:
NO
];
[
_moreBtn
addTarget
:
self
action
:
@selector
(
lookMore
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
}
return
_moreBtn
;
}
-
(
UIButton
*
)
timerBtn
{
if
(
!
_timerBtn
)
{
_timerBtn
=
[
UIButton
new
];
[
_timerBtn
dk_setImage
:
DKImagePickerWithNames
(
@"timerIcon"
,
@"timerIcon_dk"
,
@"timerIcon_dk"
)
forState
:
UIControlStateNormal
];
[
_timerBtn
addTarget
:
self
action
:
@selector
(
timerSetting
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
}
return
_timerBtn
;
}
-
(
SafeHelperCollectionView
*
)
shCollectionView
{
if
(
!
_shCollectionView
)
{
_shCollectionView
=
[[
SafeHelperCollectionView
alloc
]
initWithIndexPath
:
self
.
indexPath
courseListDatas
:@[]];
}
return
_shCollectionView
;
}
#pragma mark - Actions
-
(
void
)
timerSetting
:
(
UIButton
*
)
sender
{
DSLog
(
@"timerSetting"
);
}
-
(
void
)
lookMore
:
(
UIButton
*
)
sender
{
LookAllController
*
lookAllVC
=
[[
LookAllController
alloc
]
initWithIndexPath
:
self
.
indexPath
];
[
self
.
ds_viewController
.
navigationController
pushViewController
:
lookAllVC
animated
:
YES
];
}
@end
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test0.imageset/Contents.json
deleted
100644 → 0
查看文件 @
1765b8b
{
"images"
:
[
{
"filename"
:
"test0.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test0.imageset/test0.png
deleted
100644 → 0
查看文件 @
1765b8b
49.3 KB
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test1.imageset/Contents.json
deleted
100644 → 0
查看文件 @
1765b8b
{
"images"
:
[
{
"filename"
:
"test1.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/test1.imageset/test1.png
deleted
100644 → 0
查看文件 @
1765b8b
35.5 KB
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论