Commit 4c1929ba cgx

优化AI睡眠教练、完成部分邀请好友测试页面

1 个父辈 33bc25f9
正在显示 65 个修改的文件 包含 580 行增加57 行删除
......@@ -31,7 +31,6 @@
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; };
D027EE3227FB5464004BBA61 /* pull_down.gif in Resources */ = {isa = PBXBuildFile; fileRef = D027EE3127FB5464004BBA61 /* pull_down.gif */; };
D030C1B8284775930014946F /* RelaxTrainController.m in Sources */ = {isa = PBXBuildFile; fileRef = D030C1B7284775930014946F /* RelaxTrainController.m */; };
D033616028502B76005573CF /* DailyTaskTV.m in Sources */ = {isa = PBXBuildFile; fileRef = D033615F28502B76005573CF /* DailyTaskTV.m */; };
D0336163285035AB005573CF /* DailyBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0336162285035AB005573CF /* DailyBgView.m */; };
......@@ -193,6 +192,8 @@
D0DB33A528204E7C00E15914 /* FirstLeadAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DB33A428204E7C00E15914 /* FirstLeadAlertView.m */; };
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DB33A728224D5100E15914 /* PromotionModel.m */; };
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DF90AD2814390000FC0F64 /* BannerModel.m */; };
D0E41B5D2851E0D1005A7DA4 /* ShareRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E41B5C2851E0D1005A7DA4 /* ShareRequestModel.m */; };
D0E41B602851E0F6005A7DA4 /* ShareItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E41B5F2851E0F6005A7DA4 /* ShareItem.m */; };
D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; };
D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; };
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */; };
......@@ -284,7 +285,6 @@
D027EE2827FB51D0004BBA61 /* DSGifHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSGifHeader.m; sourceTree = "<group>"; };
D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+Extras.h"; sourceTree = "<group>"; };
D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Extras.m"; sourceTree = "<group>"; };
D027EE3127FB5464004BBA61 /* pull_down.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = pull_down.gif; sourceTree = "<group>"; };
D030C1B6284775930014946F /* RelaxTrainController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RelaxTrainController.h; sourceTree = "<group>"; };
D030C1B7284775930014946F /* RelaxTrainController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RelaxTrainController.m; sourceTree = "<group>"; };
D033615E28502B76005573CF /* DailyTaskTV.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DailyTaskTV.h; sourceTree = "<group>"; };
......@@ -592,6 +592,10 @@
D0DF90AB28142F1300FC0F64 /* DreamSleepDebug.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = DreamSleepDebug.entitlements; sourceTree = "<group>"; };
D0DF90AC2814390000FC0F64 /* BannerModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BannerModel.h; sourceTree = "<group>"; };
D0DF90AD2814390000FC0F64 /* BannerModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BannerModel.m; sourceTree = "<group>"; };
D0E41B5B2851E0D1005A7DA4 /* ShareRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareRequestModel.h; sourceTree = "<group>"; };
D0E41B5C2851E0D1005A7DA4 /* ShareRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareRequestModel.m; sourceTree = "<group>"; };
D0E41B5E2851E0F6005A7DA4 /* ShareItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareItem.h; sourceTree = "<group>"; };
D0E41B5F2851E0F6005A7DA4 /* ShareItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareItem.m; sourceTree = "<group>"; };
D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
......@@ -773,7 +777,6 @@
D0C09ED528007D9100709D4C /* 478normal_lottie.json */,
D0C09ED628007D9100709D4C /* relax_lottie.json */,
D0C09ED328007D9100709D4C /* relax_normal_lottie.json */,
D027EE3127FB5464004BBA61 /* pull_down.gif */,
D0B5ECB027F2D9E0003EDFE3 /* Assets.xcassets */,
D07F9DE827F4683B0036372F /* DKColorTable.txt */,
);
......@@ -820,21 +823,10 @@
D04567AC27F6D0BA009F0A82 /* AISleepModule */ = {
isa = PBXGroup;
children = (
D0D96FE42848698F00461839 /* SomeProxy.h */,
D0D96FE32848698E00461839 /* SomeProxy.m */,
D04B3DB427F6F7430022F8DF /* AISleepCoach.storyboard */,
D04B3DB927F6F7940022F8DF /* AISleepCoachController.h */,
D04B3DBA27F6F7940022F8DF /* AISleepCoachController.m */,
D030C1B6284775930014946F /* RelaxTrainController.h */,
D030C1B7284775930014946F /* RelaxTrainController.m */,
D0D96FDD2848457900461839 /* RelaxTrainRequestModel.h */,
D0D96FDE2848457900461839 /* RelaxTrainRequestModel.m */,
D0D96FE02848493700461839 /* RelaxTrainModel.h */,
D0D96FE12848493700461839 /* RelaxTrainModel.m */,
D0031547284DAC0D00CFE94D /* RelaxBodyView.h */,
D0031548284DAC0D00CFE94D /* RelaxBodyView.m */,
D003154A284DF46F00CFE94D /* RelaxTrainCell.h */,
D003154B284DF46F00CFE94D /* RelaxTrainCell.m */,
D0E41B5928519D05005A7DA4 /* View */,
D0E41B5A28519D1F005A7DA4 /* Model */,
D0E41B5728519CD1005A7DA4 /* Controller */,
D0E41B5828519CF2005A7DA4 /* RequestModel */,
);
path = AISleepModule;
sourceTree = "<group>";
......@@ -953,6 +945,8 @@
D07A657A2815897A00C15AF6 /* H5 */ = {
isa = PBXGroup;
children = (
D0D96FE42848698F00461839 /* SomeProxy.h */,
D0D96FE32848698E00461839 /* SomeProxy.m */,
D07A65812815911D00C15AF6 /* DsMaskView.h */,
D07A65822815911D00C15AF6 /* DsMaskView.m */,
D0BB9AA2281626F200DB209E /* ExceptionDefaultView.h */,
......@@ -1348,10 +1342,55 @@
D0BE32E8281551EB006539BE /* ShareAlertView.m */,
D09D0E9B280D73B6008DEDAB /* InviteController.h */,
D09D0E9C280D73B6008DEDAB /* InviteController.m */,
D0E41B5E2851E0F6005A7DA4 /* ShareItem.h */,
D0E41B5F2851E0F6005A7DA4 /* ShareItem.m */,
D0E41B5B2851E0D1005A7DA4 /* ShareRequestModel.h */,
D0E41B5C2851E0D1005A7DA4 /* ShareRequestModel.m */,
);
path = InviteFriend;
sourceTree = "<group>";
};
D0E41B5728519CD1005A7DA4 /* Controller */ = {
isa = PBXGroup;
children = (
D04B3DB427F6F7430022F8DF /* AISleepCoach.storyboard */,
D04B3DB927F6F7940022F8DF /* AISleepCoachController.h */,
D04B3DBA27F6F7940022F8DF /* AISleepCoachController.m */,
D030C1B6284775930014946F /* RelaxTrainController.h */,
D030C1B7284775930014946F /* RelaxTrainController.m */,
);
path = Controller;
sourceTree = "<group>";
};
D0E41B5828519CF2005A7DA4 /* RequestModel */ = {
isa = PBXGroup;
children = (
D0D96FDD2848457900461839 /* RelaxTrainRequestModel.h */,
D0D96FDE2848457900461839 /* RelaxTrainRequestModel.m */,
);
path = RequestModel;
sourceTree = "<group>";
};
D0E41B5928519D05005A7DA4 /* View */ = {
isa = PBXGroup;
children = (
D003154A284DF46F00CFE94D /* RelaxTrainCell.h */,
D003154B284DF46F00CFE94D /* RelaxTrainCell.m */,
D0031547284DAC0D00CFE94D /* RelaxBodyView.h */,
D0031548284DAC0D00CFE94D /* RelaxBodyView.m */,
);
path = View;
sourceTree = "<group>";
};
D0E41B5A28519D1F005A7DA4 /* Model */ = {
isa = PBXGroup;
children = (
D0D96FE02848493700461839 /* RelaxTrainModel.h */,
D0D96FE12848493700461839 /* RelaxTrainModel.m */,
);
path = Model;
sourceTree = "<group>";
};
D0E65FF32807A654006562F2 /* HYBUnicodeReadable */ = {
isa = PBXGroup;
children = (
......@@ -1709,7 +1748,6 @@
D046FE0D28100342000295AC /* UMSocialSDKResources.bundle in Resources */,
D0FAC425281B817D00D4B859 /* GKPhotoBrowser.bundle in Resources */,
D04B3DB327F6F6070022F8DF /* Home.storyboard in Resources */,
D027EE3227FB5464004BBA61 /* pull_down.gif in Resources */,
D020CE1F280D951400E7E82F /* invite_friend.webp in Resources */,
D07F9DE927F4683B0036372F /* DKColorTable.txt in Resources */,
D0B5ECB427F2D9E0003EDFE3 /* LaunchScreen.storyboard in Resources */,
......@@ -1947,7 +1985,9 @@
D037C49A284F4F0D000F3089 /* DailyTaskCell.m in Sources */,
D0A7510E282E2FEF00589B0E /* NoisePlayView.m in Sources */,
D08F79DD281A1838000D99DD /* TZImageManager.m in Sources */,
D0E41B602851E0F6005A7DA4 /* ShareItem.m in Sources */,
D0506B1828054ECD00229278 /* SafeHelperCollectionView.m in Sources */,
D0E41B5D2851E0D1005A7DA4 /* ShareRequestModel.m in Sources */,
D04B3DC327F6F9390022F8DF /* HomeViewController.m in Sources */,
D0F9AC5E282660CC00FD7A3B /* MusicPlayerView.m in Sources */,
D091E668283F0E8800D3279E /* MyPointController.m in Sources */,
......
......@@ -44,6 +44,12 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)btnWithTitle:(NSString *)title titleColor:(UIColor *)titleColor font:(UIFont *)font;
- (void)setTitle:(NSString *)title font:(UIFont *)font;
typedef void (^kTouchUpInsideHandlerBlock)(NSInteger tag);
/// 将UIButton点击事件封装成block
/// @param handlerBlock handlerBlock
- (void)addTouchUpInsideHandler:(kTouchUpInsideHandlerBlock)handlerBlock;
@end
NS_ASSUME_NONNULL_END
......@@ -6,6 +6,7 @@
//
#import "UIButton+Extras.h"
#import <objc/runtime.h>
@implementation UIButton (Extras)
......@@ -101,4 +102,16 @@
[self.titleLabel setFont:font];
}
static const void *kUIButtonBlockKey = &kUIButtonBlockKey;
- (void)addTouchUpInsideHandler:(kTouchUpInsideHandlerBlock)handlerBlock {
objc_setAssociatedObject(self, kUIButtonBlockKey, handlerBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
[self addTarget:self action:@selector(hookTouchUpInsideAction:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)hookTouchUpInsideAction:(UIButton *)sender {
kTouchUpInsideHandlerBlock block = objc_getAssociatedObject(self, kUIButtonBlockKey);
if (block) { block(sender.tag); }
}
@end
......@@ -11,11 +11,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 自定义遮罩视图
@interface DsMaskView : UIView
/// 显示遮罩
/// @param superView superView
+ (void)showMaskWithSuperView:(UIView *)superView;
/// 初始化
/// @param superView 父视图
- (instancetype)initWithSuperView:(UIView *)superView;
/// 显示或隐藏
- (void)display;
@end
NS_ASSUME_NONNULL_END
......@@ -9,24 +9,23 @@
@implementation DsMaskView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
- (instancetype)initWithSuperView:(UIView *)superView {
if (self = [super init]) {
self.backgroundColor = ColorFromHex(0x6B7485);
self.alpha = .5;
self.userInteractionEnabled = NO;
self.hidden = ![self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight];
UIView *view = superView ? superView : DSKeyWindow;
[view addSubview:self];
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(view).insets(UIEdgeInsetsMake(0, 0, 0, 0));
}];
}
return self;
}
+ (void)showMaskWithSuperView:(UIView *)superView {
DsMaskView *maskView = [[DsMaskView alloc] init];
UIView *view = superView ? superView : DSKeyWindow;
[view addSubview:maskView];
[maskView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(view).insets(UIEdgeInsetsMake(0, 0, 0, 0));
}];
- (void)display {
self.hidden = ![self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight];
}
@end
......@@ -9,6 +9,7 @@
#import <WebKit/webKit.h>
#import "DsMaskView.h"
#import "SomeProxy.h"
#import "InviteController.h"
@interface DsWebController () <WKNavigationDelegate, WKScriptMessageHandler>
@property (nonatomic, copy) NSString *naviTitle;
......@@ -20,6 +21,8 @@
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
/// 白天/夜间模式导航栏返回按钮
@property (nonatomic, strong) UIButton *dkBackBtn;
@property (nonatomic, strong) DsMaskView *dsMaskView;
@property (nonatomic, strong) UIView *inviteView;
@end
@implementation DsWebController
......@@ -96,7 +99,7 @@
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
self.exceptionView.hidden = YES;
if (self.isShowNavi == NO) { self.dkBackBtn.hidden = YES; }
[DsMaskView showMaskWithSuperView:self.view];
[self.dsMaskView display];
self.webView.hidden = NO;
}
......@@ -113,11 +116,28 @@
NSDictionary *bodyDic = message.body;
int type = [bodyDic[@"type"] intValue];
DSLog(@"bodyDic:%@", bodyDic);
if (type == 88) { // 新开webview,关闭
if (self.refreshDelegate && [self.refreshDelegate respondsToSelector:@selector(reloadAIPage)]) {
[self.refreshDelegate reloadAIPage];
switch (type) {
case 66: // 显示邀请好友测试悬浮按钮
{
self.inviteView.hidden = NO;
}
break;
case 77: // 隐藏邀请好友测试悬浮按钮
{
self.inviteView.hidden = YES;
}
[self.navigationController popViewControllerAnimated:YES];
break;
case 88: // 关闭webview
{
if (self.refreshDelegate && [self.refreshDelegate respondsToSelector:@selector(reloadAIPage)]) {
[self.refreshDelegate reloadAIPage];
}
[self.navigationController popViewControllerAnimated:YES];
}
break;
default:
break;
}
}
}
......@@ -187,6 +207,53 @@
return _dkBackBtn;
}
- (DsMaskView *)dsMaskView {
if (!_dsMaskView) {
_dsMaskView = [[DsMaskView alloc] initWithSuperView:self.view];
}
return _dsMaskView;
}
- (UIView *)inviteView {
if (!_inviteView) {
_inviteView = [UIView new];
_inviteView.hidden = YES;
[self.view addSubview:_inviteView];
WS(weakSelf);
UIButton *closeBtn = [UIButton new];
[closeBtn setImage:[UIImage imageNamed:@"close_invite_icon"] forState:UIControlStateNormal];
[closeBtn addTouchUpInsideHandler:^(NSInteger tag) {
weakSelf.inviteView.hidden = YES;
}];
[_inviteView addSubview:closeBtn];
UIButton *inviteBtn = [UIButton new];
[inviteBtn setImage:[UIImage imageNamed:@"invite_friend_test"] forState:UIControlStateNormal];
[inviteBtn addTouchUpInsideHandler:^(NSInteger tag) {
InviteController *inviteVC = [InviteController new];
inviteVC.isFromH5 = YES;
[weakSelf.navigationController pushViewController:inviteVC animated:YES];
}];
[_inviteView addSubview:inviteBtn];
[_inviteView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(91, 80));
make.right.equalTo(self.view).offset(-10);
make.bottom.equalTo(self.view).offset(-150-Bottom_SafeArea_Height);
}];
[closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(_inviteView);
make.width.height.equalTo(@22);
}];
[inviteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.equalTo(_inviteView);
make.width.height.equalTo(@80);
}];
}
return _inviteView;
}
#pragma mark - 关闭侧滑
- (BOOL)enableInteractivePopGestureRecognizer {
return NO;
......
......@@ -160,6 +160,7 @@
{
RelaxTrainController *relaxVC = [RelaxTrainController new];
relaxVC.refreshDelegate = self;
relaxVC.params = bodyDic;
[self.navigationController pushViewController:relaxVC animated:YES];
}
break;
......
......@@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 放松训练、腹式呼吸法页面
@interface RelaxTrainController : DSBaseViewController
@property (nonatomic, weak) id<RelaxTrainControllerDelegate> refreshDelegate;
/// title和step参数
@property (nonatomic, strong) NSDictionary *params;
@end
NS_ASSUME_NONNULL_END
......@@ -49,12 +49,33 @@
if (requestModel.resCode == DSResCodeSuccess) {
if (requestModel.trainAudioList.count) {
self.listArr = requestModel.trainAudioList;
[self.bodyView refreshData:self.listArr currentIndex:0];
if (self.listArr && self.listArr.count > 0) {
NSInteger currentIndex = [self getIndexWithListData:self.listArr];
[self.bodyView refreshData:self.listArr currentIndex:currentIndex];
}
}
}
}];
}
#pragma mark - 根据title匹配下标索引
- (NSInteger)getIndexWithListData:(NSArray *)listData {
__block NSInteger currentIndex = 0;
NSString *title = self.params[@"title"];
// 放松音频随机选一个
if ([title isEqualToString:@"练习放松训练"]) {
currentIndex = arc4random() % listData.count;
} else {
[listData enumerateObjectsUsingBlock:^(RelaxTrainModel * obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.audio_name containsString:title]) {
currentIndex = idx;
*stop = YES;
}
}];
}
return currentIndex;
}
#pragma mark - Actions
- (void)backAction {
[super backAction];
......@@ -131,6 +152,7 @@
if (!_bodyView) {
_bodyView = [[RelaxBodyView alloc] initWithFrame:CGRectMake(0, 351, kScreenWidth, 420 + Bottom_SafeArea_Height)];
_bodyView.delegate = self;
_bodyView.updateParams = self.params;
}
return _bodyView;
}
......
......@@ -21,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)refreshData:(NSArray *)listArr currentIndex:(NSInteger)index;
/// title和step参数
@property (nonatomic, strong) NSDictionary *updateParams;
/// 页面退出时停止音频播放
- (void)stopAudio;
......
......@@ -335,13 +335,14 @@
DSLog(@"播放ing...");
// 更新腹式呼吸放松法任务状态
if (weakSelf.isUpdateTask == NO) {
#warning - 需要梳理业务逻辑
[RelaxTrainRequestModel userCurTaskStateWithParams:@{@"title":@"腹式呼吸放松法", @"step":@2} completion:^(RelaxTrainRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
weakSelf.isUpdateTask = YES;
}
}];
@synchronized (weakSelf) {
if (weakSelf.isUpdateTask == NO) {
[RelaxTrainRequestModel userCurTaskStateWithParams:weakSelf.updateParams completion:^(RelaxTrainRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
weakSelf.isUpdateTask = YES;
}
}];
}
}
break;
......
......@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface InviteController : UIViewController
@property (nonatomic, assign) BOOL isFromH5;
@end
NS_ASSUME_NONNULL_END
......@@ -9,11 +9,17 @@
#import "ShareAlertView.h"
#import <YYWebImage/YYWebImage.h>
#import <UMShare/UMShare.h>
#import "CWCarousel.h"
#import "ShareRequestModel.h"
@interface InviteController () <ShareAlertViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) YYAnimatedImageView *animatedView;
@property (nonatomic, strong) ShareAlertView *shareAlertView;
@property (nonatomic, strong) CWCarousel *posterView;
@property (nonatomic, strong) UIImageView *bottomIV;
@property (nonatomic, strong) UIView *inviteView;
@end
@implementation InviteController
......@@ -21,14 +27,38 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"邀请好友";
self.view.backgroundColor = DSWhite;
[self.view addSubview:self.scrollView];
UIButton *shareBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
[shareBtn setImage:[UIImage imageNamed:@"shareIcon"] forState:UIControlStateNormal];
[shareBtn addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
if (self.isFromH5) {
self.navigationItem.title = @"邀请好友测试";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view addSubview:self.bottomIV];
[self.view addSubview:self.inviteView];
[self.bottomIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(self.view);
}];
[self.inviteView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).offset(-15);
make.bottom.equalTo(self.view).offset(-157-Bottom_SafeArea_Height);
make.height.equalTo(@40);
}];
[ShareRequestModel queryShareImagesWithCompletion:^(ShareRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
}
}];
} else {
self.navigationItem.title = @"邀请好友";
self.view.backgroundColor = DSWhite;
[self.view addSubview:self.scrollView];
UIButton *shareBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
[shareBtn setImage:[UIImage imageNamed:@"shareIcon"] forState:UIControlStateNormal];
[shareBtn addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
}
}
#pragma mark - Actions
......@@ -120,6 +150,60 @@
return _shareAlertView;
}
#pragma mark - 邀请好友测试
- (UIImageView *)bottomIV {
if (!_bottomIV) {
_bottomIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"invite_basemap", @"dk_invite_basemap", @"dk_invite_basemap")];
}
return _bottomIV;
}
- (UIView *)inviteView {
if (!_inviteView) {
_inviteView = [UIView new];
_inviteView.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[_inviteView cornerRadius:12.0];
UIButton *shareLinkBtn = [UIButton btnWithTitle:@"复制链接" font:SysFont(12.0)];
[shareLinkBtn dk_setImage:DKImagePickerWithNames(@"share_link", @"dk_share_link", @"share_link") forState:UIControlStateNormal];
[shareLinkBtn dk_setTitleColorPicker:DKColorPickerWithColors(SubTitleColor, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[shareLinkBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 8, 0, 0)];
[shareLinkBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
[_inviteView addSubview:shareLinkBtn];
UIButton *sharePosterBtn = [UIButton btnWithTitle:@"生成海报" font:SysFont(12.0)];
[sharePosterBtn dk_setImage:DKImagePickerWithNames(@"share_poster", @"dk_share_poster", @"share_poster") forState:UIControlStateNormal];
[sharePosterBtn dk_setTitleColorPicker:DKColorPickerWithColors(SubTitleColor, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[sharePosterBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 8, 0, 0)];
[sharePosterBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
[_inviteView addSubview:sharePosterBtn];
UIView *line = [UIView new];
line.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xEEEEEE), DSWhite, DSWhite);
[_inviteView addSubview:line];
[shareLinkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.bottom.equalTo(_inviteView);
}];
[sharePosterBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.bottom.equalTo(_inviteView);
make.width.equalTo(shareLinkBtn);
make.left.equalTo(shareLinkBtn.mas_right);
}];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_inviteView).offset(9);
make.bottom.equalTo(_inviteView).offset(-9);
make.centerX.equalTo(_inviteView);
make.width.equalTo(@1);
}];
}
return _inviteView;
}
#pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle {
return NaviStyleDefault;
......
//
// ShareItem.h
// DreamSleep
//
// Created by peter on 2022/6/9.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ShareItem : NSObject
/// item id
@property (nonatomic, assign) int item_id;
/// 分享类别id
@property (nonatomic, assign) int type_id;
/// 类型名称
@property (nonatomic, copy) NSString *type_name;
/// 分享海报地址
@property (nonatomic, copy) NSString *image_url;
/// 分享海报描述说明
@property (nonatomic, copy) NSString *images_desc;
/// 图片类型 1:海报,2:长图
@property (nonatomic, assign) int image_type;
/// 海报名称
@property (nonatomic, copy) NSString *image_name;
@end
NS_ASSUME_NONNULL_END
//
// ShareItem.m
// DreamSleep
//
// Created by peter on 2022/6/9.
//
#import "ShareItem.h"
@implementation ShareItem
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"item_id" : @"id"};
}
@end
//
// ShareRequestModel.h
// DreamSleep
//
// Created by peter on 2022/6/9.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface ShareRequestModel : DSNetworkTool
@property (nonatomic, strong) NSArray *shareListData;
/// 海报和长图接口
/// @param completion completion
+ (NSURLSessionDataTask *)queryShareImagesWithCompletion:(void (^)(ShareRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// ShareRequestModel.m
// DreamSleep
//
// Created by peter on 2022/6/9.
//
#import "ShareRequestModel.h"
#import "ShareItem.h"
@implementation ShareRequestModel
+ (NSURLSessionDataTask *)queryShareImagesWithCompletion:(void (^)(ShareRequestModel *requestModel))completion {
ShareRequestModel * requestModel = [[ShareRequestModel alloc] init];
NSString *api = @"query_share_images";
NSString *argStr = [NSString stringWithFormat:@"query{%@(type_id:101,image_type:1)}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"获取分享海报和长图接口apiDic:%@", apiDic);
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
[resultArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSDictionary *listDic = obj;
ShareItem *shareItem = [ShareItem yy_modelWithDictionary:listDic];
[tmpArr addObject:shareItem];
}];
requestModel.shareListData = [tmpArr copy];
requestModel.resCode = DSResCodeSuccess;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end
{
"images" : [
{
"filename" : "close_invite_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "close_invite_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "close_invite_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_invite_basemap.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_invite_basemap@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_invite_basemap@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_share_link.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_share_link@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_share_link@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_share_poster.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_share_poster@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_share_poster@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "invite_basemap.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "invite_basemap@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "invite_basemap@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "invite_friend_test.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "invite_friend_test@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "invite_friend_test@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "share_link.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "share_link@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "share_link@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "share_poster.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "share_poster@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "share_poster@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!