Commit f86335be cgx

优化登录模块(登录成功回调)

1 个父辈 c848f239
......@@ -157,6 +157,7 @@
D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F8090328042A0B0097899F /* SafeSleepCell.m */; };
D0F80907280431100097899F /* UILabel+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F80906280431100097899F /* UILabel+Extras.m */; };
D0F82286280C44D10039F586 /* SetTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F82285280C44D10039F586 /* SetTableView.m */; };
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F9AC532826563400FD7A3B /* MusicPlayerController.m */; };
D0FAC41C281B817D00D4B859 /* GKLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC406281B817D00D4B859 /* GKLoadingView.m */; };
D0FAC41D281B817D00D4B859 /* GKPhotoBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC40C281B817D00D4B859 /* GKPhotoBrowser.m */; };
D0FAC41E281B817D00D4B859 /* GKPhotoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FAC40F281B817D00D4B859 /* GKPhotoManager.m */; };
......@@ -460,6 +461,8 @@
D0F80906280431100097899F /* UILabel+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Extras.m"; sourceTree = "<group>"; };
D0F82284280C44D10039F586 /* SetTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SetTableView.h; sourceTree = "<group>"; };
D0F82285280C44D10039F586 /* SetTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SetTableView.m; sourceTree = "<group>"; };
D0F9AC522826563400FD7A3B /* MusicPlayerController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MusicPlayerController.h; sourceTree = "<group>"; };
D0F9AC532826563400FD7A3B /* MusicPlayerController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MusicPlayerController.m; sourceTree = "<group>"; };
D0FAC406281B817D00D4B859 /* GKLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKLoadingView.m; sourceTree = "<group>"; };
D0FAC407281B817D00D4B859 /* GKWebImageProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKWebImageProtocol.h; sourceTree = "<group>"; };
D0FAC408281B817D00D4B859 /* GKPhotoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKPhotoManager.h; sourceTree = "<group>"; };
......@@ -1049,6 +1052,8 @@
D055BEC728252D8200BC11A4 /* AudioCourseCell.m */,
D055BEC928252E4000BC11A4 /* SubAudioModel.h */,
D055BECA28252E4000BC11A4 /* SubAudioModel.m */,
D0F9AC522826563400FD7A3B /* MusicPlayerController.h */,
D0F9AC532826563400FD7A3B /* MusicPlayerController.m */,
);
path = Home;
sourceTree = "<group>";
......@@ -1480,6 +1485,7 @@
D08F79E0281A1838000D99DD /* TZImagePickerController.m in Sources */,
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */,
D0AEFE812817DD1500230DC6 /* MyFeedCell.m in Sources */,
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */,
D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */,
D0874BBF2816E61000CECB3C /* RescuePlanView.m in Sources */,
D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */,
......
......@@ -101,8 +101,6 @@
self.pleyerBtn = [UIButton new];
[self.bigView addSubview:self.pleyerBtn];
[self.pleyerBtn addTarget:self action:@selector(playerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.pleyerBtn dk_setImage:DKImagePickerWithNames(@"ic_list_play_normal", @"dk_ic_list_play_normal", @"dk_ic_list_play_normal") forState:UIControlStateNormal];
[self.pleyerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.bigView.mas_right).offset(-15);
make.width.equalTo(@40);
......@@ -130,11 +128,18 @@
self.numberLb.text = [NSString stringWithFormat:@"%ld", indexPath.row + 1];
self.timeLb.text = model.play_time;
self.titleLb.text = model.audio_name;
UIColor *normalTitleColor = model.is_lock == 1 ? ColorFromHex(0x848484) : MainTextColor;
self.titleLb.dk_textColorPicker = DKColorPickerWithColors(normalTitleColor, ColorFromHex(0xE8E9E9), DSWhite);
if (model.is_lock == 0 && indexPath.row == 0) {
self.pleyerBtn.hidden = YES;
self.tryLab.hidden = NO;
UIColor *darkTitleColor = model.is_lock == 1 ? ColorFromHex(0xBBBBBB) : ColorFromHex(0xE8E9E9);
NSString *normalImgName = model.is_lock == 1 ? @"dk_ic_list_play_normal" : @"ic_list_play_normal";
NSString *darkImgName = model.is_lock == 1 ? @"dk_ic_list_play_normal" : @"dk_ic_list_play_normal_unlock";
self.titleLb.dk_textColorPicker = DKColorPickerWithColors(normalTitleColor, darkTitleColor, DSWhite);
[self.pleyerBtn dk_setImage:DKImagePickerWithNames(normalImgName, darkImgName, @"dk_ic_list_play_normal") forState:UIControlStateNormal];
// 音频未🔒
if (model.is_lock == 0) {
self.tryLab.hidden = [LoginUtils getUserLoginData];
self.pleyerBtn.hidden = !self.tryLab.hidden;
}
}
......
......@@ -9,6 +9,7 @@
#import "SafeSleepRequestModel.h"
#import "AudioDetailHeaderView.h"
#import "AudioCourseCell.h"
#import "MusicPlayerController.h"
@interface CourseDetailController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *audioListView;
......@@ -45,10 +46,9 @@
}];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
[self.unlockBtn setTitle:[LoginUtils getUserLoginData] ? @"开始第一节" : @"登录解锁全部章节" forState:UIControlStateNormal];
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
......@@ -69,10 +69,15 @@
- (void)unlockAction {
if ([LoginUtils getUserLoginData]) {
} else {
[LoginUtils jumpToLoginControllerWithTarget:self];
[LoginUtils jumpToLoginControllerWithTarget:self selector:@selector(updateAfterLoginSuccess)];
}
}
- (void)updateAfterLoginSuccess {
[self.unlockBtn setTitle:@"开始第一节" forState:UIControlStateNormal];
[self getAudiosData];
}
#pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.subAudioArr.count;
......@@ -95,6 +100,23 @@
return 100;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.subAudioArr.count > indexPath.row) {
SubAudioModel *model = self.subAudioArr[indexPath.row];
if (model.is_lock == 1) {
if (![LoginUtils getUserLoginData]) {
[LoginUtils jumpToLoginControllerWithTarget:self selector:@selector(updateAfterLoginSuccess)];
}
} else {
// 跳转到播放页面
MusicPlayerController *playerVC = [[MusicPlayerController alloc] init];
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:playerVC];
[self presentViewController:naviVC animated:YES completion:nil];
}
}
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
CGFloat offset = scrollView.contentOffset.y;
if (offset >= kTopHeight(0)) {
......@@ -134,7 +156,7 @@
- (UIButton *)unlockBtn {
if (!_unlockBtn) {
_unlockBtn = [UIButton btnWithTitle:@"" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
_unlockBtn = [UIButton btnWithTitle:[LoginUtils getUserLoginData] ? @"开始第一节" : @"登录解锁全部章节" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
[_unlockBtn addTarget:self action:@selector(unlockAction) forControlEvents:UIControlEventTouchUpInside];
[_unlockBtn cornerRadius:20];
}
......
//
// MusicPlayerController.h
// DreamSleep
//
// Created by peter on 2022/5/7.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 音频播放界面
@interface MusicPlayerController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// MusicPlayerController.m
// DreamSleep
//
// Created by peter on 2022/5/7.
//
#import "MusicPlayerController.h"
@interface MusicPlayerController ()
@property (nonatomic, strong) UIButton *dismissBtn;
@end
@implementation MusicPlayerController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view addSubview:self.dismissBtn];
}
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
- (void)dismiss {
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - lazy
- (UIButton *)dismissBtn {
if (!_dismissBtn) {
_dismissBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, kStatusBarHeight + 19, 30, 30)];
[_dismissBtn dk_setImage:DKImagePickerWithNames(@"home_close", @"dk_home_close", @"home_close") forState:UIControlStateNormal];
[_dismissBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}
return _dismissBtn;
}
@end
......@@ -9,8 +9,11 @@
NS_ASSUME_NONNULL_BEGIN
@interface LoginController : UIViewController
/// 登录成功block回调
typedef void (^LoginSuccessBlock)(void);
@interface LoginController : UIViewController
@property (nonatomic, copy) LoginSuccessBlock successBlock;
@end
NS_ASSUME_NONNULL_END
......@@ -46,6 +46,7 @@
[UserRequestModel wxLoginWithCode:code completion:^(UserRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[DSProgressHUD showToast:requestModel.errorInfo];
......@@ -122,6 +123,7 @@
[UserRequestModel appleLoginWithUser:userID identityToken:identityToken authorizationCode:authorizationCode completion:^(UserRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[DSProgressHUD showToast:@"登录成功"];
if (self.successBlock) {self.successBlock(); }
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[DSProgressHUD showToast:requestModel.errorInfo];
......
......@@ -50,8 +50,14 @@ NS_ASSUME_NONNULL_BEGIN
/// 清除用户登录数据
+ (void)clearUserLoginData;
/// 跳转到登录模块
/// @param target 入口控制器
+ (void)jumpToLoginControllerWithTarget:(UIViewController *)target;
/// 跳转到登录模块,并且登录成功后发送消息给入口控制器
/// @param target 入口控制器
/// @param sel 消息
+ (void)jumpToLoginControllerWithTarget:(UIViewController *)target selector:(SEL)sel;
@end
NS_ASSUME_NONNULL_END
......@@ -93,4 +93,20 @@
}
}
+ (void)jumpToLoginControllerWithTarget:(UIViewController *)target selector:(SEL)sel {
if (target && [target isKindOfClass:[UIViewController class]]) {
LoginController *loginVC = [[LoginController alloc] init];
loginVC.successBlock = ^{
if ([target respondsToSelector:sel]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[target performSelector:sel];
#pragma clang diagnostic pop
}
};
BaseNaviController *navi = [[BaseNaviController alloc] initWithRootViewController:loginVC];
[target presentViewController:navi animated:YES completion:nil];
}
}
@end
{
"images" : [
{
"filename" : "dk_ic_list_play_normal_unlock.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_list_play_normal_unlock@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_list_play_normal_unlock@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!