邀请保存图片

This commit is contained in:
liyuhua
2024-03-14 16:52:41 +08:00
parent 09ba817622
commit 5554197b7c
30 changed files with 469 additions and 15 deletions

View File

@@ -403,6 +403,7 @@
23E9EB312A85E5D100B792F2 /* pi_app_logo_new_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E9EB302A85E5D100B792F2 /* pi_app_logo_new_bg.png */; }; 23E9EB312A85E5D100B792F2 /* pi_app_logo_new_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E9EB302A85E5D100B792F2 /* pi_app_logo_new_bg.png */; };
23E9EB332A85E97C00B792F2 /* pi_login_new_logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E9EB322A85E97B00B792F2 /* pi_login_new_logo.png */; }; 23E9EB332A85E97C00B792F2 /* pi_login_new_logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 23E9EB322A85E97B00B792F2 /* pi_login_new_logo.png */; };
23EE96F22B9FF6BE00475D69 /* pi_crazy_zoo.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23EE96F12B9FF6BE00475D69 /* pi_crazy_zoo.svga */; }; 23EE96F22B9FF6BE00475D69 /* pi_crazy_zoo.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23EE96F12B9FF6BE00475D69 /* pi_crazy_zoo.svga */; };
23EE970A2BA2D39C00475D69 /* PIWebViewSavePhotoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23EE97092BA2D39C00475D69 /* PIWebViewSavePhotoView.m */; };
23FF255B2AB956D50064E904 /* pi_home_new_pk.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23FF255A2AB956D50064E904 /* pi_home_new_pk.svga */; }; 23FF255B2AB956D50064E904 /* pi_home_new_pk.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23FF255A2AB956D50064E904 /* pi_home_new_pk.svga */; };
23FF25622ABAE6310064E904 /* pi_room_game_fine_love.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23FF25612ABAE6310064E904 /* pi_room_game_fine_love.svga */; }; 23FF25622ABAE6310064E904 /* pi_room_game_fine_love.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23FF25612ABAE6310064E904 /* pi_room_game_fine_love.svga */; };
23FF25652ABC3B3C0064E904 /* XPHomeGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF25642ABC3B3B0064E904 /* XPHomeGameView.m */; }; 23FF25652ABC3B3C0064E904 /* XPHomeGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF25642ABC3B3B0064E904 /* XPHomeGameView.m */; };
@@ -2260,6 +2261,8 @@
23E9EB302A85E5D100B792F2 /* pi_app_logo_new_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pi_app_logo_new_bg.png; sourceTree = "<group>"; }; 23E9EB302A85E5D100B792F2 /* pi_app_logo_new_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pi_app_logo_new_bg.png; sourceTree = "<group>"; };
23E9EB322A85E97B00B792F2 /* pi_login_new_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pi_login_new_logo.png; sourceTree = "<group>"; }; 23E9EB322A85E97B00B792F2 /* pi_login_new_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pi_login_new_logo.png; sourceTree = "<group>"; };
23EE96F12B9FF6BE00475D69 /* pi_crazy_zoo.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_crazy_zoo.svga; sourceTree = "<group>"; }; 23EE96F12B9FF6BE00475D69 /* pi_crazy_zoo.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_crazy_zoo.svga; sourceTree = "<group>"; };
23EE97082BA2D39C00475D69 /* PIWebViewSavePhotoView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIWebViewSavePhotoView.h; sourceTree = "<group>"; };
23EE97092BA2D39C00475D69 /* PIWebViewSavePhotoView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIWebViewSavePhotoView.m; sourceTree = "<group>"; };
23FF255A2AB956D50064E904 /* pi_home_new_pk.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_home_new_pk.svga; sourceTree = "<group>"; }; 23FF255A2AB956D50064E904 /* pi_home_new_pk.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_home_new_pk.svga; sourceTree = "<group>"; };
23FF25612ABAE6310064E904 /* pi_room_game_fine_love.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_room_game_fine_love.svga; sourceTree = "<group>"; }; 23FF25612ABAE6310064E904 /* pi_room_game_fine_love.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_room_game_fine_love.svga; sourceTree = "<group>"; };
23FF25632ABC3B3B0064E904 /* XPHomeGameView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPHomeGameView.h; sourceTree = "<group>"; }; 23FF25632ABC3B3B0064E904 /* XPHomeGameView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPHomeGameView.h; sourceTree = "<group>"; };
@@ -4359,6 +4362,8 @@
E80E09AC2A41336500CD2BE7 /* XPWebViewNavView.m */, E80E09AC2A41336500CD2BE7 /* XPWebViewNavView.m */,
18E7B33026F317A20064BC9B /* XPWebViewController.h */, 18E7B33026F317A20064BC9B /* XPWebViewController.h */,
18E7B33126F317A20064BC9B /* XPWebViewController.m */, 18E7B33126F317A20064BC9B /* XPWebViewController.m */,
23EE97082BA2D39C00475D69 /* PIWebViewSavePhotoView.h */,
23EE97092BA2D39C00475D69 /* PIWebViewSavePhotoView.m */,
); );
path = YMWeb; path = YMWeb;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -11275,6 +11280,7 @@
1464C5F329A4C18000AF7C94 /* XPIAPRechargeViewController.m in Sources */, 1464C5F329A4C18000AF7C94 /* XPIAPRechargeViewController.m in Sources */,
E85E7B662A4EC35A00B6D00A /* XPIncomeRecordGoldDetailsModel.m in Sources */, E85E7B662A4EC35A00B6D00A /* XPIncomeRecordGoldDetailsModel.m in Sources */,
9B2EA7CC2804245500ED17BF /* XPAnchorPKPanelUserView.m in Sources */, 9B2EA7CC2804245500ED17BF /* XPAnchorPKPanelUserView.m in Sources */,
23EE970A2BA2D39C00475D69 /* PIWebViewSavePhotoView.m in Sources */,
2331C1B42A60F32D00E1D940 /* XPCandyTreeRankTableViewCell.m in Sources */, 2331C1B42A60F32D00E1D940 /* XPCandyTreeRankTableViewCell.m in Sources */,
9B85B6DA279FDC5200A0A1AC /* XPUserCardSkillCollectionViewCell.m in Sources */, 9B85B6DA279FDC5200A0A1AC /* XPUserCardSkillCollectionViewCell.m in Sources */,
E85E7B0D2A4EB0D200B6D00A /* GuildSuperAdminInfoModel.m in Sources */, E85E7B0D2A4EB0D200B6D00A /* GuildSuperAdminInfoModel.m in Sources */,

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pi_webView_code_bottom@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pi_webView_code_bottom@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pi_webView_code_btn_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pi_webView_code_btn_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pi_webView_code_code_text@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pi_webView_code_code_text@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pi_webView_code_top@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pi_webView_code_top@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pi_webView_code_top_text@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pi_webView_code_top_text@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "share_save_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "share_save_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -26,6 +26,8 @@ typedef enum : NSUInteger {
XPShareItemTagCopyLink, XPShareItemTagCopyLink,
///应用好友 ///应用好友
XPShareItemTagAppFriends, XPShareItemTagAppFriends,
///保存到相册
XPShareItemTagAppSaveAlbum,
} XPShareItemTag; } XPShareItemTag;
@interface XPShareItem : NSObject @interface XPShareItem : NSObject

View File

@@ -12,6 +12,8 @@
@class XPShareView; @class XPShareView;
@protocol XCShareViewDelegate <NSObject> @protocol XCShareViewDelegate <NSObject>
///点击保存图片到相册
- (void)shareView:(XPShareView *)shareView savePhoto:(XPShareInfoModel *)shareInfo;
///点了取消分享 ///点了取消分享
- (void)shareViewDidClickCancel:(XPShareView *)shareView; - (void)shareViewDidClickCancel:(XPShareView *)shareView;
///分享成功 ///分享成功

View File

@@ -143,6 +143,13 @@
[TTPopup dismiss]; [TTPopup dismiss];
return; return;
}; };
if (item.type == XPShareItemTagAppSaveAlbum){
[TTPopup dismiss];
if (self.delegate && [self.delegate respondsToSelector:@selector(shareView:savePhoto:)]){
[self.delegate shareView:self savePhoto:self.shareInfo];
}
return;
}
if (item.type == XPShareItemTagAppFriends) { if (item.type == XPShareItemTagAppFriends) {
[TTPopup dismiss]; [TTPopup dismiss];
XPMineShareViewController * shareVC = [[XPMineShareViewController alloc] init]; XPMineShareViewController * shareVC = [[XPMineShareViewController alloc] init];
@@ -187,17 +194,10 @@
if (self.delegate && [self.delegate respondsToSelector:@selector(shareView:didSuccess:)]) { if (self.delegate && [self.delegate respondsToSelector:@selector(shareView:didSuccess:)]) {
[self.delegate shareView:self didSuccess:self.shareInfo]; [self.delegate shareView:self didSuccess:self.shareInfo];
} }
return;
// FBtype = PlatformOfLine;
// [shareParams SSDKSetupLineParamsByText:encodedUrl image:nil type:SSDKContentTypeAuto];
} else {
title = YMLocalizedString(@"XPShareView3");
platformType = SSDKPlatformTypeFacebook;
FBtype = PlatformOfFB;
content = YMLocalizedString(@"XPShareView4");
[shareParams SSDKSetupFacebookParamsByText:title image:@"https://pic.lecheng163.com/ananLogo256.png" url:[NSURL URLWithString:urlString] urlTitle:@"title" urlName:@"name" attachementUrl:nil hashtag:@"#Piko" quote:@"Piko" shareType:SSDKFacebookShareTypeNative type:SSDKContentTypeWebPage];
} }
if(item.type == XPShareItemTagFaceBook){ if(item.type == XPShareItemTagFaceBook){
FBSDKShareLinkContent*linkContent = [[FBSDKShareLinkContent alloc]init]; FBSDKShareLinkContent*linkContent = [[FBSDKShareLinkContent alloc]init];
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]; urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
linkContent.contentURL= [NSURL URLWithString:urlString]; linkContent.contentURL= [NSURL URLWithString:urlString];

View File

@@ -52,5 +52,5 @@ typedef NS_ENUM(NSUInteger, GradientType) {
-(UIImage *)compressWithMaxLength:(NSUInteger)maxLength; -(UIImage *)compressWithMaxLength:(NSUInteger)maxLength;
- (UIImage *)roundedImageWithCornerRadius:(CGFloat)cornerRadius size:(CGSize)size; - (UIImage *)roundedImageWithCornerRadius:(CGFloat)cornerRadius size:(CGSize)size;
+(UIImage *)getImageFromView:(UIView *)view;
@end @end

View File

@@ -432,4 +432,23 @@
UIGraphicsEndImageContext(); UIGraphicsEndImageContext();
return roundedImage; return roundedImage;
} }
+(UIImage *)getImageFromView:(UIView *)view {
// 1. viewbounds
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
// 2.
CGContextRef context = UIGraphicsGetCurrentContext();
// 3. view
[view.layer renderInContext:context];
// 4.
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
// 5.
UIGraphicsEndImageContext();
// 6.
return image;
}
@end @end

