Commit ecdb3878 by ludi

网页分享统一由FUSShareToolSheetView提供,而不是之前的FUSWebShareView

parent ef54cdda
......@@ -9,7 +9,6 @@
#import "FUSWKWebViewController.h"
#import "FUSWKWebView.h"
#import "FUSWebShareView.h"
#import "FUSMainViewControllerHelper.h"
#import "FUSRechargeViewController.h"
#import "FUSExchangeDiamondViewController.h"
......@@ -64,9 +63,6 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
@interface FUSFuSiWebViewEventHelper ()
// 分享 View
@property (nonatomic, strong) FUSWebShareView *shareView;
@property (nonatomic, strong) NSMutableArray *rightBtnModelArr; //右上角按钮信息model
/// 震动的timer
......@@ -216,8 +212,6 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
消失视图上面所有的视图
*/
- (void)fus_dismissAllView{
[self.shareView fus_dismissSelf];
}
- (BOOL)fus_forwardFlutterCid:(NSInteger)cid
......@@ -1366,7 +1360,6 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
*/
- (void)fus_shareWithShareInfoDict:(NSDictionary *)shareDict
{
NSDictionary *shareContentDict = shareDict[@"shareContent"];
NSDictionary *shareTypeDict = shareDict[@"shareType"];
......@@ -1374,24 +1367,23 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
NSString *imageUrl = shareContentDict[@"pic"];
NSString *content = shareContentDict[@"text"];
NSString *webUrl = shareContentDict[@"webpage"];
// NSInteger needCode = [shareContentDict[@"whichShare"] interval];
__weak typeof(self) weakSelf = self;
[[UIApplication sharedApplication].keyWindow addSubview:self.shareView];
// if (needCode == 1) {
// _shareView = [[FUSWebShareView alloc] initWithFrame:CGRectMake(0, 0, UIView.fus_screenW, UIView.fus_screenH) from:FUSFromInvitShare];
// [self.shareView fus_showShareViewWithViewController:self.wkVC title:title content:content imageOrUrl:imageUrl shareUrl:webUrl from:FUSFromInvitShare roomId:nil shareTypeInfo:shareTypeDict success:nil failure:nil];
// }else{
// _shareView = [[FUSWebShareView alloc] initWithFrame:CGRectMake(0, 0, UIView.fus_screenW, UIView.fus_screenH) from:FUSFromTopic];
// [self.shareView fus_showShareViewWithViewController:self.wkVC title:title content:content imageOrUrl:imageUrl shareUrl:webUrl from:FUSFromTopic roomId:nil shareTypeInfo:shareTypeDict success:nil failure:nil];
// }
[self.shareView fus_showShareViewWithViewController:self.wkVC title:title content:content imageOrUrl:imageUrl shareUrl:webUrl from:FUSFromTopic roomId:nil shareTypeInfo:shareTypeDict success:nil failure:nil];
_shareView.dismissWhenClick = NO;
[_shareView setDismissHandler:^{
weakSelf.shareView = nil;
}];
/// 邀请分享页面沿用邀请来源,其余 H5 分享统一按网页来源处理。
FUSFrom shareFrom = FUSFromTopic;
if ([self.wkVC isKindOfClass:[FUSWKWebViewController class]]) {
FUSFrom currentFrom = ((FUSWKWebViewController *)self.wkVC).from;
shareFrom = currentFrom == FUSFromInvitShare ? currentFrom : FUSFromTopic;
}
[FUSRouter.liveRouter fus_showShareViewWithShowOn:self.wkVC.view
viewController:self.wkVC
title:title
content:content
imageOrUrl:imageUrl
shareUrl:webUrl
from:shareFrom
roomId:nil
shareTypeInfo:shareTypeDict
success:nil
failure:nil];
}
......@@ -1451,8 +1443,17 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
// 分享 Action
- (void)onClickShareBtn:(UIButton *)sender
{
[[UIApplication sharedApplication].keyWindow addSubview:self.shareView];
[self.shareView fus_showShareViewWithViewController:self.wkVC title:self.wkVC.title content:nil imageOrUrl:nil shareUrl:self.webview.webUrlString from:FUSFromTopic roomId:nil shareTypeInfo:nil success:nil failure:nil];
[FUSRouter.liveRouter fus_showShareViewWithShowOn:self.wkVC.view
viewController:self.wkVC
title:self.wkVC.title
content:nil
imageOrUrl:nil
shareUrl:self.webview.webUrlString
from:FUSFromTopic
roomId:nil
shareTypeInfo:nil
success:nil
failure:nil];
}
/**
......@@ -1482,18 +1483,6 @@ NSString * const kEVENT_RECHARGE_FIRST_RECHARGE_WINDOW_RECEIVE_OFFICIAL_RECAHARG
[[UIViewController fus_topViewController].navigationController pushViewController:webVC animated:YES];
}
#pragma mark - getter
- (FUSWebShareView *)shareView{
if (!_shareView) {
if ([self.wkVC isKindOfClass:[FUSWKWebViewController class]]) {
_shareView = [[FUSWebShareView alloc] initWithFrame:CGRectMake(0, 0, UIView.fus_screenW, UIView.fus_screenH) from:((FUSWKWebViewController *)self.wkVC).from];
} else {
_shareView = [[FUSWebShareView alloc] initWithFrame:CGRectMake(0, 0, UIView.fus_screenW, UIView.fus_screenH) from:FUSFromOther];
}
}
return _shareView;
}
- (BOOL)isLiving {
return FUSConfig.sharedInstanced.liveConfigs.isInRoom;
}
......
......@@ -483,6 +483,8 @@ extension SocialSharePlatform {
return .com_ImageNamed("Share_Live_whatsapp")
case .FriendChatShare:
return .com_ImageNamed("Share_icon_chat")
case .BarcodePhotoPlatform:
return .com_ImageNamed("Share_Live_barcode")
default:
return .init()
}
......@@ -533,6 +535,8 @@ extension SocialSharePlatform {
return "Instagram"
case .MessengerPlatform:
return "Messenger"
case .BarcodePhotoPlatform:
return .fus_versionLocalString("二维码")
default:
return ""
}
......
......@@ -158,6 +158,31 @@ NS_ASSUME_NONNULL_BEGIN
-(void)fus_showShareViewWithShowOn:(UIView *)showOnView
shareHandler:(void(^)(SocialSharePlatform type))shareHandler;
/// 展示分享面板并执行分享链路。
/// - Parameters:
/// - showOnView: 分享面板承载视图,传 nil 时使用当前顶层页面视图
/// - viewController: 当前分享控制器
/// - title: 分享标题
/// - content: 分享内容
/// - imageOrUrl: 分享图片或图片地址
/// - shareUrl: 分享链接
/// - from: 分享来源,用于分配分享平台
/// - roomId: 包房 ID
/// - shareTypeInfo: H5 下发的分享类型映射
/// - success: 分享成功回调
/// - failure: 分享失败回调
- (void)fus_showShareViewWithShowOn:(UIView * _Nullable)showOnView
viewController:(UIViewController * _Nullable)viewController
title:(NSString * _Nullable)title
content:(NSString * _Nullable)content
imageOrUrl:(id _Nullable)imageOrUrl
shareUrl:(NSString * _Nullable)shareUrl
from:(FUSFrom)from
roomId:(NSString * _Nullable)roomId
shareTypeInfo:(NSDictionary * _Nullable)shareTypeInfo
success:(void(^_Nullable)(void))success
failure:(void(^_Nullable)(void))failure;
/// 跳转到直播记录页面
/// - Parameter turnTo: 需要显示哪一天的日期的时间戳,负数则不跳
-(void)fus_showLiveRecordsControllerWithTurnToTimeInterval:(NSTimeInterval)turnTo;
......
......@@ -11,11 +11,18 @@ var isShowShareToolSheetView = true
@objcMembers public class FUSShareToolSheetView: FUSBaseView {
/// 创建
/// 创建默认直播间分享面板。
@objc static public func fus_showShareView(showOn: UIView?, shareHandler: ((SocialSharePlatform) -> Void)?) -> Void {
fus_showShareView(showOn: showOn, from: FUSFrom(rawValue: 2) ?? .init(rawValue: 0)!, shareHandler: shareHandler)
}
/// 创建指定来源的分享面板。
@objc static public func fus_showShareView(showOn: UIView?, from: FUSFrom, shareHandler: ((SocialSharePlatform) -> Void)?) -> Void {
guard let showOnView = ((showOn != nil) ? showOn : UIViewController.fus_top()?.view) else { return }
let view = FUSShareToolSheetView(frame: showOnView.bounds)
view.shareFrom = from
view.fus_updateSharePlatforms()
view.shareClickAction = shareHandler
view.fus_showAlert(on: showOnView, animated: true)
}
......@@ -24,6 +31,9 @@ var isShowShareToolSheetView = true
private let shareSubViewHeight: CGFloat = 88.0
/// 分享来源,用于分配不同的分享平台。
private var shareFrom: FUSFrom = FUSFrom(rawValue: 2) ?? .init(rawValue: 0)!
let bgView = UIView()
private let topBgView = UIView()
......@@ -53,18 +63,39 @@ var isShowShareToolSheetView = true
public override func makeUI() {
super.makeUI()
topShareArr = [.CopyLink, .FriendChatShare]
bottomShareArr = [.FacebookPlatform/*, .TwitterPlatform*/, .LineSharePlatform, .WhatsAppPlatform/*, .WechatFriendPlatform, .WechatCirclePaltform*/]
fus_updateSharePlatforms()
self.frame = UIView.fus_screenFrame()
self.fus_setUpUI()
}
/// 根据分享来源刷新平台分配。
private func fus_updateSharePlatforms() {
let platformTuple = fus_sharePlatforms(from: shareFrom)
topShareArr = platformTuple.top
bottomShareArr = platformTuple.bottom
if topShareView.superview != nil {
fus_setUpData()
}
}
/// 根据不同入口返回顶部和底部平台列表。
private func fus_sharePlatforms(from: FUSFrom) -> (top: [SocialSharePlatform], bottom: [SocialSharePlatform]) {
switch from.rawValue {
case 9:
return ([.CopyLink, .BarcodePhotoPlatform], [.FacebookPlatform, .LineSharePlatform, .WhatsAppPlatform])
case 2, 3, 4:
return ([.CopyLink, .FriendChatShare], [.FacebookPlatform, .LineSharePlatform, .WhatsAppPlatform])
default:
return ([.CopyLink], [.FacebookPlatform, .LineSharePlatform, .WhatsAppPlatform])
}
}
private func fus_setUpData() {
var topArr: [FUSShareToolSheetViewCellModel] = []
var bottomArr: [FUSShareToolSheetViewCellModel] = []
for (_, target) in topShareArr.enumerated() {
let model = FUSShareToolSheetViewCellModel(image: target.shareIcon!, title: target.shareName) {[weak self] in
let model = FUSShareToolSheetViewCellModel(image: target.shareIcon ?? UIImage(), title: target.shareName) {[weak self] in
guard let self = self else {
return
}
......@@ -77,7 +108,7 @@ var isShowShareToolSheetView = true
}
for (_, target) in bottomShareArr.enumerated() {
let model = FUSShareToolSheetViewCellModel(image: target.shareIcon!, title: target.shareName) {[weak self] in
let model = FUSShareToolSheetViewCellModel(image: target.shareIcon ?? UIImage(), title: target.shareName) {[weak self] in
guard let self = self else {
return
}
......
......@@ -29,6 +29,7 @@
#import <FUSCommon/FUSCustomizedInfosStore.h>
#import "FUSLiveThemeModel+FUSRequest.h"
#import "FUSSocialShareHelper.h"
@implementation FUSShowRoomRouter
......@@ -548,6 +549,41 @@
[FUSShareToolSheetView fus_showShareViewWithShowOn:showOnView shareHandler:shareHandler];
}
- (void)fus_showShareViewWithShowOn:(UIView * _Nullable)showOnView
viewController:(UIViewController * _Nullable)viewController
title:(NSString * _Nullable)title
content:(NSString * _Nullable)content
imageOrUrl:(id _Nullable)imageOrUrl
shareUrl:(NSString * _Nullable)shareUrl
from:(FUSFrom)from
roomId:(NSString * _Nullable)roomId
shareTypeInfo:(NSDictionary * _Nullable)shareTypeInfo
success:(void (^ _Nullable)(void))success
failure:(void (^ _Nullable)(void))failure {
/// 分享面板优先展示在当前页面,缺失时回退到顶层页面。
UIViewController *targetViewController = viewController ?: [UIViewController fus_topViewController];
UIView *targetShowOnView = showOnView ?: targetViewController.view;
if (targetShowOnView == nil) {
return;
}
[FUSShareToolSheetView fus_showShareViewWithShowOn:targetShowOnView from:from shareHandler:^(SocialSharePlatform type) {
/// 根据 H5 配置决定当前平台的分享类型。
FUSShareType shareType = [self fus_shareTypeWithPlatform:type shareTypeInfo:shareTypeInfo];
[FUSSocialShareHelper fus_shareWithSocialPlatform:type
title:title
content:content
imageOrUrl:imageOrUrl
shareUrl:shareUrl
from:from
viewController:targetViewController
roomId:roomId
shareType:shareType
success:success
failure:failure];
}];
}
- (void)fus_showLiveRecordsControllerWithTurnToTimeInterval:(NSTimeInterval)turnTo{
FUSLiveRecordsController *vc = [[FUSLiveRecordsController alloc] init];
vc.turnToLiveScoreTime = turnTo;
......@@ -733,6 +769,52 @@
[FUSLiveHelper fus_minimizeLiveCompletion:completion];
}
#pragma mark - Share
- (FUSShareType)fus_shareTypeWithPlatform:(SocialSharePlatform)platform
shareTypeInfo:(NSDictionary * _Nullable)shareTypeInfo {
NSString *shareTypeKey = nil;
switch (platform) {
case FacebookPlatform:
shareTypeKey = @"facebook";
break;
case TwitterPlatform:
shareTypeKey = @"twitter";
break;
case WhatsAppPlatform:
shareTypeKey = @"whatApp";
break;
case WechatFriendPlatform:
shareTypeKey = @"wechat";
break;
case WechatCirclePaltform:
shareTypeKey = @"wechat_moment";
break;
case LineSharePlatform:
shareTypeKey = @"line";
break;
default:
break;
}
if (shareTypeKey.length <= 0) {
return FUSShareTypeDefault;
}
return [self fus_shareTypeFromH5ShareStr:[shareTypeInfo[shareTypeKey] description]];
}
- (FUSShareType)fus_shareTypeFromH5ShareStr:(NSString * _Nullable)shareStr {
if ([shareStr isEqualToString:@"1"]) {
return FUSShareTypeImage;
}
if ([shareStr isEqualToString:@"2"]) {
return FUSShareTypeText;
}
if ([shareStr isEqualToString:@"3"]) {
return FUSShareTypeWebUrl;
}
return FUSShareTypeDefault;
}
#pragma mark - Private
// 注销登录用户
- (void)cancellationLoginUser:(NSNotification *)notification {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment