Commit c69d914a cgx

完成邀请好友测试页面

1 个父辈 4c1929ba
正在显示 14 个修改的文件 包含 361 行增加112 行删除
......@@ -99,6 +99,7 @@
D07DACAA2810557D0067A1BF /* RSKImageCropperStrings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D07DAC9D2810557D0067A1BF /* RSKImageCropperStrings.bundle */; };
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07DACA32810557D0067A1BF /* RSKImageScrollView.m */; };
D07F9DE927F4683B0036372F /* DKColorTable.txt in Resources */ = {isa = PBXBuildFile; fileRef = D07F9DE827F4683B0036372F /* DKColorTable.txt */; };
D0833C402852D48C00B3135E /* PosterScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0833C3F2852D48C00B3135E /* PosterScrollView.m */; };
D0874BBF2816E61000CECB3C /* RescuePlanView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0874BBE2816E61000CECB3C /* RescuePlanView.m */; };
D0878F48280BD18F005F1B7F /* LoginView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0878F47280BD18F005F1B7F /* LoginView.m */; };
D0878F4C280BEFF9005F1B7F /* UILabel+YBAttributeTextTapAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D0878F4B280BEFF9005F1B7F /* UILabel+YBAttributeTextTapAction.m */; };
......@@ -405,6 +406,8 @@
D07DACA32810557D0067A1BF /* RSKImageScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RSKImageScrollView.m; sourceTree = "<group>"; };
D07F9D0627F45CB20036372F /* DKNightVersion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DKNightVersion.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D07F9DE827F4683B0036372F /* DKColorTable.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DKColorTable.txt; sourceTree = "<group>"; };
D0833C3E2852D48C00B3135E /* PosterScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PosterScrollView.h; sourceTree = "<group>"; };
D0833C3F2852D48C00B3135E /* PosterScrollView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PosterScrollView.m; sourceTree = "<group>"; };
D0874BBD2816E61000CECB3C /* RescuePlanView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RescuePlanView.h; sourceTree = "<group>"; };
D0874BBE2816E61000CECB3C /* RescuePlanView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RescuePlanView.m; sourceTree = "<group>"; };
D0878F46280BD18F005F1B7F /* LoginView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginView.h; sourceTree = "<group>"; };
......@@ -1091,6 +1094,44 @@
path = DSNavigationTools;
sourceTree = "<group>";
};
D0948603285301F800E15A2A /* Controller */ = {
isa = PBXGroup;
children = (
D09D0E9B280D73B6008DEDAB /* InviteController.h */,
D09D0E9C280D73B6008DEDAB /* InviteController.m */,
);
path = Controller;
sourceTree = "<group>";
};
D09486042853020700E15A2A /* View */ = {
isa = PBXGroup;
children = (
D0BE32E7281551EB006539BE /* ShareAlertView.h */,
D0BE32E8281551EB006539BE /* ShareAlertView.m */,
D0833C3E2852D48C00B3135E /* PosterScrollView.h */,
D0833C3F2852D48C00B3135E /* PosterScrollView.m */,
);
path = View;
sourceTree = "<group>";
};
D09486052853022A00E15A2A /* Model */ = {
isa = PBXGroup;
children = (
D0E41B5E2851E0F6005A7DA4 /* ShareItem.h */,
D0E41B5F2851E0F6005A7DA4 /* ShareItem.m */,
);
path = Model;
sourceTree = "<group>";
};
D09486062853023300E15A2A /* RequestModel */ = {
isa = PBXGroup;
children = (
D0E41B5B2851E0D1005A7DA4 /* ShareRequestModel.h */,
D0E41B5C2851E0D1005A7DA4 /* ShareRequestModel.m */,
);
path = RequestModel;
sourceTree = "<group>";
};
D09D0E97280D4EEA008DEDAB /* SystemSet */ = {
isa = PBXGroup;
children = (
......@@ -1338,14 +1379,10 @@
D0D382682812660C005BB219 /* InviteFriend */ = {
isa = PBXGroup;
children = (
D0BE32E7281551EB006539BE /* ShareAlertView.h */,
D0BE32E8281551EB006539BE /* ShareAlertView.m */,
D09D0E9B280D73B6008DEDAB /* InviteController.h */,
D09D0E9C280D73B6008DEDAB /* InviteController.m */,
D0E41B5E2851E0F6005A7DA4 /* ShareItem.h */,
D0E41B5F2851E0F6005A7DA4 /* ShareItem.m */,
D0E41B5B2851E0D1005A7DA4 /* ShareRequestModel.h */,
D0E41B5C2851E0D1005A7DA4 /* ShareRequestModel.m */,
D09486042853020700E15A2A /* View */,
D09486052853022A00E15A2A /* Model */,
D0948603285301F800E15A2A /* Controller */,
D09486062853023300E15A2A /* RequestModel */,
);
path = InviteFriend;
sourceTree = "<group>";
......@@ -1875,6 +1912,7 @@
D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */,
D08F79E1281A1838000D99DD /* TZLocationManager.m in Sources */,
D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */,
D0833C402852D48C00B3135E /* PosterScrollView.m in Sources */,
D07A65832815911D00C15AF6 /* DsMaskView.m in Sources */,
D055BEBF2825267C00BC11A4 /* DSBaseViewController.m in Sources */,
D0FAC41C281B817D00D4B859 /* GKLoadingView.m in Sources */,
......
......@@ -25,6 +25,8 @@
#define UserServiceAgreement [NSString stringWithFormat:@"%@/%@", ServerURL, @"sleep/user/agreement"]
// 隐私政策
#define PrivacyPolicy [NSString stringWithFormat:@"%@/%@", ServerURL, @"sleep/user/privacy"]
// 测测你的睡眠分数
#define ShareTestSleepScore [NSString stringWithFormat:@"%@/%@", ServerURL, @"sleep/ssmian/share_image"]
NS_ASSUME_NONNULL_BEGIN
......
......@@ -39,7 +39,6 @@
- (void)getCourseDataRequest {
[SafeSleepRequestModel getCourseListDataWithSubID:(_type == CourseTypeSafe ? 6 : 18) isHome:NO completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
[self.courseListView.mj_header endRefreshing];
if (requestModel.resCode == DSResCodeSuccess) {
self.exceptionView.hidden = YES;
self.listArr = requestModel.courseListData;
......
......@@ -9,17 +9,18 @@
#import "ShareAlertView.h"
#import <YYWebImage/YYWebImage.h>
#import <UMShare/UMShare.h>
#import "CWCarousel.h"
#import "ShareRequestModel.h"
#import "PosterScrollView.h"
@interface InviteController () <ShareAlertViewDelegate>
@interface InviteController () <ShareAlertViewDelegate, PosterScrollViewDelegate>
@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;
@property (nonatomic, strong) PosterScrollView *posterScrollView;
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
@property (nonatomic, assign) ShareType shareType;
@property (nonatomic, strong) ShareItem *currentItem;
@end
@implementation InviteController
......@@ -31,24 +32,7 @@
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) {
}
}];
[self queryShareImagesRequest];
} else {
self.navigationItem.title = @"邀请好友";
self.view.backgroundColor = DSWhite;
......@@ -61,6 +45,18 @@
}
}
- (void)queryShareImagesRequest {
[ShareRequestModel queryShareImagesWithCompletion:^(ShareRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.exceptionView.hidden = YES;
[self.view addSubview:self.posterScrollView];
[self.posterScrollView refreshPosterData:requestModel.shareListData];
} else {
self.exceptionView.hidden = NO;
}
}];
}
#pragma mark - Actions
- (void)shareAction {
// 判断是否登录成功
......@@ -74,28 +70,53 @@
}
#pragma mark - ShareAlertViewDelegate
- (void)didClickShareBtnWithIndex:(int)index {
- (void)didClickShareBtnWithIndex:(int)index shareSource:(ShareSource)shareSource {
UMSocialPlatformType type = UMSocialPlatformType_WechatSession;
if (index == 2) {
type = UMSocialPlatformType_WechatTimeLine;
} else if (index == 3) {
type = UMSocialPlatformType_QQ;
}
[self shareTextToPlatformType:type];
[self shareWithSource:shareSource platformType:type];
}
#pragma mark - 友盟分享
- (void)shareTextToPlatformType:(UMSocialPlatformType)platformType {
- (void)shareWithSource:(ShareSource)shareSource platformType:(UMSocialPlatformType)platformType {
// 创建分享消息对象
UMSocialMessageObject*messageObject = [UMSocialMessageObject messageObject];
// 创建图片内容对象
UMShareImageObject*shareObject =[[UMShareImageObject alloc] init];
// 如果有缩略图,则设置缩略图
shareObject.thumbImage = [UIImage imageNamed:@"icon"];
UIImage *img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:@"invite_friend.webp"]];
[shareObject setShareImage:img];
// 分享消息对象设置分享内容对象
messageObject.shareObject = shareObject;
UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
switch (shareSource) {
case ShareSourceProfile:
{
// 创建图片内容对象
UMShareImageObject *shareObject = [[UMShareImageObject alloc] init];
[shareObject setShareImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:@"invite_friend.webp"]]];
// 分享消息对象设置分享内容对象
messageObject.shareObject = shareObject;
}
break;
case ShareSourceH5:
{
if (self.shareType == ShareTypeLink) {
// 创建网页内容对象
UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"测测你的睡眠分数" descr:@"为什么总感觉睡眠不足?掉发秃头跟睡眠差有关吗?年龄越大睡眠时长越少吗?" thumImage:[UIImage imageNamed:@"icon"]];
// 设置网页地址
shareObject.webpageUrl = ShareTestSleepScore;
// 分享消息对象设置分享内容对象
messageObject.shareObject = shareObject;
} else if (self.shareType == ShareTypePoster) {
// 创建图片内容对象
UMShareImageObject *shareObject = [[UMShareImageObject alloc] init];
[shareObject setShareImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.currentItem.image_url]]]];
// 分享消息对象设置分享内容对象
messageObject.shareObject = shareObject;
}
}
break;
default:
break;
}
// 调用分享接口
[[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data,NSError*error) {
if (error) {
......@@ -117,6 +138,14 @@
}];
}
#pragma mark - PosterScrollViewDelegate
- (void)shareWithType:(ShareType)type item:(ShareItem *)item {
self.shareType = type;
self.currentItem = item;
[self.shareAlertView showShareAlertView];
}
#pragma mark - lazy
- (UIScrollView *)scrollView {
if (!_scrollView) {
......@@ -145,63 +174,28 @@
- (ShareAlertView *)shareAlertView {
if (!_shareAlertView) {
_shareAlertView = [[ShareAlertView alloc] initWithDelegate:self];
_shareAlertView = [[ShareAlertView alloc] initWithDelegate:self shareSource:(self.isFromH5 ? ShareSourceH5 : ShareSourceProfile)];
}
return _shareAlertView;
}
#pragma mark - 邀请好友测试
- (UIImageView *)bottomIV {
if (!_bottomIV) {
_bottomIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"invite_basemap", @"dk_invite_basemap", @"dk_invite_basemap")];
- (PosterScrollView *)posterScrollView {
if (!_posterScrollView) {
_posterScrollView = [[PosterScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight(0)) shareDelegate:self];
}
return _bottomIV;
return _posterScrollView;
}
- (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);
}];
- (ExceptionDefaultView *)exceptionView {
if (!_exceptionView) {
WS(weakSelf);
_exceptionView = [[ExceptionDefaultView alloc] initWithType:ExceptionTypeNet block:^{
weakSelf.exceptionView.hidden = YES;
[weakSelf queryShareImagesRequest];
} superView:self.view];
}
return _inviteView;
return _exceptionView;
}
#pragma mark - 品牌模式
......@@ -209,4 +203,9 @@
return NaviStyleDefault;
}
#pragma mark - 关闭侧滑
- (BOOL)enableInteractivePopGestureRecognizer {
return NO;
}
@end
......@@ -14,7 +14,7 @@
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) {
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"获取分享海报和长图接口apiDic:%@", apiDic);
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
......
//
// PosterScrollView.h
// DreamSleep
//
// Created by peter on 2022/6/10.
//
#import <UIKit/UIKit.h>
#import "ShareItem.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, ShareType) {
// 分享链接
ShareTypeLink,
// 分享图片
ShareTypePoster
};
@protocol PosterScrollViewDelegate <NSObject>
- (void)shareWithType:(ShareType)type item:(ShareItem *)item;
@end
/// 邀请好友测试自定义view
@interface PosterScrollView : UIScrollView
@property (nonatomic, weak) id<PosterScrollViewDelegate> shareDelegate;
- (instancetype)initWithFrame:(CGRect)frame shareDelegate:(id<PosterScrollViewDelegate>)shareDelegate;
- (void)refreshPosterData:(NSArray *)listData;
@end
NS_ASSUME_NONNULL_END
//
// PosterScrollView.m
// DreamSleep
//
// Created by peter on 2022/6/10.
//
#import "PosterScrollView.h"
#import "CWCarousel.h"
@interface PosterScrollView () <CWCarouselDatasource, CWCarouselDelegate>
@property (nonatomic, strong) UIView *assistView;
@property (nonatomic, strong) CWCarousel *posterView;
@property (nonatomic, strong) UIImageView *bottomIV;
@property (nonatomic, strong) UIView *inviteView;
@property (nonatomic, strong) NSArray *posterList;
@property (nonatomic, assign) NSInteger currentIndex;
@end
@implementation PosterScrollView
- (instancetype)initWithFrame:(CGRect)frame shareDelegate:(id<PosterScrollViewDelegate>)shareDelegate {
if (self = [super initWithFrame:frame]) {
self.shareDelegate = shareDelegate;
self.posterList = [NSArray array];
self.currentIndex = 0;
self.showsVerticalScrollIndicator = NO;
[self addSubview:self.assistView];
[self.assistView addSubview:self.posterView];
[self.assistView addSubview:self.inviteView];
[self.assistView addSubview:self.bottomIV];
[self.assistView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.offset(0);
make.width.equalTo(self.mas_width);
}];
[self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.assistView).offset(40);
make.width.mas_equalTo(self.assistView);
make.height.mas_equalTo(1299*(kScreenWidth - 2*58)/780.0);
}];
[self.inviteView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.assistView).offset(15);
make.right.equalTo(self.assistView).offset(-15);
make.top.equalTo(self.posterView.mas_bottom).offset(20);
make.height.equalTo(@40);
}];
[self.bottomIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.assistView);
make.top.equalTo(self.inviteView.mas_bottom).offset(7);
make.bottom.equalTo(self.assistView);
}];
[self.assistView layoutIfNeeded];
self.contentSize = CGSizeMake(kScreenWidth, self.assistView.height);
}
return self;
}
- (void)refreshPosterData:(NSArray *)listData {
self.posterList = listData;
[self.posterView freshCarousel];
}
#pragma mark - CWCarouselDatasource
- (NSInteger)numbersForCarousel {
return self.posterList.count;
}
- (UICollectionViewCell *)viewForCarousel:(CWCarousel *)carousel indexPath:(NSIndexPath *)indexPath index:(NSInteger)index {
UICollectionViewCell *cell = [carousel.carouselView dequeueReusableCellWithReuseIdentifier:@"PosterBarnnerCellID" forIndexPath:indexPath];
UIImageView *imgView = [cell.contentView viewWithTag:777];
if (!imgView) {
imgView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds];
imgView.tag = 777;
imgView.contentMode = UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:imgView];
}
[imgView cornerRadius:24.0];
imgView.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, 1.0);
ShareItem *item = self.posterList[index];
[imgView yy_setImageWithURL:[NSURL URLWithString:item.image_url] placeholder:[UIImage imageNamed:@"bannerPlaceholder"]];
return cell;
}
#pragma mark - CWCarouselDelegate
- (void)CWCarousel:(CWCarousel *)carousel didEndScrollAtIndex:(NSInteger)index indexPathRow:(NSInteger)indexPathRow {
self.currentIndex = index;
}
#pragma mark - lazy
- (UIView *)assistView {
if (!_assistView) {
_assistView = [UIView new];
}
return _assistView;
}
- (CWCarousel *)posterView {
if (!_posterView) {
// 自定义布局
CWFlowLayout *flowLayout = [[CWFlowLayout alloc] initWithStyle:CWCarouselStyle_H_2];
flowLayout.itemWidth = kScreenWidth - 2*58;
flowLayout.itemSpace_H = 20;
_posterView = [[CWCarousel alloc] initWithFrame:CGRectZero
delegate:self
datasource:self
flowLayout:flowLayout];
_posterView.endless = YES;
_posterView.backgroundColor = DSClearColor;
_posterView.pageControl.hidden = YES;
[_posterView registerViewClass:[UICollectionViewCell class] identifier:@"PosterBarnnerCellID"];
}
return _posterView;
}
- (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 = [self buildShareBtnWithTitle:@"复制链接" imgName:@"share_link" dkImgName:@"dk_share_link" shareType:ShareTypeLink];
UIButton *sharePosterBtn = [self buildShareBtnWithTitle:@"生成海报" imgName:@"share_poster" dkImgName:@"dk_share_poster" shareType:ShareTypePoster];
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;
}
- (UIButton *)buildShareBtnWithTitle:(NSString *)title imgName:(NSString *)imgName dkImgName:(NSString *)dkImgName shareType:(ShareType)shareType {
WS(weakSelf);
UIButton *shareBtn = [UIButton btnWithTitle:title font:SysFont(12.0)];
[shareBtn dk_setImage:DKImagePickerWithNames(imgName, dkImgName, imgName) forState:UIControlStateNormal];
[shareBtn dk_setTitleColorPicker:DKColorPickerWithColors(SubTitleColor, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[shareBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 8, 0, 0)];
[shareBtn addTouchUpInsideHandler:^(NSInteger tag) {
if (weakSelf.shareDelegate && [weakSelf.shareDelegate respondsToSelector:@selector(shareWithType:item:)]) {
[weakSelf.shareDelegate shareWithType:shareType item:weakSelf.posterList[weakSelf.currentIndex]];
}
}];
[self.inviteView addSubview:shareBtn];
return shareBtn;
}
@end
......@@ -9,20 +9,28 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, ShareSource) {
// H5中邀请好友测试
ShareSourceH5,
// 我的邀请好友
ShareSourceProfile
};
@protocol ShareAlertViewDelegate <NSObject>
@optional
/// 点击拍照或者相册
/// 点击分享按钮
/// @param index 1:微信好友,2:朋友圈,3:QQ好友
- (void)didClickShareBtnWithIndex:(int)index;
/// @param shareSource 分享来源
- (void)didClickShareBtnWithIndex:(int)index shareSource:(ShareSource)shareSource;
@end
/// 分享弹框
@interface ShareAlertView : UIView
@property (nonatomic, weak) id<ShareAlertViewDelegate> delegate;
@property (nonatomic, assign) ShareSource shareSource;
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate;
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate shareSource:(ShareSource)shareSource;
- (void)showShareAlertView;
......
......@@ -13,9 +13,10 @@
@implementation ShareAlertView
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate {
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate shareSource:(ShareSource)shareSource {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_delegate = delegate;
_shareSource = shareSource;
self.backgroundColor = AlertDarkColor;
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
......@@ -80,8 +81,8 @@
- (void)clickAction:(UIButton *)sender {
[self dismissShareAlertView];
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickShareBtnWithIndex:)]) {
[self.delegate didClickShareBtnWithIndex:(int)sender.tag];
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickShareBtnWithIndex:shareSource:)]) {
[self.delegate didClickShareBtnWithIndex:(int)sender.tag shareSource:self.shareSource];
}
}
......
......@@ -11,36 +11,33 @@
@class CWCarousel;
@protocol CWCarouselDelegate<NSObject>
@optional
/**
轮播图点击代理
@param carousel 轮播图实例对象
@param index 被点击的下标
*/
- (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index;
@optional
/**
将要开始滑动时,会触发该代理
将要开始滑动时,会触发该代理
@param carousel 轮播图控件
@param index 开始滑动时,处于中心点图片的下标
@param indexPathRow 开始滑动时,处于中心点图片的在控件内部的实际下标
*/
- (void)CWCarousel:(CWCarousel *)carousel didStartScrollAtIndex:(NSInteger)index indexPathRow:(NSInteger)indexPathRow;
/**
滑动结束后,会触发该代理
@param carousel 轮播图控件
@param index 结束滑动时,处于中心点图片的下标
@param indexPathRow 结束滑动时,处于中心点图片在控件内部的实际下标
*/
- (void)CWCarousel:(CWCarousel *)carousel didEndScrollAtIndex:(NSInteger)index indexPathRow:(NSInteger)indexPathRow;
/// 开始布局pageControl时会触发该回调
/// @param carousel 轮播组件对象
/// @param pageControl pageControl对象
......@@ -53,19 +50,18 @@
/// 2. 先将CWCarousel添加到父视图中, 后设置customPageControl, 此回调会被调用两次, 第一次isDefault = YES, 第二次isDefault = NO. 因为将CWCarousel添加到父视图时检测到没有customPageControl, 组件内部并不清楚外部调用者是否会设置customPageControl, 会先创建并添加默认的pageControl.
/// 3. 当自定义的customPageControl宽度布局不是自己撑开的时候, 请在该回调中自己布局. 否则采用默认的布局将不可见.
- (void)CWCarousel:(CWCarousel *)carousel addPageControl:(UIView *)pageControl isDefault:(BOOL)isDefault;
@end
@protocol CWCarouselDatasource<NSObject>
/**
轮播图数量
@return 轮播图展示个数
*/
- (NSInteger)numbersForCarousel;
/**
自定义每个轮播图视图
@param carousel 轮播图控件
@param indexPath 轮播图cell实际下标
@param index 业务逻辑需要的下标
......@@ -74,7 +70,6 @@
- (UICollectionViewCell *)viewForCarousel:(CWCarousel *)carousel indexPath:(NSIndexPath *)indexPath index:(NSInteger)index;
@end
@protocol CWCarouselPageControlProtocol<NSObject>
@required
/**
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!