View File

@@ -0,0 +1,18 @@
//
// PIWebViewSavePhotoView.h
// YuMi
//
// Created by duoban on 2024/3/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface PIWebViewSavePhotoView : UIView
@property(nonatomic,copy) NSString *text;
@property(nonatomic,copy) UIImage *image;
@property(nonatomic,copy) NSString *code;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,179 @@
//
// PIWebViewSavePhotoView.m
// YuMi
//
// Created by duoban on 2024/3/14.
//
#import "PIWebViewSavePhotoView.h"
@interface PIWebViewSavePhotoView()
@property(nonatomic,strong) UIImageView *topView;
@property(nonatomic,strong) UIImageView *bottomView;
@property(nonatomic,strong) UIImageView *topTextImageView;
@property(nonatomic,strong) UIView *bgCodeView;
@property(nonatomic,strong) UIImageView *bgCodeText;
@property(nonatomic,strong) UILabel *codeText;
@property(nonatomic,strong) NetImageView *codeView;
@property(nonatomic,strong) UILabel *tipView;
@property(nonatomic,strong) UIButton *codeBtn;
@end
@implementation PIWebViewSavePhotoView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
[self addSubview:self.topView];
[self addSubview:self.bottomView];
[self addSubview:self.topTextImageView];
[self addSubview:self.bgCodeView];
[self.bgCodeView addSubview:self.bgCodeText];
[self.bgCodeText addSubview:self.codeText];
[self.bgCodeView addSubview:self.codeView];
[self.bgCodeView addSubview:self.tipView];
[self.bgCodeView addSubview:self.codeBtn];
}
-(void)installConstraints{
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(326));
}];
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self);
make.top.mas_equalTo(kGetScaleWidth(303));
make.height.mas_equalTo(kGetScaleWidth(509));
}];
[self.topTextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(132));
make.width.mas_equalTo(kGetScaleWidth(297));
make.height.mas_equalTo(kGetScaleWidth(32.5));
make.centerX.equalTo(self);
}];
[self.bgCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(345));
make.height.mas_equalTo(kGetScaleWidth(431));
make.top.equalTo(self.topTextImageView.mas_bottom).mas_offset(kGetScaleWidth(186.5));
make.centerX.equalTo(self);
}];
[self.bgCodeText mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.centerX.equalTo(self.bgCodeView);
make.width.mas_equalTo(kGetScaleWidth(290));
make.height.mas_equalTo(kGetScaleWidth(43));
}];
[self.codeText mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(3));
make.bottom.mas_equalTo(-kGetScaleWidth(3));
make.leading.trailing.equalTo(self.bgCodeText).inset(kGetScaleWidth(10));
}];
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(200));
make.centerX.equalTo(self.bgCodeView);
make.top.mas_equalTo(kGetScaleWidth(96));
}];
[self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(321));
make.height.mas_equalTo(kGetScaleWidth(14));
make.centerX.equalTo(self.bgCodeView);
}];
[self.codeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(355));
make.width.mas_equalTo(kGetScaleWidth(241));
make.height.mas_equalTo(kGetScaleWidth(46));
make.centerX.equalTo(self.bgCodeView);
}];
}
-(void)setText:(NSString *)text{
_text = text;
_codeText.text = text;
}
-(void)setImage:(UIImage *)image{
_image = image;
_codeView.image = _image;
}
- (void)setCode:(NSString *)code{
_code = code;
NSString *text = [NSString stringWithFormat:@"%@%@",YMLocalizedString(@"PIWebViewSavePhotoView1"),_code];
[_codeBtn setTitle:text forState:UIControlStateNormal];
}
#pragma mark -
- (UIImageView *)topView{
if(!_topView){
_topView = [UIImageView new];
_topView.image = kImage(@"pi_webView_code_top");
}
return _topView;
}
- (UIImageView *)bottomView{
if(!_bottomView){
_bottomView = [UIImageView new];
_bottomView.image = kImage(@"pi_webView_code_bottom");
}
return _bottomView;
}
- (UIImageView *)topTextImageView{
if(!_topTextImageView){
_topTextImageView = [UIImageView new];
_topTextImageView.image = kImage(@"pi_webView_code_top_text");
}
return _topTextImageView;
}
- (UIImageView *)bgCodeText{
if(!_bgCodeText){
_bgCodeText = [UIImageView new];
_bgCodeText.image = kImage(@"pi_webView_code_code_text");
}
return _bgCodeText;
}
- (UIView *)bgCodeView{
if(!_bgCodeView){
_bgCodeView = [UIView new];
_bgCodeView.layer.cornerRadius = kGetScaleWidth(20);
_bgCodeView.layer.masksToBounds = YES;
_bgCodeView.backgroundColor = [UIColor whiteColor];
}
return _bgCodeView;
}
- (UILabel *)codeText{
if(!_codeText){
_codeText = [UILabel labelInitWithText:@"掃碼下載PiKO並填寫我的邀請碼\n立得1000钻石" font:kFontRegular(12) textColor:[UIColor whiteColor]];
_codeText.textAlignment = NSTextAlignmentCenter;
_codeText.numberOfLines = 0;
}
return _codeText;
}
- (UILabel *)tipView{
if(!_tipView){
_tipView = [UILabel labelInitWithText:YMLocalizedString(@"PIWebViewSavePhotoView0") font:kFontRegular(10) textColor:UIColorFromRGB(0x999999)];
}
return _tipView;
}
- (UIButton *)codeBtn{
if(!_codeBtn){
_codeBtn = [UIButton new];
NSString *text = [NSString stringWithFormat:@"%@GHT32",YMLocalizedString(@"PIWebViewSavePhotoView1")];
[_codeBtn setTitle:text forState:UIControlStateNormal];
_codeBtn.titleLabel.font = kFontRegular(16);
[_codeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_codeBtn setBackgroundImage:kImage(@"pi_webView_code_btn_bg") forState:UIControlStateNormal];
}
return _codeBtn;
}
- (NetImageView *)codeView{
if(!_codeView){
_codeView = [NetImageView new];
}
return _codeView;
}
@end

