Commit a01b08a9 cgx

初步完成每日任务功能模块

1 个父辈 a2822f71
正在显示 25 个修改的文件 包含 616 行增加151 行删除
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
D043DD58285B25EE0043A4CE /* VersionRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D043DD57285B25EE0043A4CE /* VersionRequestModel.m */; }; D043DD58285B25EE0043A4CE /* VersionRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D043DD57285B25EE0043A4CE /* VersionRequestModel.m */; };
D0496798283484CC00FB81E5 /* ProfileTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0496797283484CC00FB81E5 /* ProfileTableView.m */; }; D0496798283484CC00FB81E5 /* ProfileTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0496797283484CC00FB81E5 /* ProfileTableView.m */; };
D049679D2834E1AB00FB81E5 /* ProfileHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D049679C2834E1AB00FB81E5 /* ProfileHeaderView.m */; }; D049679D2834E1AB00FB81E5 /* ProfileHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D049679C2834E1AB00FB81E5 /* ProfileHeaderView.m */; };
D049886E286E9209000ACF55 /* TaskTimerTool.m in Sources */ = {isa = PBXBuildFile; fileRef = D049886D286E9209000ACF55 /* TaskTimerTool.m */; };
D0498874286E95F2000ACF55 /* DsTaskManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0498873286E95F2000ACF55 /* DsTaskManager.m */; };
D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */ = {isa = PBXBuildFile; fileRef = D04B3D9827F6D4D90022F8DF /* LeadingController.m */; }; D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */ = {isa = PBXBuildFile; fileRef = D04B3D9827F6D4D90022F8DF /* LeadingController.m */; };
D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = D04B3DAA27F6EEB40022F8DF /* DSTabBarController.m */; }; D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = D04B3DAA27F6EEB40022F8DF /* DSTabBarController.m */; };
D04B3DB327F6F6070022F8DF /* Home.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D04B3DB227F6F6070022F8DF /* Home.storyboard */; }; D04B3DB327F6F6070022F8DF /* Home.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D04B3DB227F6F6070022F8DF /* Home.storyboard */; };
...@@ -321,6 +323,10 @@ ...@@ -321,6 +323,10 @@
D0496797283484CC00FB81E5 /* ProfileTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfileTableView.m; sourceTree = "<group>"; }; D0496797283484CC00FB81E5 /* ProfileTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfileTableView.m; sourceTree = "<group>"; };
D049679B2834E1AB00FB81E5 /* ProfileHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProfileHeaderView.h; sourceTree = "<group>"; }; D049679B2834E1AB00FB81E5 /* ProfileHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProfileHeaderView.h; sourceTree = "<group>"; };
D049679C2834E1AB00FB81E5 /* ProfileHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfileHeaderView.m; sourceTree = "<group>"; }; D049679C2834E1AB00FB81E5 /* ProfileHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfileHeaderView.m; sourceTree = "<group>"; };
D049886C286E9209000ACF55 /* TaskTimerTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TaskTimerTool.h; sourceTree = "<group>"; };
D049886D286E9209000ACF55 /* TaskTimerTool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TaskTimerTool.m; sourceTree = "<group>"; };
D0498872286E95F2000ACF55 /* DsTaskManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DsTaskManager.h; sourceTree = "<group>"; };
D0498873286E95F2000ACF55 /* DsTaskManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsTaskManager.m; sourceTree = "<group>"; };
D04B3D9727F6D4D90022F8DF /* LeadingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LeadingController.h; sourceTree = "<group>"; }; D04B3D9727F6D4D90022F8DF /* LeadingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LeadingController.h; sourceTree = "<group>"; };
D04B3D9827F6D4D90022F8DF /* LeadingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LeadingController.m; sourceTree = "<group>"; }; D04B3D9827F6D4D90022F8DF /* LeadingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LeadingController.m; sourceTree = "<group>"; };
D04B3DA927F6EEB40022F8DF /* DSTabBarController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSTabBarController.h; sourceTree = "<group>"; }; D04B3DA927F6EEB40022F8DF /* DSTabBarController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSTabBarController.h; sourceTree = "<group>"; };
...@@ -1115,6 +1121,10 @@ ...@@ -1115,6 +1121,10 @@
D0BE53732845B27E007F15B3 /* DailyTaskModel.m */, D0BE53732845B27E007F15B3 /* DailyTaskModel.m */,
D0BE536F2845AFD8007F15B3 /* NewTaskModel.h */, D0BE536F2845AFD8007F15B3 /* NewTaskModel.h */,
D0BE53702845AFD8007F15B3 /* NewTaskModel.m */, D0BE53702845AFD8007F15B3 /* NewTaskModel.m */,
D049886C286E9209000ACF55 /* TaskTimerTool.h */,
D049886D286E9209000ACF55 /* TaskTimerTool.m */,
D0498872286E95F2000ACF55 /* DsTaskManager.h */,
D0498873286E95F2000ACF55 /* DsTaskManager.m */,
); );
path = ScoreTaskAI; path = ScoreTaskAI;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2077,6 +2087,7 @@ ...@@ -2077,6 +2087,7 @@
D091E674283F5B4200D3279E /* ScoreDetailModel.m in Sources */, D091E674283F5B4200D3279E /* ScoreDetailModel.m in Sources */,
D01BD425282BFFB400BA86B3 /* WhiteNoiseRequestModel.m in Sources */, D01BD425282BFFB400BA86B3 /* WhiteNoiseRequestModel.m in Sources */,
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */, D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */,
D049886E286E9209000ACF55 /* TaskTimerTool.m in Sources */,
D091BBBB2809079600487A50 /* NSString+Extras.m in Sources */, D091BBBB2809079600487A50 /* NSString+Extras.m in Sources */,
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */, D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */,
D0C50B4227FD39C800DC68F0 /* UIViewController+FullScreenModal.m in Sources */, D0C50B4227FD39C800DC68F0 /* UIViewController+FullScreenModal.m in Sources */,
...@@ -2113,6 +2124,7 @@ ...@@ -2113,6 +2124,7 @@
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */, D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */,
D0C50B3C27FD2EFD00DC68F0 /* PrivacyViewController.m in Sources */, D0C50B3C27FD2EFD00DC68F0 /* PrivacyViewController.m in Sources */,
D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */, D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */,
D0498874286E95F2000ACF55 /* DsTaskManager.m in Sources */,
D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */, D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */,
D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */, D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */,
D0930F122801124E006B497A /* BaseNaviController.m in Sources */, D0930F122801124E006B497A /* BaseNaviController.m in Sources */,
......
...@@ -3,4 +3,22 @@ ...@@ -3,4 +3,22 @@
uuid = "B7FD559A-562B-4E26-9933-6F7E1817C3F7" uuid = "B7FD559A-562B-4E26-9933-6F7E1817C3F7"
type = "0" type = "0"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "AB571E92-11B2-4994-AF38-757E0BC9241C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DreamSleep/Class/ProfileModule/ScoreTaskAI/TaskTimerTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "52"
endingLineNumber = "52"
landmarkName = "-dealloc"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>
...@@ -43,4 +43,6 @@ ...@@ -43,4 +43,6 @@
#import "DataStatisticsUtil.h" #import "DataStatisticsUtil.h"
#import "DsTaskManager.h"
#endif /* PrefixHeader_pch */ #endif /* PrefixHeader_pch */
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
@property (nonatomic, assign) BOOL isDraging; @property (nonatomic, assign) BOOL isDraging;
/// streamState /// streamState
@property (nonatomic, assign) FSAudioStreamState streamState; @property (nonatomic, assign) FSAudioStreamState streamState;
@property (nonatomic, assign) NSInteger taskTimeCount;
@end @end
@implementation MusicPlayerController { @implementation MusicPlayerController {
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.taskTimeCount = 0;
[self launchPlayer]; [self launchPlayer];
WS(weakSelf); WS(weakSelf);
...@@ -256,6 +259,13 @@ ...@@ -256,6 +259,13 @@
// DSLog(@"缓存进度:%f, 总进度:%f", self.audioStream.prebufferedByteCount, self.audioStream.contentLength); // DSLog(@"缓存进度:%f, 总进度:%f", self.audioStream.prebufferedByteCount, self.audioStream.contentLength);
[self updatePlayingCenterInfo]; [self updatePlayingCenterInfo];
// 执行舒眠课程、助眠音乐任务
if (self.taskTimeCount/60 >= 30) {
self.taskTimeCount = 0;
[DsTaskManager excuteGeneralTaskWithType:TaskTypeDaily taskItem:self.courseType == CourseTypeSafe ? TaskItemSafe : TaskItemRelax];
}
self.taskTimeCount++;
} }
- (void)audioStreamPlaybackCompleted { - (void)audioStreamPlaybackCompleted {
...@@ -390,16 +400,6 @@ ...@@ -390,16 +400,6 @@
[self launchPlayer]; [self launchPlayer];
} }
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
#pragma mark - lazy #pragma mark - lazy
- (MusicPlayerView *)playerView { - (MusicPlayerView *)playerView {
if (!_playerView) { if (!_playerView) {
...@@ -420,4 +420,14 @@ ...@@ -420,4 +420,14 @@
return _audioStream; return _audioStream;
} }
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
@end @end
...@@ -38,9 +38,39 @@ ...@@ -38,9 +38,39 @@
@implementation HomeViewController @implementation HomeViewController
#pragma mark - life
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self buildInterface];
[self requestHomeData];
[self addObserver];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self getLatestDataRequest];
[self.homeTV.headerView controllerWillAppear];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.homeTV.headerView controllerWillDisAppear];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedPauseAllNoise object:nil];
#if DSRELEASE == 1
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
#endif
}
- (void)buildInterface {
// leftItem // leftItem
UILabel *leftLab = [UILabel dkLabWithText:@"小梦睡眠" font:BoldFont(24.0)]; UILabel *leftLab = [UILabel dkLabWithText:@"小梦睡眠" font:BoldFont(24.0)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftLab]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftLab];
...@@ -68,84 +98,9 @@ ...@@ -68,84 +98,9 @@
[self promotionAlert]; [self promotionAlert];
// APP首次启动弹框(只出现一次) // APP首次启动弹框(只出现一次)
[self showFirstLeadAlertView]; [self showFirstLeadAlertView];
[self requestHomeData];
// 监听主页需要刷新数据通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil];
// 监听需要暂停所有白噪音
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pauseAllNoise) name:NeedPauseAllNoise object:nil];
#if DSRELEASE == 1
// 设置初始值
self.update_Way = -1;
[self appWillEnterForeground];
// 监听APP回到前台通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
#endif
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([LoginUtils getUserLoginData]) {
// 自动登录请求(每次APP首页显示的时候调用)
[UserRequestModel autoLoginRequestWithCompletion:^(UserRequestModel * _Nonnull requestModel) {
// 自动登录失败,清除本地用户信息并且跳转到登录页面
if (requestModel.resCode == DSResCodeFail) {
[LoginUtils clearUserLoginData];
[LoginUtils jumpToLoginControllerWithTarget:self];
}
}];
}
[self.homeTV.headerView controllerWillAppear];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.homeTV.headerView controllerWillDisAppear];
}
- (void)pauseAllNoise {
[[NoisePlayerManager sharedNoisePlayerManager] pauseAll];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedUpdateHomePage object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NeedPauseAllNoise object:nil];
#if DSRELEASE == 1
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
#endif
} }
#pragma mark - 先放大,再缩小 // banner、舒眠课程、助眠音乐、白噪音类型数据获取
- (void)addScaleAnimtaionWithView:(UIView *)view {
// 放大效果,并回到原位
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// 速度控制函数,控制动画运行的节奏
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// 执行时间
animation.duration = 0.2;
// 执行次数
animation.repeatCount = 1;
// 完成动画后会回到执行动画之前的状态
animation.autoreverses = YES;
// 初始伸缩倍数
animation.fromValue = [NSNumber numberWithFloat:0.9];
// 结束伸缩倍数
animation.toValue = [NSNumber numberWithFloat:1.1];
[view.layer addAnimation:animation forKey:nil];
}
- (void)needUpdate {
[self.homeTV.mj_header beginRefreshing];
}
#pragma mark - banner、舒眠课程、助眠音乐数据获取
- (void)requestHomeData { - (void)requestHomeData {
WS(weakSelf); WS(weakSelf);
self.homeTV.mj_header = [DSGifHeader headerWithRefreshingBlock:^{ self.homeTV.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
...@@ -233,6 +188,39 @@ ...@@ -233,6 +188,39 @@
}); });
} }
- (void)addObserver {
// 监听主页需要刷新数据通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needUpdate) name:NeedUpdateHomePage object:nil];
// 监听需要暂停所有白噪音
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pauseAllNoise) name:NeedPauseAllNoise object:nil];
#if DSRELEASE == 1
// 设置初始值
self.update_Way = -1;
[self appWillEnterForeground];
// 监听APP回到前台通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
#endif
}
#pragma mark - 获取最新数据请求
- (void)getLatestDataRequest {
if ([LoginUtils getUserLoginData]) {
// 自动登录请求(每次APP首页显示的时候调用)
[UserRequestModel autoLoginRequestWithCompletion:^(UserRequestModel * _Nonnull requestModel) {
// 自动登录失败,清除本地用户信息并且跳转到登录页面
if (requestModel.resCode == DSResCodeFail) {
[LoginUtils clearUserLoginData];
[LoginUtils jumpToLoginControllerWithTarget:self];
}
}];
// 获取任务列表数据
[DsTaskManager getTaskListData];
}
}
#pragma mark - APP首次启动弹框 #pragma mark - APP首次启动弹框
- (void)showFirstLeadAlertView { - (void)showFirstLeadAlertView {
if (kGetUserDefaultsBOOL(IsFirstAlert)) { return; } if (kGetUserDefaultsBOOL(IsFirstAlert)) { return; }
...@@ -248,7 +236,7 @@ ...@@ -248,7 +236,7 @@
[view show]; [view show];
} }
#pragma mark - 运营活动相关 #pragma mark - 运营活动弹框
- (void)promotionAlert { - (void)promotionAlert {
if (kGetUserDefaultsBOOL(IsFirstAlert) == NO) { if (kGetUserDefaultsBOOL(IsFirstAlert) == NO) {
return; return;
...@@ -334,7 +322,16 @@ ...@@ -334,7 +322,16 @@
} }
} }
#pragma mark - APP升级相关 #pragma mark - 通知处理
- (void)needUpdate {
[self.homeTV.mj_header beginRefreshing];
}
- (void)pauseAllNoise {
[[NoisePlayerManager sharedNoisePlayerManager] pauseAll];
}
// APP升级相关
- (void)appWillEnterForeground { - (void)appWillEnterForeground {
// 已经是最新版本 // 已经是最新版本
if (self.update_Way == 2) { return; } if (self.update_Way == 2) { return; }
...@@ -417,4 +414,24 @@ ...@@ -417,4 +414,24 @@
return _updateBox; return _updateBox;
} }
#pragma mark - others
// 先放大,再缩小
- (void)addScaleAnimtaionWithView:(UIView *)view {
// 放大效果,并回到原位
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// 速度控制函数,控制动画运行的节奏
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// 执行时间
animation.duration = 0.2;
// 执行次数
animation.repeatCount = 1;
// 完成动画后会回到执行动画之前的状态
animation.autoreverses = YES;
// 初始伸缩倍数
animation.fromValue = [NSNumber numberWithFloat:0.9];
// 结束伸缩倍数
animation.toValue = [NSNumber numberWithFloat:1.1];
[view.layer addAnimation:animation forKey:nil];
}
@end @end
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#elif TARGET_OS_IPHONE #elif TARGET_OS_IPHONE
#import <UnityFramework/UnityFramework.h> #import <UnityFramework/UnityFramework.h>
@interface UnityGameController () <UnityFrameworkListener> @interface UnityGameController () <UnityFrameworkListener>
@property (nonatomic, strong) UnityFramework* ufw; @property (nonatomic, strong) UnityFramework *ufw;
@end @end
@implementation UnityGameController @implementation UnityGameController
...@@ -41,6 +41,26 @@ ...@@ -41,6 +41,26 @@
[self showUnityView:self.gameType]; [self showUnityView:self.gameType];
[self addObsever];
if (self.gameType == GameTypeCoax) {
// 哄睡任务
[DsTaskManager excuteTimeTaskWithType:TaskTypeDaily taskItem:TaskItemCoax];
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}
#pragma mark - 通知相关
- (void)addObsever {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitCoaxSleep) name:ExitCoaxSleep object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitCoaxSleep) name:ExitCoaxSleep object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
...@@ -67,26 +87,8 @@ ...@@ -67,26 +87,8 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:ExitCoaxSleep object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:ExitCoaxSleep object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
}
[DsTaskManager resetTaskTimerTool];
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 隐藏状态栏
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
} }
#pragma mark - Unity #pragma mark - Unity
...@@ -136,6 +138,17 @@ extern char** gArgv; ...@@ -136,6 +138,17 @@ extern char** gArgv;
[self setUfw: nil]; [self setUfw: nil];
[DSDelegateWindow makeKeyAndVisible]; [DSDelegateWindow makeKeyAndVisible];
} }
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 隐藏状态栏
- (BOOL)prefersStatusBarHidden {
return YES;
}
@end @end
#endif #endif
...@@ -94,6 +94,9 @@ ...@@ -94,6 +94,9 @@
[[NoisePlayerManager sharedNoisePlayerManager] addNoiseAudioCell:cell]; [[NoisePlayerManager sharedNoisePlayerManager] addNoiseAudioCell:cell];
[DataStatisticsUtil event:White_Noise_Click attributes:@{@"typeName":self.sub_name, @"audioName":model.audio_name}]; [DataStatisticsUtil event:White_Noise_Click attributes:@{@"typeName":self.sub_name, @"audioName":model.audio_name}];
// 执行白噪音点击任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeDaily taskItem:TaskItemGood];
} else { } else {
cell.playItem = nil; cell.playItem = nil;
[[NoisePlayerManager sharedNoisePlayerManager] removeNoiseAudioCell:cell]; [[NoisePlayerManager sharedNoisePlayerManager] removeNoiseAudioCell:cell];
......
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
[DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改昵称"}]; [DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改昵称"}];
// 执行修改昵称任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeNew taskItem:TaskItemNick];
} }
}]; }];
} }
......
...@@ -160,6 +160,9 @@ ...@@ -160,6 +160,9 @@
[weakSelf reloadData]; [weakSelf reloadData];
[DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改生日"}]; [DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改生日"}];
// 执行完善生日任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeNew taskItem:TaskItemBirth];
} }
}]; }];
}]; }];
...@@ -183,6 +186,9 @@ ...@@ -183,6 +186,9 @@
[weakSelf reloadData]; [weakSelf reloadData];
[DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改性别"}]; [DataStatisticsUtil event:User_Info attributes:@{@"name":@"修改性别"}];
// 执行修改性别任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeNew taskItem:TaskItemSex];
} }
}]; }];
} }
......
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
[self.ds_viewController dismissViewControllerAnimated:YES completion:nil]; [self.ds_viewController dismissViewControllerAnimated:YES completion:nil];
[DataStatisticsUtil event:User_Info attributes:@{@"name":@"更换头像"}]; [DataStatisticsUtil event:User_Info attributes:@{@"name":@"更换头像"}];
// 执行上传用户头像任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeNew taskItem:TaskItemUpload];
} }
}]; }];
} }
......
...@@ -112,6 +112,11 @@ static int AlbumColumnCount = 4; ...@@ -112,6 +112,11 @@ static int AlbumColumnCount = 4;
[DSProgressHUD showDetailInfo:@"请输入遇到的问题或建议"]; [DSProgressHUD showDetailInfo:@"请输入遇到的问题或建议"];
return; return;
} }
if (self.feedTV.text.length < 5) {
[DSProgressHUD showDetailInfo:@"内容不能少于5个字"];
return;
}
// 发送提交请求 // 发送提交请求
[DSProgressHUD showProgressHUDWithInfo:@"提交中..."]; [DSProgressHUD showProgressHUDWithInfo:@"提交中..."];
_result_imgurls = _result_imgurls ? _result_imgurls : @""; _result_imgurls = _result_imgurls ? _result_imgurls : @"";
...@@ -123,6 +128,9 @@ static int AlbumColumnCount = 4; ...@@ -123,6 +128,9 @@ static int AlbumColumnCount = 4;
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
[DataStatisticsUtil event:SuggestFeedback attributes:@{@"name":@"提交反馈意见"}]; [DataStatisticsUtil event:SuggestFeedback attributes:@{@"name":@"提交反馈意见"}];
// 执行意见反馈任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeDaily taskItem:TaskItemFeedback];
} }
}]; }];
} }
......
...@@ -125,6 +125,9 @@ ...@@ -125,6 +125,9 @@
} }
UMSocialLogInfo(@"************Share fail with error %@*********", error); UMSocialLogInfo(@"************Share fail with error %@*********", error);
} else { } else {
// 执行邀请好友任务
[DsTaskManager excuteGeneralTaskWithType:TaskTypeDaily taskItem:TaskItemInvite];
if ([data isKindOfClass:[UMSocialShareResponse class]]) { if ([data isKindOfClass:[UMSocialShareResponse class]]) {
UMSocialShareResponse *resp = data; UMSocialShareResponse *resp = data;
// 分享结果消息 // 分享结果消息
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
}]; }];
[self.todayLab mas_makeConstraints:^(MASConstraintMaker *make) { [self.todayLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.pointsLab.mas_right).offset(2); make.left.equalTo(self.pointsLab.mas_right).offset(2);
make.bottom.equalTo(self.pointsLab).offset(-8); make.bottom.equalTo(self.pointsLab).offset(-9);
}]; }];
// 积分需要动画显示效果 // 积分需要动画显示效果
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
[ScoreTaskRequestModel queryUserDailyTaskListWithCompletion:^(ScoreTaskRequestModel * _Nonnull requestModel) { [ScoreTaskRequestModel queryUserDailyTaskListWithCompletion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
[self.dailyTaskView updateTaskView:requestModel]; [self.dailyTaskView updateTaskView:requestModel];
[DsTaskManager sharedDsTaskManager].taskRequestModel = requestModel;
} }
}]; }];
} }
...@@ -100,11 +101,8 @@ ...@@ -100,11 +101,8 @@
if ([[UIApplication sharedApplication] canOpenURL:url]) { if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) { if (success) {
[ScoreTaskRequestModel updateUserDailyTaskStatusWithTaskID:task_id completion:^(ScoreTaskRequestModel * _Nonnull requestModel) { // 执行夸夸小梦任务
if (requestModel.resCode == DSResCodeSuccess) { [DsTaskManager excuteGeneralTaskWithType:TaskTypeDaily taskItem:TaskItemStore];
}
}];
} }
}]; }];
} }
...@@ -160,7 +158,6 @@ ...@@ -160,7 +158,6 @@
- (DailyTaskView *)dailyTaskView { - (DailyTaskView *)dailyTaskView {
if (!_dailyTaskView) { if (!_dailyTaskView) {
_dailyTaskView = [[DailyTaskView alloc] initWithDelegate:self]; _dailyTaskView = [[DailyTaskView alloc] initWithDelegate:self];
[_dailyTaskView debugViewShowBorder];
} }
return _dailyTaskView; return _dailyTaskView;
} }
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section == self.taskListArr.count - 1) { if (section == self.taskListArr.count - 1) {
return (24 + Bottom_SafeArea_Height); return iPhoneX ? 0.001 : 24;
} else { } else {
return 0.001; return 0.001;
} }
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
} }
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
CGFloat h = (section == self.taskListArr.count - 1) ? (24 + Bottom_SafeArea_Height) : 0.001; CGFloat h = (section == self.taskListArr.count - 1) ? (iPhoneX ? 0.001 : 24) : 0.001;
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)]; return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, h)];
} }
...@@ -227,7 +227,11 @@ ...@@ -227,7 +227,11 @@
- (SignTaskView *)signTaskView { - (SignTaskView *)signTaskView {
if (!_signTaskView) { if (!_signTaskView) {
WS(weakSelf);
_signTaskView = [[SignTaskView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 30, 186)]; _signTaskView = [[SignTaskView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 30, 186)];
_signTaskView.signSuccessBlock = ^(int date_points) {
[weakSelf.dailyBgView updateTodayPointData:date_points];
};
} }
return _signTaskView; return _signTaskView;
} }
......
//
// DsTaskManager.h
// DreamSleep
//
// Created by peter on 2022/7/1.
//
#import <Foundation/Foundation.h>
#import "ScoreTaskRequestModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 分组任务类型(大类)
typedef NS_ENUM(NSInteger, TaskType) {
TaskTypeDaily = 1, // 每日任务
TaskTypeNew = 2 // 新手任务
};
/// 任务项类型(小类)
typedef NS_ENUM(int, TaskItem) {
TaskItemCoach = 1, // AI睡眠教练
TaskItemCoax = 2, // 哄睡
TaskItemRelax = 3, // 助眠音乐
TaskItemSafe = 4, // 舒眠课程
TaskItemGood = 5, // 好眠声音
TaskItemInvite = 6, // 邀请好友
TaskItemStore = 7, // 夸夸小梦
TaskItemFeedback = 8, // 意见反馈
TaskItemUpload = 9, // 上传头像
TaskItemNick = 10, // 修改昵称
TaskItemSex = 11, // 选择性别
TaskItemBirth = 12, // 完善生日
TaskItemDaily = 13 // 完成每日一题
};
/// 任务管理者
@interface DsTaskManager : NSObject
SingletonH(DsTaskManager)
@property (nonatomic, strong) ScoreTaskRequestModel *taskRequestModel;
/// 获取任务列表数据
+ (void)getTaskListData;
/// 执行定时任务(哄睡定时)
+ (void)excuteTimeTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem;
/// 重置定时任务工具(在页面dealloc调用)
+ (void)resetTaskTimerTool;
/// 通用执行任务方法
+ (void)excuteGeneralTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem;
@end
NS_ASSUME_NONNULL_END
//
// DsTaskManager.m
// DreamSleep
//
// Created by peter on 2022/7/1.
//
#import "DsTaskManager.h"
#import "DailyTaskModel.h"
#import "NewTaskModel.h"
#import "TaskTimerTool.h"
@interface DsTaskManager ()
@property (nonatomic, strong) TaskTimerTool *taskTimerTool;
@property (nonatomic, assign) TaskType taskType;
@property (nonatomic, assign) TaskItem taskItem;
@property (nonatomic, assign) NSInteger taskTimeCount;
@end
@implementation DsTaskManager
SingletonM(DsTaskManager)
- (void)setTaskRequestModel:(ScoreTaskRequestModel *)taskRequestModel {
_taskRequestModel = taskRequestModel;
for (DailyTaskModel *dModel in taskRequestModel.task_items) {
if (dModel.task_id == TaskItemCoax) {
DSLog(@"dModel444:%@", dModel.yy_modelDescription);
}
}
}
#pragma mark - public
+ (void)getTaskListData {
[ScoreTaskRequestModel queryUserDailyTaskListWithCompletion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[DsTaskManager sharedDsTaskManager].taskRequestModel = requestModel;
}
}];
}
+ (void)excuteTimeTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem {
// 1、判断任务是否完成
if ([self taskHasFinishedWithType:taskType taskItem:taskItem]) { return; }
// 2、配置任务参数
DsTaskManager *taskManager = [DsTaskManager sharedDsTaskManager];
// 任务时长根据任务项取值
taskManager.taskTimeCount = 30;
taskManager.taskType = taskType;
taskManager.taskItem = taskItem;
// 3、开启定时任务
taskManager.taskTimerTool.taskTimeCount = taskManager.taskTimeCount;
[taskManager.taskTimerTool excuteTask];
}
+ (void)resetTaskTimerTool {
TaskTimerTool *taskTimerTool = [DsTaskManager sharedDsTaskManager].taskTimerTool;
if (taskTimerTool) {
[taskTimerTool reset];
}
}
+ (void)excuteGeneralTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem {
// 1、判断任务是否完成
if ([self taskHasFinishedWithType:taskType taskItem:taskItem]) { return; }
// 2、更新任务状态
[DsTaskManager updateTaskWithType:taskType taskItem:taskItem];
}
#pragma mark - 是否有任务列表数据
+ (BOOL)hasTaskListData {
return [DsTaskManager sharedDsTaskManager].taskRequestModel;
}
#pragma mark - 任务是否完成(YES:完成了则不需要发送更新任务状态请求,NO:未完成需要更新)
+ (BOOL)taskHasFinishedWithType:(TaskType)taskType taskItem:(TaskItem)taskItem {
if (![self hasTaskListData]) {
return NO;
}
__block BOOL isFinish = NO;
ScoreTaskRequestModel *taskRequestModel = [DsTaskManager sharedDsTaskManager].taskRequestModel;
if (taskType == TaskTypeDaily) {
[taskRequestModel.task_items enumerateObjectsUsingBlock:^(DailyTaskModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.task_id == taskItem) {
*stop = YES;
isFinish = !(obj.state == 0);
}
}];
} else if (taskType == TaskTypeNew) {
[taskRequestModel.task_news enumerateObjectsUsingBlock:^(NewTaskModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.task_id == taskItem) {
*stop = YES;
isFinish = !(obj.state == 0);
}
}];
}
for (DailyTaskModel *dModel in taskRequestModel.task_items) {
if (dModel.task_id == TaskItemCoax) {
DSLog(@"dModel222:%@", dModel.yy_modelDescription);
}
}
return isFinish;
}
// 白噪音点击成功次数
static int _noiseSuccessCount = 0;
#pragma mark - 更新任务状态
+ (void)updateTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem {
if (taskType == TaskTypeDaily) {
[ScoreTaskRequestModel updateUserDailyTaskStatusWithTaskID:taskItem completion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
if (taskItem == TaskItemGood) { // 白噪音成功5次才算完成
if (_noiseSuccessCount >= 5) {
_noiseSuccessCount = 0;
[self markTaskWithType:taskType taskItem:taskItem state:1];
}
_noiseSuccessCount++;
} else {
[self markTaskWithType:taskType taskItem:taskItem state:1];
}
}
}];
} else if (taskType == TaskTypeNew) {
[ScoreTaskRequestModel updateUserNewsTaskStateWithTaskID:taskItem completion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self markTaskWithType:taskType taskItem:taskItem state:1];
}
}];
}
}
#pragma mark - 标记本地任务列表中任务状态
+ (void)markTaskWithType:(TaskType)taskType taskItem:(TaskItem)taskItem state:(int)state {
if (![self hasTaskListData]) {
return;
}
ScoreTaskRequestModel *taskRequestModel = [DsTaskManager sharedDsTaskManager].taskRequestModel;
if (taskType == TaskTypeDaily) {
[taskRequestModel.task_items enumerateObjectsUsingBlock:^(DailyTaskModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.task_id == taskItem) {
*stop = YES;
obj.state = state;
}
}];
} else if (taskType == TaskTypeNew) {
[taskRequestModel.task_news enumerateObjectsUsingBlock:^(NewTaskModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.task_id == taskItem) {
*stop = YES;
obj.state = state;
}
}];
}
for (DailyTaskModel *dModel in taskRequestModel.task_items) {
if (dModel.task_id == TaskItemCoax) {
DSLog(@"dModel333:%@", dModel.yy_modelDescription);
}
}
}
#pragma mark - lazy
- (TaskTimerTool *)taskTimerTool {
if (!_taskTimerTool) {
_taskTimerTool = [[TaskTimerTool alloc] initWithBlock:^{
// 4、更新任务状态
[DsTaskManager updateTaskWithType:[DsTaskManager sharedDsTaskManager].taskType taskItem:[DsTaskManager sharedDsTaskManager].taskItem];
}];
}
return _taskTimerTool;
}
@end
...@@ -62,11 +62,7 @@ ...@@ -62,11 +62,7 @@
- (void)refreshSignView:(ScoreTaskRequestModel *)requestModel indexPath:(NSIndexPath *)indexPath { - (void)refreshSignView:(ScoreTaskRequestModel *)requestModel indexPath:(NSIndexPath *)indexPath {
SignModel *signModel = requestModel.signList[indexPath.row]; SignModel *signModel = requestModel.signList[indexPath.row];
BOOL is_cur_day = requestModel.cur_day == signModel.day; BOOL is_cur_day = requestModel.cur_day == signModel.day;
// 背景小圆背景颜色显示
DKColorPicker day_dk_bg_color = is_cur_day ? DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xB5552E), DSWhite) : DKColorPickerWithColors(ColorFromHexA(0xFC7032, .1), ColorFromHexA(0xFC7032, .1), DSWhite);
self.dayView.dk_backgroundColorPicker = day_dk_bg_color;
// 礼物图标显示 // 礼物图标显示
if (signModel.state == 0) { // 未签到 if (signModel.state == 0) { // 未签到
if (signModel.day == 3) { // 小礼物 if (signModel.day == 3) { // 小礼物
...@@ -82,19 +78,16 @@ ...@@ -82,19 +78,16 @@
self.giftIV.hidden = YES; self.giftIV.hidden = YES;
} }
// 动画效果 // 动画效果
if (signModel.state == 0 && (requestModel.cur_day == 3 || requestModel.cur_day == 7)) { if (signModel.state == 0 && (requestModel.cur_day == 3 || requestModel.cur_day == 7) && signModel.day == 3) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; [self showAnimation];
animation.duration = 2.0;
animation.repeatCount = HUGE_VALF;
animation.autoreverses = YES;
animation.removedOnCompletion = NO;
animation.fromValue = [NSNumber numberWithFloat:1.2];
animation.toValue = [NSNumber numberWithFloat:.8];
[self.giftIV.layer addAnimation:animation forKey:@"scale-layer"];
} else { } else {
[self.giftIV.layer removeAllAnimations]; [self.giftIV.layer removeAllAnimations];
} }
// 背景小圆背景颜色显示
DKColorPicker day_dk_bg_color = (is_cur_day && self.giftIV.hidden) ? DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xB5552E), DSWhite) : DKColorPickerWithColors(ColorFromHexA(0xFC7032, .1), ColorFromHexA(0xFC7032, .1), DSWhite);
self.dayView.dk_backgroundColorPicker = day_dk_bg_color;
// 积分显示 // 积分显示
if (signModel.state == 0 && (signModel.day == 3 || signModel.day == 7)) { if (signModel.state == 0 && (signModel.day == 3 || signModel.day == 7)) {
self.scoreLab.hidden = YES; self.scoreLab.hidden = YES;
...@@ -149,6 +142,17 @@ ...@@ -149,6 +142,17 @@
self.smallDot.dk_backgroundColorPicker = small_dk_bg_color; self.smallDot.dk_backgroundColorPicker = small_dk_bg_color;
} }
- (void)showAnimation {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.duration = 2.0;
animation.repeatCount = HUGE_VALF;
animation.autoreverses = YES;
animation.removedOnCompletion = NO;
animation.fromValue = [NSNumber numberWithFloat:1.2];
animation.toValue = [NSNumber numberWithFloat:.8];
[self.giftIV.layer addAnimation:animation forKey:@"scale-layer"];
}
#pragma mark - lazy #pragma mark - lazy
- (UIView *)dayView { - (UIView *)dayView {
if (!_dayView) { if (!_dayView) {
......
...@@ -10,9 +10,14 @@ ...@@ -10,9 +10,14 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 签到成功block
typedef void (^SignSuccessBlock)(int date_points);
/// 签到任务视图 /// 签到任务视图
@interface SignTaskView : UIView @interface SignTaskView : UIView
@property (nonatomic, copy) SignSuccessBlock signSuccessBlock;
- (void)updateSignView:(ScoreTaskRequestModel *)requestModel; - (void)updateSignView:(ScoreTaskRequestModel *)requestModel;
@end @end
......
...@@ -42,6 +42,15 @@ ...@@ -42,6 +42,15 @@
make.centerX.equalTo(self); make.centerX.equalTo(self);
make.bottom.equalTo(self).offset(-15); make.bottom.equalTo(self).offset(-15);
}]; }];
[self.signBtn layoutIfNeeded];
UIView *tmpV = [self.signBtn genGradientWithStart:CGPointMake(0, 0.5) end:CGPointMake(1, 0.5) colors:@[(__bridge id)ColorFromHex(0xFEA961).CGColor, (__bridge id)ColorFromHex(0xFC7032).CGColor] locations:@[@(0), @(1.0f)]];
UIImage *bgImg = [tmpV snapshotImage];
UIView *dktmpV = [self.signBtn genGradientWithStart:CGPointMake(0, 0.5) end:CGPointMake(1, 0.5) colors:@[(__bridge id)ColorFromHex(0xB77C4E).CGColor, (__bridge id)ColorFromHex(0xB5552E).CGColor] locations:@[@(0), @(1.0f)]];
UIImage *dkbgImg = [dktmpV snapshotImage];
[self.signBtn dk_setBackgroundImage:DKImagePickerWithImages(bgImg, dkbgImg, bgImg) forState:UIControlStateNormal];
} }
return self; return self;
} }
...@@ -50,6 +59,9 @@ ...@@ -50,6 +59,9 @@
[ScoreTaskRequestModel receiveUserDailySignPointWithCurDay:self.requestModel.cur_day completion:^(ScoreTaskRequestModel * _Nonnull requestModel) { [ScoreTaskRequestModel receiveUserDailySignPointWithCurDay:self.requestModel.cur_day completion:^(ScoreTaskRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
// 回调数据到DailyTaskView // 回调数据到DailyTaskView
if (self.signSuccessBlock) {
self.signSuccessBlock(requestModel.date_points);
}
// 更新按钮状态 // 更新按钮状态
[self.signBtn setTitle:@"已签到" forState:UIControlStateNormal]; [self.signBtn setTitle:@"已签到" forState:UIControlStateNormal];
...@@ -122,7 +134,6 @@ ...@@ -122,7 +134,6 @@
_signBtn = [UIButton btnWithTitle:@"签到领积分" font:BoldFont(16)]; _signBtn = [UIButton btnWithTitle:@"签到领积分" font:BoldFont(16)];
_signBtn.userInteractionEnabled = NO; _signBtn.userInteractionEnabled = NO;
[_signBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal]; [_signBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_signBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(ColorFromHex(0xFEA961), ColorFromHex(0xB77C4E), DSWhite)];
[_signBtn addTarget:self action:@selector(signAction) forControlEvents:UIControlEventTouchUpInside]; [_signBtn addTarget:self action:@selector(signAction) forControlEvents:UIControlEventTouchUpInside];
[_signBtn cornerRadius:20]; [_signBtn cornerRadius:20];
} }
......
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, TaskType) {
TaskTypeDaily, // 每日任务
TaskTypeNew, // 新手任务
};
/// 每日任务和新手任务组数据 /// 每日任务和新手任务组数据
@interface TaskGroupModel : NSObject @interface TaskGroupModel : NSObject
@property (nonatomic, assign) TaskType taskType; @property (nonatomic, assign) TaskType taskType;
......
//
// TaskTimerTool.h
// DreamSleep
//
// Created by peter on 2022/7/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^TaskTimeFinishedBlock)(void);
/// 定时任务完成代理
@protocol TaskTimerToolDelegate <NSObject>
// 任务时长到了
- (void)taskTimerHasFinished;
@end
/// 任务完成时长工具类
@interface TaskTimerTool : NSObject
/// 任务时长
@property (nonatomic, assign) NSInteger taskTimeCount;
/// 代理
@property (nonatomic, weak) id<TaskTimerToolDelegate> delegate;
/// block
@property (nonatomic, copy) TaskTimeFinishedBlock taskTimeFinishedBlock;
- (instancetype)initWithTaskTimeCount:(NSInteger)taskTimeCount delegate:(id<TaskTimerToolDelegate>)delegate;
- (instancetype)initWithBlock:(TaskTimeFinishedBlock)block;
- (void)excuteTask;
- (void)stopTask;
- (void)reset;
@end
NS_ASSUME_NONNULL_END
//
// TaskTimerTool.m
// DreamSleep
//
// Created by peter on 2022/7/1.
//
#import "TaskTimerTool.h"
@interface TaskTimerTool ()
/// 当前时长
@property (nonatomic, assign) NSInteger curTimeCount;
/// 任务定时器
@property (nonatomic, strong) NSTimer *taskTimer;
@end
@implementation TaskTimerTool
- (instancetype)initWithTaskTimeCount:(NSInteger)taskTimeCount delegate:(id<TaskTimerToolDelegate>)delegate {
if (self = [super init]) {
self.curTimeCount = 0;
self.taskTimeCount = taskTimeCount;
self.delegate = delegate;
}
return self;
}
- (instancetype)initWithBlock:(TaskTimeFinishedBlock)block {
if (self = [super init]) {
self.curTimeCount = 0;
self.taskTimeFinishedBlock = block;
}
return self;
}
- (void)excuteTask {
[self.taskTimer setFireDate:[NSDate date]];
}
- (void)stopTask {
[self.taskTimer setFireDate:[NSDate distantFuture]];
[_taskTimer invalidate];
_taskTimer = nil;
}
- (void)reset {
[self.taskTimer setFireDate:[NSDate distantFuture]];
self.curTimeCount = 0;
}
- (void)dealloc {
[_taskTimer invalidate];
_taskTimer = nil;
}
#pragma mark - lazy
- (NSTimer *)taskTimer {
if (!_taskTimer) {
WS(weakSelf);
_taskTimer = [NSTimer timerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
DSLog(@"self.curTimeCount:%ld", self.curTimeCount);
// 标记完成任务
if (weakSelf.curTimeCount >= self.taskTimeCount) {
[weakSelf.taskTimer setFireDate:[NSDate distantFuture]];
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(taskTimerHasFinished)]) {
[weakSelf.delegate taskTimerHasFinished];
}
if (weakSelf.taskTimeFinishedBlock) {
weakSelf.taskTimeFinishedBlock();
}
return;
}
weakSelf.curTimeCount++;
}];
[[NSRunLoop currentRunLoop] addTimer:_taskTimer forMode:NSRunLoopCommonModes];
}
[_taskTimer setFireDate:[NSDate distantFuture]];
return _taskTimer;
}
@end
...@@ -12,22 +12,22 @@ ...@@ -12,22 +12,22 @@
<key>DKNightVersion.xcscheme_^#shared#^_</key> <key>DKNightVersion.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>15</integer> <integer>5</integer>
</dict> </dict>
<key>DOUAudioStreamer.xcscheme_^#shared#^_</key> <key>DOUAudioStreamer.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>6</integer>
</dict> </dict>
<key>FreeStreamer.xcscheme_^#shared#^_</key> <key>FreeStreamer.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>8</integer> <integer>14</integer>
</dict> </dict>
<key>IQKeyboardManager.xcscheme_^#shared#^_</key> <key>IQKeyboardManager.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>16</integer> <integer>8</integer>
</dict> </dict>
<key>MBProgressHUD.xcscheme_^#shared#^_</key> <key>MBProgressHUD.xcscheme_^#shared#^_</key>
<dict> <dict>
...@@ -37,47 +37,47 @@ ...@@ -37,47 +37,47 @@
<key>MJRefresh.xcscheme_^#shared#^_</key> <key>MJRefresh.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>12</integer> <integer>19</integer>
</dict> </dict>
<key>Masonry.xcscheme_^#shared#^_</key> <key>Masonry.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>17</integer> <integer>7</integer>
</dict> </dict>
<key>Pods-DreamSleep.xcscheme_^#shared#^_</key> <key>Pods-DreamSleep.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>16</integer>
</dict> </dict>
<key>Reachability.xcscheme_^#shared#^_</key> <key>Reachability.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>10</integer>
</dict> </dict>
<key>YYCache.xcscheme_^#shared#^_</key> <key>YYCache.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>14</integer> <integer>18</integer>
</dict> </dict>
<key>YYImage.xcscheme_^#shared#^_</key> <key>YYImage.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>12</integer>
</dict> </dict>
<key>YYModel.xcscheme_^#shared#^_</key> <key>YYModel.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>19</integer> <integer>17</integer>
</dict> </dict>
<key>YYWebImage.xcscheme_^#shared#^_</key> <key>YYWebImage.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>18</integer> <integer>15</integer>
</dict> </dict>
<key>lottie-ios.xcscheme_^#shared#^_</key> <key>lottie-ios.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>4</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!