Commit 6ebc1c44 cgx

首页白噪音显示模块初步完成

1 个父辈 1bed1b3e
正在显示 28 个修改的文件 包含 632 行增加3 行删除
...@@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 用于调试UI /// 用于调试UI
- (void)debugViewShowBorder; - (void)debugViewShowBorder;
- (void)debugViewShowBorderWithColor:(UIColor *)color;
/// 设置圆角 /// 设置圆角
/// @param radius radius /// @param radius radius
- (void)cornerRadius:(CGFloat)radius; - (void)cornerRadius:(CGFloat)radius;
......
...@@ -104,6 +104,11 @@ ...@@ -104,6 +104,11 @@
self.layer.borderWidth = 2; self.layer.borderWidth = 2;
} }
- (void)debugViewShowBorderWithColor:(UIColor *)color {
self.layer.borderColor = color.CGColor;
self.layer.borderWidth = 2;
}
- (void)cornerRadius:(CGFloat)radius { - (void)cornerRadius:(CGFloat)radius {
self.layer.cornerRadius = radius; self.layer.cornerRadius = radius;
self.layer.masksToBounds = YES; self.layer.masksToBounds = YES;
......
...@@ -36,6 +36,8 @@ FOUNDATION_EXTERN NSString * const ExpireTime2; ...@@ -36,6 +36,8 @@ FOUNDATION_EXTERN NSString * const ExpireTime2;
FOUNDATION_EXTERN NSString * const WXLoginAuthNoti; FOUNDATION_EXTERN NSString * const WXLoginAuthNoti;
// 更新用户数据通知 // 更新用户数据通知
FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti; FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti;
// 刷新主页通知
FOUNDATION_EXTERN NSString * const NeedUpdateHomePage;
// 用户基础信息 // 用户基础信息
FOUNDATION_EXTERN NSString * const UserBasicInfo; FOUNDATION_EXTERN NSString * const UserBasicInfo;
......
...@@ -26,6 +26,7 @@ NSString * const ExpireTime2 = @"06:00:00"; ...@@ -26,6 +26,7 @@ NSString * const ExpireTime2 = @"06:00:00";
NSString * const WXLoginAuthNoti = @"wxLoginAuthNoti"; NSString * const WXLoginAuthNoti = @"wxLoginAuthNoti";
NSString * const HasUpdateUserDataNoti = @"hasUpdateUserDataNoti"; NSString * const HasUpdateUserDataNoti = @"hasUpdateUserDataNoti";
NSString * const NeedUpdateHomePage = @"NeedUpdateHomePageNoti";
NSString * const UserBasicInfo = @"UserBasicInfo"; NSString * const UserBasicInfo = @"UserBasicInfo";
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "HomeRequestModel.h" #import "HomeRequestModel.h"
#import "ThreeMinuteController.h" #import "ThreeMinuteController.h"
#import "SafeSleepRequestModel.h" #import "SafeSleepRequestModel.h"
#import "WhiteNoiseRequestModel.h"
@interface HomeViewController () @interface HomeViewController ()
@property (nonatomic, strong) DSHomeView *homeTV; @property (nonatomic, strong) DSHomeView *homeTV;
...@@ -44,6 +45,25 @@ ...@@ -44,6 +45,25 @@
[self showFirstLeadAlertView]; [self showFirstLeadAlertView];
[self requestHomeData]; [self requestHomeData];
// 监听主页需要刷新数据通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
dispatch_async(dispatch_get_main_queue(), ^{
self.homeTV.frame = CGRectMake(0, kTopHeight(0), kScreenWidth, kScreenHeight - kTopHeight(0) - kTabBarHeight);
});
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil];
}
- (void)needUpdate {
[self.homeTV.mj_header beginRefreshing];
} }
#pragma mark - banner、舒眠课程、助眠音乐数据获取 #pragma mark - banner、舒眠课程、助眠音乐数据获取
...@@ -70,6 +90,13 @@ ...@@ -70,6 +90,13 @@
[self.homeTV updateCourseMusicCell:CellTypeMusic data:requestModel.courseListData]; [self.homeTV updateCourseMusicCell:CellTypeMusic data:requestModel.courseListData];
} }
}]; }];
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
[self.homeTV.mj_header endRefreshing];
if (requestModel.resCode == DSResCodeSuccess) {
[self.homeTV updateNoiseAllTypeData:requestModel.noiseTypeArr];
}
}];
}]; }];
[self.homeTV.mj_header beginRefreshing]; [self.homeTV.mj_header beginRefreshing];
} }
......
...@@ -22,6 +22,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -22,6 +22,9 @@ NS_ASSUME_NONNULL_BEGIN
/// @param dataArr dataArr /// @param dataArr dataArr
- (void)updateCourseMusicCell:(CellType)type data:(NSArray *)dataArr; - (void)updateCourseMusicCell:(CellType)type data:(NSArray *)dataArr;
/// 更新白噪音类型数据
/// @param typeDataArr typeDataArr
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -13,17 +13,20 @@ ...@@ -13,17 +13,20 @@
@interface DSHomeView () <UITableViewDelegate, UITableViewDataSource> @interface DSHomeView () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) HomeHeaderView *headerView; @property (nonatomic, strong) HomeHeaderView *headerView;
@property (nonatomic, strong) NSArray *courseMusicArr; @property (nonatomic, strong) NSArray *courseMusicArr;
/// 类型数据
@property (nonatomic, strong) NSArray *typeArr;
@end @end
@implementation DSHomeView @implementation DSHomeView
- (instancetype)init { - (instancetype)init {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain]) { if (self = [super initWithFrame:CGRectMake(0, kTopHeight(0), kScreenWidth, kScreenHeight - kTopHeight(0) - kTabBarHeight) style:UITableViewStylePlain]) {
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.delegate = self;
self.dataSource = self; self.dataSource = self;
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[self registerClass:[CourseMusicCell class] forCellReuseIdentifier:NSStringFromClass([CourseMusicCell class])]; [self registerClass:[CourseMusicCell class] forCellReuseIdentifier:NSStringFromClass([CourseMusicCell class])];
[self registerClass:[GoodSleepSoundCell class] forCellReuseIdentifier:NSStringFromClass([GoodSleepSoundCell class])]; [self registerClass:[GoodSleepSoundCell class] forCellReuseIdentifier:NSStringFromClass([GoodSleepSoundCell class])];
self.tableHeaderView = self.headerView; self.tableHeaderView = self.headerView;
...@@ -41,6 +44,16 @@ ...@@ -41,6 +44,16 @@
[cell updateCourseMusicListWithData:dataArr cellIndex:index]; [cell updateCourseMusicListWithData:dataArr cellIndex:index];
} }
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr {
if (typeDataArr && typeDataArr.count > 0) {
self.typeArr = typeDataArr;
}
GoodSleepSoundCell *cell = (GoodSleepSoundCell *)[self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
if (cell) {
[cell updateNoiseAllTypeData:typeDataArr];
}
}
- (NSString *)cellIdentiferAtIndexPath:(NSIndexPath *)indexPath { - (NSString *)cellIdentiferAtIndexPath:(NSIndexPath *)indexPath {
SafeSleepModel *item = self.courseMusicArr[indexPath.row]; SafeSleepModel *item = self.courseMusicArr[indexPath.row];
if (item.type == CellTypeGood) { if (item.type == CellTypeGood) {
...@@ -54,6 +67,11 @@ ...@@ -54,6 +67,11 @@
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
HomeBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:[self cellIdentiferAtIndexPath:indexPath] forIndexPath:indexPath]; HomeBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:[self cellIdentiferAtIndexPath:indexPath] forIndexPath:indexPath];
[cell configBasicData:self.courseMusicArr[indexPath.row] cellIndex:indexPath.row]; [cell configBasicData:self.courseMusicArr[indexPath.row] cellIndex:indexPath.row];
if (indexPath.row == 2) {
GoodSleepSoundCell *goodCell = (GoodSleepSoundCell *)cell;
[goodCell updateNoiseAllTypeData:self.typeArr];
}
return cell; return cell;
} }
...@@ -66,7 +84,9 @@ ...@@ -66,7 +84,9 @@
if (indexPath.row == 0) { if (indexPath.row == 0) {
height = 206; height = 206;
} else if (indexPath.row == 1) { } else if (indexPath.row == 1) {
height = 196; height = 206;
} else if (indexPath.row == 2) {
height = 68 + 40 + 327;
} }
return height; return height;
} }
...@@ -108,4 +128,11 @@ ...@@ -108,4 +128,11 @@
return _courseMusicArr; return _courseMusicArr;
} }
- (NSArray *)typeArr {
if (!_typeArr) {
_typeArr = [NSArray array];
}
return _typeArr;
}
@end @end
...@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 好眠声音cell /// 好眠声音cell
@interface GoodSleepSoundCell : HomeBasicCell @interface GoodSleepSoundCell : HomeBasicCell
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
// //
#import "GoodSleepSoundCell.h" #import "GoodSleepSoundCell.h"
#import "NoiseListController.h"
#import "NoiseTypeModel.h"
#import "NoiseView.h"
@interface GoodSleepSoundCell () @interface GoodSleepSoundCell ()
@property (nonatomic, strong) UIButton *timerBtn; @property (nonatomic, strong) UIButton *timerBtn;
@property (nonatomic, strong) NoiseView *noiseView;
@end @end
@implementation GoodSleepSoundCell @implementation GoodSleepSoundCell
...@@ -16,6 +20,7 @@ ...@@ -16,6 +20,7 @@
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self.contentView addSubview:self.timerBtn]; [self.contentView addSubview:self.timerBtn];
[self.contentView addSubview:self.noiseView];
[self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-5); make.right.equalTo(self.contentView.mas_right).offset(-5);
...@@ -23,13 +28,20 @@ ...@@ -23,13 +28,20 @@
make.height.equalTo(@30); make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY); make.centerY.equalTo(self.verticalView.mas_centerY);
}]; }];
[self.noiseView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.timerBtn.mas_bottom).offset(5);
make.left.right.bottom.equalTo(self.contentView);
}];
} }
return self; return self;
} }
- (void)updateNoiseAllTypeData:(NSArray *)typeDataArr {
[self.noiseView refreshNoiseTypeData:typeDataArr];
}
#pragma mark - Actions #pragma mark - Actions
- (void)timerSetting:(UIButton *)sender { - (void)timerSetting:(UIButton *)sender {
DSLog(@"66666:%ld", self.model.type);
DSLog(@"timerSetting"); DSLog(@"timerSetting");
} }
...@@ -43,4 +55,11 @@ ...@@ -43,4 +55,11 @@
return _timerBtn; return _timerBtn;
} }
- (NoiseView *)noiseView {
if (!_noiseView) {
_noiseView = [[NoiseView alloc] initWithNoiseTypeData:@[]];
}
return _noiseView;
}
@end @end
//
// NoiseAudioCell.h
// DreamSleep
//
// Created by peter on 2022/5/13.
//
#import <UIKit/UIKit.h>
#import "NoiseAudioModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 白噪音小音频cell
@interface NoiseAudioCell : UICollectionViewCell
@property (nonatomic, strong) UIButton *audioIV;
@property (nonatomic, strong) NoiseAudioModel *model;
@end
NS_ASSUME_NONNULL_END
//
// NoiseAudioCell.m
// DreamSleep
//
// Created by peter on 2022/5/13.
//
#import "NoiseAudioCell.h"
@interface NoiseAudioCell ()
@property (nonatomic, strong) UILabel *nameLab;
@end
@implementation NoiseAudioCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self.contentView addSubview:self.audioIV];
[self.contentView addSubview:self.nameLab];
[self.audioIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.contentView).offset(5);
make.size.mas_equalTo(CGSizeMake(30, 30));
}];
}
return self;
}
- (void)setModel:(NoiseAudioModel *)model {
_model = model;
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:model.audio_img] forState:UIControlStateNormal placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:model.audio_pic] forState:UIControlStateSelected placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
self.nameLab.text = model.audio_name;
[self.nameLab sizeToFit];
[self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.audioIV.mas_bottom).offset(3);
make.centerX.equalTo(self.audioIV);
}];
}
#pragma mark - lazy
- (UIButton *)audioIV {
if (!_audioIV) {
_audioIV = [UIButton new];
_audioIV.userInteractionEnabled = NO;
_audioIV.imageView.contentMode = UIViewContentModeScaleAspectFit;
_audioIV.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
_audioIV.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
}
return _audioIV;
}
- (UILabel *)nameLab {
if (!_nameLab) {
_nameLab = [UILabel labWithFont:SysFont(12.0)];
_nameLab.textAlignment = NSTextAlignmentCenter;
_nameLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite);
}
return _nameLab;
}
@end
//
// NoiseAudioModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音音频数据model
@interface NoiseAudioModel : NSObject
// 白噪音音频id
@property (nonatomic, assign) int noise_audio_id;
// 名称
@property (nonatomic, copy) NSString *audio_name;
// 未选中图标
@property (nonatomic, copy) NSString *audio_img;
// 选中图标
@property (nonatomic, copy) NSString *audio_pic;
// 音频链接
@property (nonatomic, copy) NSString *audio_url;
// 是否推荐(默认0:不推荐,1:推荐)
@property (nonatomic, copy) NSString *is_recommend;
@end
NS_ASSUME_NONNULL_END
//
// NoiseAudioModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseAudioModel.h"
@implementation NoiseAudioModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"noise_audio_id" : @"id"};
}
@end
//
// NoiseListController.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音列分页
@interface NoiseListController : UIViewController
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID;
@end
NS_ASSUME_NONNULL_END
//
// NoiseListController.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseListController.h"
#import "WhiteNoiseRequestModel.h"
#import "NoiseAudioCell.h"
@interface NoiseListController () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *noiseAudioView;
@property (nonatomic, strong) NSArray *noiseAudioArr;
@end
@implementation NoiseListController {
NSInteger _typeID;
}
- (instancetype)initWithNoiseTypeID:(NSInteger)typeID {
if (self = [super init]) {
_typeID = typeID;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.noiseAudioView];
self.view.backgroundColor = _typeID == 32 ? BrandColor : DSRed;
[WhiteNoiseRequestModel queryRelaxWhiteNoiseAudiosWithTypeID:_typeID completion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.noiseAudioArr = requestModel.noiseAudioArr;
[self.noiseAudioView reloadData];
}
}];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.noiseAudioArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NoiseAudioCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NoiseAudioCellID" forIndexPath:indexPath];
cell.model = self.noiseAudioArr[indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// NoiseAudioModel *model = [self.noiseAudioArr objectAtIndex:indexPath.row];
NoiseAudioCell *cell = (NoiseAudioCell *)[collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]];
cell.audioIV.selected = !cell.audioIV.selected;
}
#pragma mark - lazy
- (UICollectionView *)noiseAudioView {
if (!_noiseAudioView) {
CGFloat space = (kScreenWidth - 240 - 66)/3.0;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(15, 33, 0, 33);
layout.itemSize = CGSizeMake(60, 53);
layout.minimumLineSpacing = 12;
layout.minimumInteritemSpacing = space;
_noiseAudioView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 327) collectionViewLayout:layout];
_noiseAudioView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
_noiseAudioView.delegate = self;
_noiseAudioView.dataSource = self;
[_noiseAudioView registerClass:[NoiseAudioCell class] forCellWithReuseIdentifier:@"NoiseAudioCellID"];
}
return _noiseAudioView;
}
- (NSArray *)noiseAudioArr {
if (!_noiseAudioArr) {
_noiseAudioArr = [NSArray array];
}
return _noiseAudioArr;
}
@end
//
// NoiseTypeModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 白噪音类型数据model
@interface NoiseTypeModel : NSObject
/// 白噪音分类id
@property (nonatomic, assign) int type_id;
/// 分类名称
@property (nonatomic, copy) NSString *sub_name;
/// 是否上锁(1:加锁,0:不加锁)
@property (nonatomic, assign) int is_lock;
#pragma mark - 自定义属性
/// 是否被选中
@property (nonatomic, assign) BOOL isSelected;
/// 解锁、未解锁、选中等状态宽度
@property (nonatomic, assign) CGFloat typeWidth;
- (void)calculateWidth;
@end
NS_ASSUME_NONNULL_END
//
// NoiseTypeModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "NoiseTypeModel.h"
@implementation NoiseTypeModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"type_id" : @"id"};
}
- (void)setIsSelected:(BOOL)isSelected {
_isSelected = isSelected;
}
- (void)setTypeWidth:(CGFloat)typeWidth {
_typeWidth = typeWidth;
}
- (void)calculateWidth {
// 获取文字宽度
UILabel *lab = [UILabel labWithText:self.sub_name font:(self.isSelected ? BoldFont(15.0) : SysFont(14.0)) fit:YES];
// 图片宽度
CGFloat iconW = self.is_lock == 1 ? 20 : 0;
self.typeWidth = lab.width + iconW;
}
@end
//
// NoiseView.h
// DreamSleep
//
// Created by peter on 2022/5/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/**
下划线长度取值类型
- LineWidthTypeStaticShort: 静态短长度,取个固定短值
- LineWidthTypeStaticLong: 静态长度,根据总长度/数量
- LineWidthTypeDynamic: 动态长度,根据文字长度
*/
typedef NS_ENUM(NSInteger, LineWidthType) {
LineWidthTypeStaticShort = 0,
LineWidthTypeStaticLong,
LineWidthTypeDynamic
};
/**
分页条目 cell 宽度取值类型
- PageCellWidthTypeWithTitleLength: 根据 cell 标题文字长度取值
- PageCellWidthTypeSplitScreen: pageCell个数小于屏宽最大cell展示个数时,按个数平分屏宽
- PageCellWidthTypeWidthByStaticCount: 根据屏宽最大cell展示个数平分屏宽
*/
typedef NS_ENUM(NSInteger, PageCellWidthType) {
PageCellWidthTypeByTitleLength = 0,
PageCellWidthTypeSplitScreen,
PageCellWidthTypeWidthByStaticCount
};
/**
下划线在条目切换时的动态表现类型
- LineScrollTypeDynamicAnimation: 滑动即时的下划线动态动画
- LineScrollTypeDynamicLinear: 滑动即时的下划线线性动画
- LineScrollTypeFinishedLinear: 滑动完成后的下划线线性动画
*/
typedef NS_ENUM(NSInteger, LineScrollType) {
LineScrollTypeDynamicAnimation = 0,
LineScrollTypeDynamicLinear,
LineScrollTypeScrollEndLinear
};
/** 分页滑动时标题字体大小改变方式
- PageTitleFontChangeTypeScrolling: 滑动中实时改变
- PageTitleFontChangeTypeScrollEnd: 滑动结束无动画改变
- PageTitleFontChangeTypeScrollEndAnimation: 滑动结束动画改变
*/
typedef NS_ENUM(NSInteger, PageTitleFontChangeType) {
PageTitleFontChangeTypeScrolling = 0,
PageTitleFontChangeTypeScrollEnd,
PageTitleFontChangeTypeScrollEndAnimation
};
/** 分页滑动时标题颜色改变方式
- PageTitleColorChangeTypeScrolling: 滑动中实时改变
- PageTitleColorChangeTypeScrollEnd: 滑动结束改变
*/
typedef NS_ENUM(NSInteger, PageTitleColorChangeType) {
PageTitleColorChangeTypeScrolling = 0,
PageTitleColorChangeTypeScrollEnd
};
/// 首页白噪音自定义view
@interface NoiseView : UIView
/// 配置分页类型数据
/// @param data data
- (void)refreshNoiseTypeData:(NSArray *)data;
/// 初始化
/// @param data data
- (instancetype)initWithNoiseTypeData:(NSArray *)data;
/** 分页条高度 */
@property(nonatomic, assign) CGFloat pageBarHeight;
/** 分页条背景色 */
@property (nonatomic,strong) UIColor *pageBarBgColor;
/** 下滑线颜色 */
@property (nonatomic,strong) UIColor *lineColor;
/** 下滑线颜色数组 */
@property (nonatomic,strong) NSArray *lineColors;
/** 下滑线高度 */
@property (nonatomic,assign) CGFloat lineHeight;
/** 下划线固定宽度: lineWidthType=LineWidthTypeStaticShort时设置,其他类型自动计算 */
@property (nonatomic,assign) CGFloat lineStaticWidth;
/** 分页工具条在展示区域的条目数量展示最大值: 在导航条上时默认值4,在一屏宽度上时默认值5 */
@property (nonatomic,assign) NSInteger maxPagesCountInPageShowArea;
/** 下划线长度取值类型 */
@property (nonatomic,assign) LineWidthType lineWidthType;
/** 下划线在条目切换时的动态表现类型 */
@property (nonatomic,assign) LineScrollType lineScrollType;
/** 分页条目 cell 宽度取值类型 */
@property (nonatomic,assign) PageCellWidthType pageCellWidthType;
/** 分页滑动时标题字体大小改变方式 */
@property (nonatomic,assign) PageTitleFontChangeType pageTitleFontChangeType;
/** 分页滑动时标题颜色改变方式 */
@property (nonatomic,assign) PageTitleColorChangeType pageTitleColorChangeType;
/** 标题颜色 */
@property (nonatomic,strong) UIColor *titleColor;
/** 标题选中颜色(可不设置) */
@property (nonatomic,strong) UIColor *titleSelectedColor;
/** 标题字体, default: [UIFont systemFontOfSize:15] */
@property (nonatomic,strong) UIFont *titleFont;
/** 标题选中字体(可不设置), default: [UIFont systemFontOfSize:20] */
@property (nonatomic,strong) UIFont *titleSelectedFont;
/** 默认选择的 index 位置 ,默认值为0*/
@property (nonatomic,assign) NSInteger defaultIndex;
/** 分页控制器View视图的 Y 轴方向 设置初始位置(适用于分页条不在导航条上的情况) , 动态位置由于UICollectionViewCell 的复用存在不可知 bug, 暂不实现*/
@property (nonatomic, assign) CGFloat originY;
@end
NS_ASSUME_NONNULL_END
//
// WhiteNoiseRequestModel.h
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface WhiteNoiseRequestModel : DSNetworkTool
/// 所有白噪音类型数据
@property (nonatomic, strong) NSArray *noiseTypeArr;
/// 白噪音列表数据
@property (nonatomic, strong) NSArray *noiseAudioArr;
/// 睡眠-放松训练-噪声分类请求
/// @param completion completion
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseTypeWithCompletion:(void (^)(WhiteNoiseRequestModel *requestModel))completion;
/// 睡眠-放松训练-白噪声列表请求接口
/// @param typeID 白噪音类型id
/// @param completion completion
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseAudiosWithTypeID:(NSInteger)typeID completion:(void (^)(WhiteNoiseRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// WhiteNoiseRequestModel.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "WhiteNoiseRequestModel.h"
#import "NoiseTypeModel.h"
#import "NoiseAudioModel.h"
@implementation WhiteNoiseRequestModel
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseTypeWithCompletion:(void (^)(WhiteNoiseRequestModel *requestModel))completion {
WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init];
NSString *api = @"query_relax_white_noise_type";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"睡眠-放松训练-噪声分类接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
NoiseTypeModel *noiseTypeModel = [NoiseTypeModel yy_modelWithJSON:resultArr[i]];
// if (i == 0) {
// noiseTypeModel.is_lock = 0;
// } else {
// noiseTypeModel.is_lock = ![LoginUtils getUserLoginData];
// }
[tmpArr addObject:noiseTypeModel];
}
requestModel.noiseTypeArr = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)queryRelaxWhiteNoiseAudiosWithTypeID:(NSInteger)typeID completion:(void (^)(WhiteNoiseRequestModel *requestModel))completion {
WhiteNoiseRequestModel * requestModel = [[WhiteNoiseRequestModel alloc] init];
NSString *api = @"query_relax_white_noise_audios_for_IOS";
NSString *argStr = [NSString stringWithFormat:@"query{%@(type_id:%ld)}", api, typeID];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"睡眠-放松训练-白噪声列表接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
NoiseAudioModel *noiseAudioModel = [NoiseAudioModel yy_modelWithJSON:resultArr[i]];
[tmpArr addObject:noiseAudioModel];
}
requestModel.noiseAudioArr = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
[self clearUserData:@"退出成功"]; [self clearUserData:@"退出成功"];
// 刷新我的个人信息相关数据 // 刷新我的个人信息相关数据
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} }
}]; }];
} }
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
[DSProgressHUD showToast:@"登录成功"]; [DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); } if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} else { } else {
[DSProgressHUD showToast:requestModel.errorInfo]; [DSProgressHUD showToast:requestModel.errorInfo];
} }
...@@ -125,6 +127,8 @@ ...@@ -125,6 +127,8 @@
[DSProgressHUD showToast:@"登录成功"]; [DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); } if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
// 刷新主页数据
[[NSNotificationCenter defaultCenter] postNotificationName:NeedUpdateHomePage object:nil];
} else { } else {
[DSProgressHUD showToast:requestModel.errorInfo]; [DSProgressHUD showToast:requestModel.errorInfo];
} }
......
{
"images" : [
{
"filename" : "dk_ic_voice_lock_unselected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_voice_lock_unselected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_voice_lock_unselected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!