View File

@@ -30,6 +30,9 @@
#import "XPIAPRechargeViewController.h" #import "XPIAPRechargeViewController.h"
#import "SessionViewController.h" #import "SessionViewController.h"
#import "XPMonentTopicContainerViewController.h" #import "XPMonentTopicContainerViewController.h"
#import "PIWebViewSavePhotoView.h"
typedef NS_ENUM(NSUInteger, RightNavigationPushType){ typedef NS_ENUM(NSUInteger, RightNavigationPushType){
///h5 ///h5
RightNavigationPushType_Web = 1, RightNavigationPushType_Web = 1,
@@ -77,6 +80,9 @@ typedef NS_ENUM(NSUInteger, RightNavigationPushType){
@property (nonatomic, strong) WKUserContentController *pi_userContentController; @property (nonatomic, strong) WKUserContentController *pi_userContentController;
/// ///
@property (nonatomic,copy) NSDictionary *shareDic; @property (nonatomic,copy) NSDictionary *shareDic;
///
@property (nonatomic,copy) NSDictionary *savePhotoDic;
/// ///
@property (nonatomic,strong) XPWebViewNavView *navView; @property (nonatomic,strong) XPWebViewNavView *navView;
/// ///
@@ -103,7 +109,7 @@ NSString * const kJSOpenRoom = @"openRoom";
NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId"; NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId";
NSString * const kJSOpenChatPage = @"geToChatPage"; NSString * const kJSOpenChatPage = @"geToChatPage";
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
NSString * const kJSSavePictureShare = @"savePictureShare";
@implementation XPWebViewController @implementation XPWebViewController
@@ -129,9 +135,38 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initView]; [self initView];
}
- (void)saveImageToPhotoAlbum:(NSDictionary *)data{
[self showLoading];
NSString *qrCodeUrl = data[@"qrCodeUrl"];
NetImageView *imageView = [NetImageView new];
[imageView loadImageWithUrl:qrCodeUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
[self hideHUD];
NSString *text = data[@"text"];
NSString *invitationCode = data[@"invitationCode"];
PIWebViewSavePhotoView *saveView = [[PIWebViewSavePhotoView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
saveView.text = text;
saveView.image = image;
saveView.code = invitationCode;
UIImage *saveImage = [UIImage getImageFromView:saveView];
UIImageWriteToSavedPhotosAlbum(saveImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}];
} }
//
- (void)image: (UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
NSString *msg = YMLocalizedString(@"PIWebViewSavePhotoView2");
if(error != NULL){
msg = YMLocalizedString(@"PIWebViewSavePhotoView3");
}
[self showSuccessToast:msg];
}
- (void)initView { - (void)initView {
if (self.navigationController.viewControllers.count > 1){ if (self.navigationController.viewControllers.count > 1){
UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"common_nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick)]; UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"common_nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick)];
@@ -430,7 +465,19 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
}); });
} }
} }else if ([message.name isEqualToString:kJSSavePictureShare]){
if ([message.body isKindOfClass:[NSDictionary class]]){
NSDictionary *bodyDic = message.body;
NSString *type = bodyDic[@"type"];
if ([type isEqualToString:@"1"]){
[self saveImageToPhotoAlbum:bodyDic];
return;
}
self.savePhotoDic = bodyDic;
[self showShareSavePhote];
}
}
} }
}]; }];
} }
@@ -530,7 +577,31 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
[self.navigationController pushViewController:webVC animated:YES]; [self.navigationController pushViewController:webVC animated:YES];
} }
} }
-(void)showShareSavePhote{
if (self.savePhotoDic.allKeys.count <= 0) {
return;
}
NSDictionary * dic = self.savePhotoDic;
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
shareInfo.shareContent = dic[@"shareText"];
shareInfo.type = ShareType_H5;
shareInfo.uid = [AccountInfoStorage instance].getUid;
NSString *urlStr = ((NSString *)dic[@"toUrl"]).length > 0 ? dic[@"toUrl"] : @"";
shareInfo.shareUrl = urlStr;
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"];
XPShareItem *save = [XPShareItem itemWitTag:XPShareItemTagAppSaveAlbum title:YMLocalizedString(@"PIWebViewSavePhotoView4") imageName:@"share_save_icon" disableImageName:@"share_save_icon"];
NSArray * items = @[wechat,cycle, qq,save];
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
}
- (void)showSharePanel { - (void)showSharePanel {
if (self.shareDic.allKeys.count <= 0) { if (self.shareDic.allKeys.count <= 0) {
return; return;
@@ -554,7 +625,9 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"]; XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"]; XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"]; XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"];
NSArray * items = @[wechat,cycle, qq]; XPShareItem *save = [XPShareItem itemWitTag:XPShareItemTagAppSaveAlbum title:YMLocalizedString(@"PIWebViewSavePhotoView4") imageName:@"share_save_icon" disableImageName:@"share_save_icon"];
NSArray * items = @[wechat,cycle, qq,save];
CGFloat margin = 15; CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65); CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo]; XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
@@ -565,6 +638,9 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
} }
#pragma mark - XCShareViewDelegate #pragma mark - XCShareViewDelegate
- (void)shareView:(XPShareView *)shareView savePhoto:(XPShareInfoModel *)shareInfo{
[self saveImageToPhotoAlbum:self.savePhotoDic];
}
- (void)shareViewDidClickCancle:(XPShareView *)shareView { - (void)shareViewDidClickCancle:(XPShareView *)shareView {
[TTPopup dismiss]; [TTPopup dismiss];
} }
@@ -744,6 +820,8 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChatPage]; [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChatPage];
/// ///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat]; [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare];
} }
return _pi_userContentController; return _pi_userContentController;

