Commit 4e6dc930 cgx

完成分享功能模块

1 个父辈 83a1e5a9
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; }; D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; };
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; }; D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; }; D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; };
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E8281551EB006539BE /* ShareAlertView.m */; };
D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; }; D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; };
D0C09ED828007D9100709D4C /* 478_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED428007D9100709D4C /* 478_lottie.json */; }; D0C09ED828007D9100709D4C /* 478_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED428007D9100709D4C /* 478_lottie.json */; };
D0C09ED928007D9100709D4C /* 478normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED528007D9100709D4C /* 478normal_lottie.json */; }; D0C09ED928007D9100709D4C /* 478normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED528007D9100709D4C /* 478normal_lottie.json */; };
...@@ -266,6 +267,8 @@ ...@@ -266,6 +267,8 @@
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; }; D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; };
D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; }; D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; };
D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; }; D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; };
D0BE32E7281551EB006539BE /* ShareAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareAlertView.h; sourceTree = "<group>"; };
D0BE32E8281551EB006539BE /* ShareAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareAlertView.m; sourceTree = "<group>"; };
D0C09ED328007D9100709D4C /* relax_normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = relax_normal_lottie.json; sourceTree = "<group>"; }; D0C09ED328007D9100709D4C /* relax_normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = relax_normal_lottie.json; sourceTree = "<group>"; };
D0C09ED428007D9100709D4C /* 478_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478_lottie.json; sourceTree = "<group>"; }; D0C09ED428007D9100709D4C /* 478_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478_lottie.json; sourceTree = "<group>"; };
D0C09ED528007D9100709D4C /* 478normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478normal_lottie.json; sourceTree = "<group>"; }; D0C09ED528007D9100709D4C /* 478normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478normal_lottie.json; sourceTree = "<group>"; };
...@@ -760,6 +763,8 @@ ...@@ -760,6 +763,8 @@
children = ( children = (
D09D0E9B280D73B6008DEDAB /* InviteController.h */, D09D0E9B280D73B6008DEDAB /* InviteController.h */,
D09D0E9C280D73B6008DEDAB /* InviteController.m */, D09D0E9C280D73B6008DEDAB /* InviteController.m */,
D0BE32E7281551EB006539BE /* ShareAlertView.h */,
D0BE32E8281551EB006539BE /* ShareAlertView.m */,
); );
path = InviteFriend; path = InviteFriend;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1059,6 +1064,7 @@ ...@@ -1059,6 +1064,7 @@
D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */, D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */,
D09BF331280E570D00E5F06C /* UserModel.m in Sources */, D09BF331280E570D00E5F06C /* UserModel.m in Sources */,
D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */, D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */,
D0BE32E9281551EB006539BE /* ShareAlertView.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 */,
......
...@@ -6,12 +6,14 @@ ...@@ -6,12 +6,14 @@
// //
#import "InviteController.h" #import "InviteController.h"
#import "ShareAlertView.h"
#import <YYWebImage/YYWebImage.h> #import <YYWebImage/YYWebImage.h>
#import <UMShare/UMShare.h> #import <UMShare/UMShare.h>
@interface InviteController () @interface InviteController () <ShareAlertViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) YYAnimatedImageView *animatedView; @property (nonatomic, strong) YYAnimatedImageView *animatedView;
@property (nonatomic, strong) ShareAlertView *shareAlertView;
@end @end
@implementation InviteController @implementation InviteController
...@@ -38,24 +40,18 @@ ...@@ -38,24 +40,18 @@
return; return;
} }
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"模拟分享" message:@"" preferredStyle:UIAlertControllerStyleAlert]; [self.shareAlertView showShareAlertView];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"微信好友" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }
[self shareTextToPlatformType:UMSocialPlatformType_WechatSession];
}]; #pragma mark - ShareAlertViewDelegate
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"朋友圈" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - (void)didClickShareBtnWithIndex:(int)index {
[self shareTextToPlatformType:UMSocialPlatformType_WechatTimeLine]; UMSocialPlatformType type = UMSocialPlatformType_WechatSession;
}]; if (index == 2) {
UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"QQ好友" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { type = UMSocialPlatformType_WechatTimeLine;
[self shareTextToPlatformType:UMSocialPlatformType_QQ]; } else if (index == 3) {
}]; type = UMSocialPlatformType_QQ;
UIAlertAction *action4 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }
[self dismissViewControllerAnimated:YES completion:nil]; [self shareTextToPlatformType:type];
}];
[alertVC addAction:action1];
[alertVC addAction:action2];
[alertVC addAction:action3];
[alertVC addAction:action4];
[self presentViewController:alertVC animated:YES completion:nil];
} }
#pragma mark - 友盟分享 #pragma mark - 友盟分享
...@@ -117,6 +113,13 @@ ...@@ -117,6 +113,13 @@
return _animatedView; return _animatedView;
} }
- (ShareAlertView *)shareAlertView {
if (!_shareAlertView) {
_shareAlertView = [[ShareAlertView alloc] initWithDelegate:self];
}
return _shareAlertView;
}
#pragma mark - 品牌模式 #pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle { - (NaviStyle)navigationBarStyle {
return NaviStyleDefault; return NaviStyleDefault;
......
//
// ShareAlertView.h
// DreamSleep
//
// Created by peter on 2022/4/24.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol ShareAlertViewDelegate <NSObject>
@optional
/// 点击拍照或者相册
/// @param index 1:微信好友,2:朋友圈,3:QQ好友
- (void)didClickShareBtnWithIndex:(int)index;
@end
/// 分享弹框
@interface ShareAlertView : UIView
@property (nonatomic, weak) id<ShareAlertViewDelegate> delegate;
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate;
- (void)showShareAlertView;
@end
NS_ASSUME_NONNULL_END
//
// ShareAlertView.m
// DreamSleep
//
// Created by peter on 2022/4/24.
//
#import "ShareAlertView.h"
@interface ShareAlertView ()
@property (nonatomic, strong) UIView *shareView;
@end
@implementation ShareAlertView
- (instancetype)initWithDelegate:(id<ShareAlertViewDelegate>)delegate {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_delegate = delegate;
self.backgroundColor = AlertDarkColor;
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
[self addSubview:self.shareView];
[self.shareView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.bottom.equalTo(self).offset(- 118 - Bottom_SafeArea_Height);
make.height.equalTo(@125);
}];
UILabel *titleLab = [UILabel dkLabWithText:@"分享到" font:BoldFont(15)];
[self.shareView addSubview:titleLab];
UIButton *wxFriendBtn = [self btnWithTitle:@"微信好友" index:1 imgName:@"wx_friend" superView:self.shareView];
UIButton *wxTimelineBtn = [self btnWithTitle:@"朋友圈" index:2 imgName:@"wx_timeline" superView:self.shareView];
UIButton *qqShareBtn = [self btnWithTitle:@"QQ好友" index:3 imgName:@"qq_share" superView:self.shareView];
UIButton *dismissBtn = [UIButton dkBtnTitle:@"取消" font:BoldFont(15)];
dismissBtn.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[dismissBtn addTarget:self action:@selector(dismissShareAlertView) forControlEvents:UIControlEventTouchUpInside];
[dismissBtn cornerRadius:12.0];
[self addSubview:dismissBtn];
[titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.shareView);
make.top.equalTo(self.shareView).offset(15);
make.height.equalTo(@21);
}];
[wxFriendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(titleLab.mas_bottom);
make.bottom.equalTo(self.shareView);
make.left.equalTo(self.shareView);
}];
[wxTimelineBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wxFriendBtn);
make.left.equalTo(wxFriendBtn.mas_right);
make.size.equalTo(wxFriendBtn);
}];
[qqShareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wxFriendBtn);
make.left.equalTo(wxTimelineBtn.mas_right);
make.size.equalTo(wxFriendBtn);
make.right.equalTo(self.shareView);
}];
[dismissBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.shareView);
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.top.equalTo(self.shareView.mas_bottom).offset(20);
make.height.equalTo(@40);
}];
}
return self;
}
#pragma mark - Actions
- (void)clickAction:(UIButton *)sender {
[self dismissShareAlertView];
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickShareBtnWithIndex:)]) {
[self.delegate didClickShareBtnWithIndex:(int)sender.tag];
}
}
#pragma mark - public
- (void)showShareAlertView {
[DSKeyWindow addSubview:self];
}
- (void)dismissShareAlertView {
[self removeFromSuperview];
}
#pragma mark - lazy
- (UIView *)shareView {
if (!_shareView) {
_shareView = [UIView new];
[_shareView cornerRadius:12.0];
_shareView.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
}
return _shareView;
}
#pragma mark - others
- (UIButton *)btnWithTitle:(NSString *)title index:(int)index imgName:(NSString *)imgName superView:(UIView *)sv {
UIButton *btn = [UIButton btnWithTitle:title font:SysFont(12)];
[btn dk_setTitleColorPicker:DKColorPickerWithColors(ColorFromHex(0x777777), DSWhite, DSWhite) forState:UIControlStateNormal];
btn.tag = index;
[btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
[btn adjustLayoutWithType:UIButtonLayoutTypeUpImageBottomTitle midSpace:2 sizeToFit:YES];
[btn addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
[sv addSubview:btn];
return btn;
}
@end
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "qq_share.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "qq_share@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "qq_share@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wx_friend.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wx_friend@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wx_friend@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wx_timeline.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wx_timeline@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wx_timeline@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!