View File

@@ -3184,6 +3184,12 @@
"PIGuildAnchorIncomeSectionView1"="主播(钻石)"; "PIGuildAnchorIncomeSectionView1"="主播(钻石)";
"PIGuildAnchorIncomeSectionView2"="房间(钻石)"; "PIGuildAnchorIncomeSectionView2"="房间(钻石)";
"PIGuildAnchorIncomeSectionView3"="直播时长"; "PIGuildAnchorIncomeSectionView3"="直播时长";
///PIWebViewSavePhotoView
"PIWebViewSavePhotoView0"="记得注册时填写邀请码哦~";
"PIWebViewSavePhotoView1"="邀请码:";
"PIWebViewSavePhotoView2"="保存图片成功";
"PIWebViewSavePhotoView3"="保存图片失败";
"PIWebViewSavePhotoView4"="保存邀请图片";
///不能脚本生成的 ///不能脚本生成的
"App_Common_And" = "和"; "App_Common_And" = "和";
"App_Common_Male" = "男"; "App_Common_Male" = "男";

View File

@@ -3182,6 +3182,12 @@
"PIGuildAnchorIncomeSectionView1"="主播(鉆石)"; "PIGuildAnchorIncomeSectionView1"="主播(鉆石)";
"PIGuildAnchorIncomeSectionView2"="房間(鉆石)"; "PIGuildAnchorIncomeSectionView2"="房間(鉆石)";
"PIGuildAnchorIncomeSectionView3"="直播時長"; "PIGuildAnchorIncomeSectionView3"="直播時長";
///PIWebViewSavePhotoView
"PIWebViewSavePhotoView0"="記得註冊時填寫邀請碼哦~";
"PIWebViewSavePhotoView1"="邀請碼:";
"PIWebViewSavePhotoView2"="保存圖片成功";
"PIWebViewSavePhotoView3"="保存圖片失敗";
"PIWebViewSavePhotoView4"="保存邀請圖片";
///不能腳本生成的 ///不能腳本生成的
"App_Common_And" = "和"; "App_Common_And" = "和";
"App_Common_Male" = "男"; "App_Common_Male" = "男";