Commit b7c966c7 by ludi

完成订阅im部分

parent b8ec0b09
Showing with 331 additions and 1 deletions
...@@ -34,6 +34,9 @@ public final class FUSFlutterBridge: NSObject { ...@@ -34,6 +34,9 @@ public final class FUSFlutterBridge: NSObject {
/// 当前 Flutter 页面对应的点击来源链接。 /// 当前 Flutter 页面对应的点击来源链接。
private var clickUrlInUserData = "" private var clickUrlInUserData = ""
/// 当前flutter的音频播放状态 type 0:接通电话后挂断 / online状态 1:直播间内
private var currentVideoStateType: Int = 0
private override init() { private override init() {
super.init() super.init()
...@@ -121,6 +124,7 @@ public final class FUSFlutterBridge: NSObject { ...@@ -121,6 +124,7 @@ public final class FUSFlutterBridge: NSObject {
showHeadInUserData = (notification.userInfo?["showHeadInUserData"] as? Bool) ?? false showHeadInUserData = (notification.userInfo?["showHeadInUserData"] as? Bool) ?? false
clickUrlInUserData = (notification.userInfo?["clickUrl"] as? String) ?? "" clickUrlInUserData = (notification.userInfo?["clickUrl"] as? String) ?? ""
pushUserData() pushUserData()
fus_p_setVideoState(type: self.currentVideoStateType)
} }
@objc private func handleFlutterPageDidExit(_ notification: Notification) { @objc private func handleFlutterPageDidExit(_ notification: Notification) {
...@@ -133,6 +137,21 @@ public final class FUSFlutterBridge: NSObject { ...@@ -133,6 +137,21 @@ public final class FUSFlutterBridge: NSObject {
let json = encodeJSONString(composeUserData()) let json = encodeJSONString(composeUserData())
activeChannel?.invokeMethod("getUserData", arguments: json) activeChannel?.invokeMethod("getUserData", arguments: json)
} }
/// 设置flutter音频属性
/// - Parameter type: type 0:接通电话后挂断 / 正常状态 1:直播间内
@objc public func fus_setVideoState(type: Int) {
if type == self.currentVideoStateType {
return
}
fus_p_setVideoState(type: type)
}
/// 直接设置
private func fus_p_setVideoState(type: Int) {
let json = encodeJSONString(["type": type])
activeChannel?.invokeMethod("setVideoState", arguments: json)
}
private func handle(call: FlutterMethodCall, result: @escaping FlutterResult) { private func handle(call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method { switch call.method {
......
...@@ -217,6 +217,16 @@ import SwiftyJSON ...@@ -217,6 +217,16 @@ import SwiftyJSON
set { self.todayDidClickedSevenDayCheckin.accept(newValue) } set { self.todayDidClickedSevenDayCheckin.accept(newValue) }
} }
/// 直播状态
public var liveType: BehaviorRelay<FUSLiveType> = .init(value: .none)
/// OC设置直播状态
@objc public var oc_liveType: FUSLiveType {
set { self.liveType.accept(newValue) }
get { self.liveType.value }
}
/// 是否正在打电话
public var onCallState: BehaviorRelay<Bool> = .init(value: false)
// - base // - base
public override init() { public override init() {
super.init() super.init()
...@@ -247,6 +257,21 @@ import SwiftyJSON ...@@ -247,6 +257,21 @@ import SwiftyJSON
}).disposed(by: disposeBag) }).disposed(by: disposeBag)
fus_requestGetOpenCheckIpaddr() fus_requestGetOpenCheckIpaddr()
// 处理如果改变了通话和播放状态,要传递给flutter
Observable.combineLatest(self.liveType, self.onCallState)
.subscribe(onNext: {[weak self] liveType, onCallState in
guard let self = self else { return }
if liveType == .none && onCallState == false {
// 没有在直播间中并且没有在打电话
FUSFlutterBridge.shared.fus_setVideoState(type: 0)
}
else {
FUSFlutterBridge.shared.fus_setVideoState(type: 1)
}
})
.disposed(by: disposeBag)
} }
......
...@@ -451,6 +451,8 @@ ...@@ -451,6 +451,8 @@
BED3D25D2C58D9FF0028E28F /* FUSIMChatGiftCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */; }; BED3D25D2C58D9FF0028E28F /* FUSIMChatGiftCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */; };
BED3D25E2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */; }; BED3D25E2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */; };
BED3D25F2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */; }; BED3D25F2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */; };
00A1E0012DAD000100AA0001 /* FUSIMChatSubscribeCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00A1E0032DAD000100AA0001 /* FUSIMChatSubscribeCellView.h */; };
00A1E0022DAD000100AA0001 /* FUSIMChatSubscribeCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00A1E0042DAD000100AA0001 /* FUSIMChatSubscribeCellView.m */; };
BED3D2602C58D9FF0028E28F /* FUSIMChatMessageCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */; }; BED3D2602C58D9FF0028E28F /* FUSIMChatMessageCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */; };
BED3D2612C58D9FF0028E28F /* FUSIMChatMessageCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */; }; BED3D2612C58D9FF0028E28F /* FUSIMChatMessageCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */; };
BED3D2622C58D9FF0028E28F /* FUSIMChatPhoneCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */; }; BED3D2622C58D9FF0028E28F /* FUSIMChatPhoneCellView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */; };
...@@ -1023,6 +1025,8 @@ ...@@ -1023,6 +1025,8 @@
BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatGiftCellView.m; sourceTree = "<group>"; }; BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatGiftCellView.m; sourceTree = "<group>"; };
BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatLiveRoomCellView.h; sourceTree = "<group>"; }; BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatLiveRoomCellView.h; sourceTree = "<group>"; };
BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatLiveRoomCellView.m; sourceTree = "<group>"; }; BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatLiveRoomCellView.m; sourceTree = "<group>"; };
00A1E0032DAD000100AA0001 /* FUSIMChatSubscribeCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatSubscribeCellView.h; sourceTree = "<group>"; };
00A1E0042DAD000100AA0001 /* FUSIMChatSubscribeCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatSubscribeCellView.m; sourceTree = "<group>"; };
BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatMessageCellView.h; sourceTree = "<group>"; }; BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatMessageCellView.h; sourceTree = "<group>"; };
BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatMessageCellView.m; sourceTree = "<group>"; }; BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSIMChatMessageCellView.m; sourceTree = "<group>"; };
BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatPhoneCellView.h; sourceTree = "<group>"; }; BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSIMChatPhoneCellView.h; sourceTree = "<group>"; };
...@@ -2126,6 +2130,8 @@ ...@@ -2126,6 +2130,8 @@
BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */, BED3D1332C58D9FC0028E28F /* FUSIMChatGiftCellView.m */,
BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */, BED3D1342C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.h */,
BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */, BED3D1352C58D9FC0028E28F /* FUSIMChatLiveRoomCellView.m */,
00A1E0032DAD000100AA0001 /* FUSIMChatSubscribeCellView.h */,
00A1E0042DAD000100AA0001 /* FUSIMChatSubscribeCellView.m */,
BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */, BED3D1362C58D9FC0028E28F /* FUSIMChatMessageCellView.h */,
BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */, BED3D1372C58D9FC0028E28F /* FUSIMChatMessageCellView.m */,
BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */, BED3D1382C58D9FC0028E28F /* FUSIMChatPhoneCellView.h */,
...@@ -2373,6 +2379,7 @@ ...@@ -2373,6 +2379,7 @@
BE189B712C732D570008418B /* FSRFriendgiftdictFriendsOfficialView.h in Headers */, BE189B712C732D570008418B /* FSRFriendgiftdictFriendsOfficialView.h in Headers */,
BED3D2682C58D9FF0028E28F /* FUSIMChatDetailCell.h in Headers */, BED3D2682C58D9FF0028E28F /* FUSIMChatDetailCell.h in Headers */,
BED3D25E2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.h in Headers */, BED3D25E2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.h in Headers */,
00A1E0012DAD000100AA0001 /* FUSIMChatSubscribeCellView.h in Headers */,
BED3D1A62C58D9FC0028E28F /* FUSSingleChatDataSourceHelper.h in Headers */, BED3D1A62C58D9FC0028E28F /* FUSSingleChatDataSourceHelper.h in Headers */,
BED3D19E2C58D9FC0028E28F /* FUSSingleChatViewController.h in Headers */, BED3D19E2C58D9FC0028E28F /* FUSSingleChatViewController.h in Headers */,
BED3D24D2C58D9FF0028E28F /* FUSIMChatImageCellView.h in Headers */, BED3D24D2C58D9FF0028E28F /* FUSIMChatImageCellView.h in Headers */,
...@@ -2906,6 +2913,7 @@ ...@@ -2906,6 +2913,7 @@
BE8F03B82C63B171006139E8 /* FUSZoneVideoCreditHeaderView.m in Sources */, BE8F03B82C63B171006139E8 /* FUSZoneVideoCreditHeaderView.m in Sources */,
BE189B482C732D570008418B /* FSRServiceViewController.m in Sources */, BE189B482C732D570008418B /* FSRServiceViewController.m in Sources */,
BED3D25F2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.m in Sources */, BED3D25F2C58D9FF0028E28F /* FUSIMChatLiveRoomCellView.m in Sources */,
00A1E0022DAD000100AA0001 /* FUSIMChatSubscribeCellView.m in Sources */,
00B97D952D2B7DDD00533573 /* FUSZoneVideoCreditAlertView.m in Sources */, 00B97D952D2B7DDD00533573 /* FUSZoneVideoCreditAlertView.m in Sources */,
BED3D1F52C58D9FE0028E28F /* FUSIMZhaiXinViewController.m in Sources */, BED3D1F52C58D9FE0028E28F /* FUSIMZhaiXinViewController.m in Sources */,
BED3D1AF2C58D9FD0028E28F /* FUSSingleChatSocketReciever.m in Sources */, BED3D1AF2C58D9FD0028E28F /* FUSSingleChatSocketReciever.m in Sources */,
......
...@@ -2030,6 +2030,18 @@ ...@@ -2030,6 +2030,18 @@
[FUSRouter.liveRouter fus_enterLiveRoomWithModel:roomModel]; [FUSRouter.liveRouter fus_enterLiveRoomWithModel:roomModel];
} }
break; break;
case FUSMsgContentTypeSubscribe: // 订阅消息
{
if ([NSString isNullWithString:infoModel.subscribeJumpUrl] == false) {
[FUSRouter.userRouter fus_handleTaskJumpActionWithJumpType:infoModel.subscribeJumpUrl tid:0 url:infoModel.subscribeJumpParam success:^{}];
} else if ([NSString isNullWithString:infoModel.subscribeJumpParam] == false) {
FUSWKWebViewController *webVc = [[FUSWKWebViewController alloc] init];
webVc.webUrlString = infoModel.subscribeJumpParam;
webVc.shouldIncludeIdentifyInfo = YES;
[self.targetVC.navigationController pushViewController:webVc animated:YES];
}
}
break;
case FUSMsgContentTypeGift: //礼物 case FUSMsgContentTypeGift: //礼物
{ {
if (self.giftPlayView) { if (self.giftPlayView) {
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#define liveRoomW 210 #define liveRoomW 210
#define liveRoomH (108/210.0*liveRoomW) #define liveRoomH (108/210.0*liveRoomW)
#define subscribeW liveRoomW
#define subscribeH liveRoomH
#define timeFont [UIFont fus_themeFont:11] #define timeFont [UIFont fus_themeFont:11]
...@@ -118,5 +120,7 @@ ...@@ -118,5 +120,7 @@
// 跳转直播间的消息 frame // 跳转直播间的消息 frame
@property (nonatomic, assign, readonly) CGRect liveRoomFrame; @property (nonatomic, assign, readonly) CGRect liveRoomFrame;
/// 订阅消息 frame
@property (nonatomic, assign, readonly) CGRect subscribeFrame;
@end @end
...@@ -307,6 +307,22 @@ ...@@ -307,6 +307,22 @@
}else{ }else{
_liveRoomFrame = CGRectZero; _liveRoomFrame = CGRectZero;
} }
// 订阅消息的 Frame
if (msgModel.messageContentType == FUSMsgContentTypeSubscribe) {
CGFloat subscribeFrameX = msgModel.messageDirection ? (All_MSG_PADDING * 1.5 + iconFrameW) : (UIView.fus_screenW - (All_MSG_PADDING * 1.5 + iconFrameW + subscribeW));
CGFloat subscribeFrameY = iconFrameY;
CGFloat subscribeFrameW = subscribeW;
CGFloat subscribeFrameH = subscribeH;
_subscribeFrame = CGRectMake(subscribeFrameX, subscribeFrameY, subscribeFrameW, subscribeFrameH);
if (msgModel.messageDirection == FUSMsgDirectionSend && msgModel.messageStatus != FUSMsgStateBegining) {
[self getMessageSendingStateFrameWithMessageFrame:_subscribeFrame];
}
[self getMessageMsgPaidInfoFrameWithMessageFrame:_subscribeFrame];
} else {
_subscribeFrame = CGRectZero;
}
// 礼物的Frame // 礼物的Frame
if (msgModel.messageContentType == FUSMsgContentTypeGift) { if (msgModel.messageContentType == FUSMsgContentTypeGift) {
...@@ -337,7 +353,7 @@ ...@@ -337,7 +353,7 @@
} }
//cell的最终高度 //cell的最终高度
_cellFinalHeight = MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(CGRectGetMaxY(_textBubbleBgImageFrame), CGRectGetMaxY(_voiceBgFrame)), CGRectGetMaxY(_giftsFrame)), CGRectGetMaxY(_videoConversationFrame)), CGRectGetMaxY(_voiceConversationFrame)), CGRectGetMaxY(_imageFrame)), CGRectGetMaxY(_iconFrame)), CGRectGetMaxY(_systemNoticeBgFrame)), CGRectGetMaxY(_emptyMsgFrame)),CGRectGetMaxY(_msgPaidInfoFrame)) + All_MSG_PADDING/2,CGRectGetMaxY(_videoThumbFrame)),CGRectGetMaxY(_liveRoomFrame)); _cellFinalHeight = MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(MAX(CGRectGetMaxY(_textBubbleBgImageFrame), CGRectGetMaxY(_voiceBgFrame)), CGRectGetMaxY(_giftsFrame)), CGRectGetMaxY(_videoConversationFrame)), CGRectGetMaxY(_voiceConversationFrame)), CGRectGetMaxY(_imageFrame)), CGRectGetMaxY(_iconFrame)), CGRectGetMaxY(_systemNoticeBgFrame)), CGRectGetMaxY(_emptyMsgFrame)),CGRectGetMaxY(_msgPaidInfoFrame)) + All_MSG_PADDING/2,CGRectGetMaxY(_videoThumbFrame)),CGRectGetMaxY(_liveRoomFrame)),CGRectGetMaxY(_subscribeFrame));
} }
#pragma mark 当消息发送者为自己时 计算出加载视图and感叹号and送达状态的Frame #pragma mark 当消息发送者为自己时 计算出加载视图and感叹号and送达状态的Frame
......
...@@ -41,6 +41,7 @@ typedef NS_ENUM(NSInteger,FUSMsgContentType){ ...@@ -41,6 +41,7 @@ typedef NS_ENUM(NSInteger,FUSMsgContentType){
FUSMsgContentTypeGift, // 礼物消息 FUSMsgContentTypeGift, // 礼物消息
FUSMsgContentTypeSystemNotice, // 系统提示消息 FUSMsgContentTypeSystemNotice, // 系统提示消息
FUSMsgContentTypeLiveRoom, // 进入直播间消息 FUSMsgContentTypeLiveRoom, // 进入直播间消息
FUSMsgContentTypeSubscribe, // 订阅消息
FUSMsgContentTypeEmpty // 空白消息(用来预加载即将发送的文件) FUSMsgContentTypeEmpty // 空白消息(用来预加载即将发送的文件)
}; };
...@@ -313,4 +314,16 @@ typedef NS_ENUM(NSInteger,FUSSystemNoticeType){ ...@@ -313,4 +314,16 @@ typedef NS_ENUM(NSInteger,FUSSystemNoticeType){
@property (nonatomic, copy) NSString *iconUrl; @property (nonatomic, copy) NSString *iconUrl;
@property (nonatomic, copy) NSString *liveRoomPassword; @property (nonatomic, copy) NSString *liveRoomPassword;
#pragma mark - FUSMsgContentTypeSubscribe
/// 订阅消息标题
@property (nonatomic, copy) NSString *subscribeTitle;
/// 订阅消息内容
@property (nonatomic, copy) NSString *subscribeDetail;
/// 订阅消息封面
@property (nonatomic, copy) NSString *subscribeIconUrl;
/// 订阅消息点击跳转指令
@property (nonatomic, copy) NSString *subscribeJumpUrl;
/// 订阅消息点击跳转参数
@property (nonatomic, copy) NSString *subscribeJumpParam;
@end @end
...@@ -887,8 +887,10 @@ import SwiftyJSON ...@@ -887,8 +887,10 @@ import SwiftyJSON
if state == .idle || if state == .idle ||
state == .end{ state == .end{
UIApplication.shared.isIdleTimerDisabled = false UIApplication.shared.isIdleTimerDisabled = false
FUSSwiftCacheDataShare.share.onCallState.accept(false)
}else { }else {
UIApplication.shared.isIdleTimerDisabled = true UIApplication.shared.isIdleTimerDisabled = true
FUSSwiftCacheDataShare.share.onCallState.accept(true)
} }
}).disposed(by: disposeBag) }).disposed(by: disposeBag)
} }
......
...@@ -298,6 +298,8 @@ extension AnyHashable { ...@@ -298,6 +298,8 @@ extension AnyHashable {
static let wordsEffect = "cmd_msg_effect_info" static let wordsEffect = "cmd_msg_effect_info"
/// 分享动态信息 /// 分享动态信息
static let dynamicShareInfo = "cmd_moment_detail" static let dynamicShareInfo = "cmd_moment_detail"
/// 订阅消息信息
static let subscribeInfo = "cmd_msg_dynamic_sub"
} }
struct CallSocketCID { struct CallSocketCID {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#import "FUSIMChatAudioManager.h" #import "FUSIMChatAudioManager.h"
#import "FUSIMChatLiveRoomCellView.h" #import "FUSIMChatLiveRoomCellView.h"
#import "FUSIMChatSubscribeCellView.h"
//长按选中一条消息的上标MenuItem(复制,删除) //长按选中一条消息的上标MenuItem(复制,删除)
typedef NS_ENUM(NSInteger, FUSMenuItemType){ typedef NS_ENUM(NSInteger, FUSMenuItemType){
...@@ -128,4 +129,12 @@ typedef NS_ENUM(NSInteger, FUSTouchType){ ...@@ -128,4 +129,12 @@ typedef NS_ENUM(NSInteger, FUSTouchType){
*/ */
- (void)fus_addLiveRoomClickEventToRoomView:(FUSIMChatLiveRoomCellView *)roomView withModel:(FUSChatDetailFrameModel *)model; - (void)fus_addLiveRoomClickEventToRoomView:(FUSIMChatLiveRoomCellView *)roomView withModel:(FUSChatDetailFrameModel *)model;
/**
添加订阅消息点击事件
@param subscribeView 订阅消息卡片
@param model 数据源 model
*/
- (void)fus_addSubscribeClickEventToSubscribeView:(FUSIMChatSubscribeCellView *)subscribeView withModel:(FUSChatDetailFrameModel *)model;
@end @end
...@@ -198,6 +198,15 @@ ...@@ -198,6 +198,15 @@
[_clickBtn addTarget:self action:@selector(cellMessageClickEvent) forControlEvents:UIControlEventTouchUpInside]; [_clickBtn addTarget:self action:@selector(cellMessageClickEvent) forControlEvents:UIControlEventTouchUpInside];
} }
- (void)fus_addSubscribeClickEventToSubscribeView:(FUSIMChatSubscribeCellView *)subscribeView withModel:(FUSChatDetailFrameModel *)model{
_msgModel = model.msgModel;
_frameModel = model;
_clickBtn = subscribeView.clickBtn;
[self addCellMenuItemBlock];
[_clickBtn addTarget:self action:@selector(cellMessageClickEvent) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - call delegate #pragma mark - call delegate
/** /**
点击和长按cell,调用代理(不包括文字消息里富文本的点击) 点击和长按cell,调用代理(不包括文字消息里富文本的点击)
......
...@@ -66,10 +66,34 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) { ...@@ -66,10 +66,34 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) {
FUSIMChatMessageTypeVideoChat = 5, FUSIMChatMessageTypeVideoChat = 5,
FUSIMChatMessageTypeSystemTip = 6, FUSIMChatMessageTypeSystemTip = 6,
FUSIMChatMessageTypeLiveRoomShare = 8, FUSIMChatMessageTypeLiveRoomShare = 8,
FUSIMChatMessageTypeSubscribeContentUpdate = 12,
FUSIMChatMessageTypeSubscribeStatusChanged = 13,
FUSIMChatMessageTypeSubscribePriceChanged = 14,
}; };
#define kmessageTypeToStr(type) [NSString stringWithFormat:@"%ld",type] #define kmessageTypeToStr(type) [NSString stringWithFormat:@"%ld",type]
/// 解析订阅消息扩展数据,兼容字符串和字典两种格式
static NSDictionary *fus_subscribeMessageInfo(NSDictionary *extraDict) {
NSDictionary *infoDict = extraDict[@"cmd_msg_dynamic_sub"];
if ([infoDict isKindOfClass:[NSString class]]) {
infoDict = [(NSString *)infoDict converToDictionary];
}
return [infoDict isKindOfClass:NSDictionary.class] ? infoDict : @{};
}
/// 规范化订阅消息文案,处理服务端透传的 `<br>`
static NSString *fus_subscribeDisplayText(NSString *text) {
if ([NSString isNull:text]) {
return @"";
}
NSString *displayText = [text description];
displayText = [displayText stringByReplacingOccurrencesOfString:@"<br>" withString:@"\n"];
displayText = [displayText stringByReplacingOccurrencesOfString:@"<br/>" withString:@"\n"];
displayText = [displayText stringByReplacingOccurrencesOfString:@"<br />" withString:@"\n"];
return displayText;
}
@interface FUSIMChatService ()<EMChatManagerDelegate, EMClientDelegate> @interface FUSIMChatService ()<EMChatManagerDelegate, EMClientDelegate>
/** /**
...@@ -426,6 +450,15 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) { ...@@ -426,6 +450,15 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) {
skeletonizeMsg = [NSString stringWithFormat:@"[%@]",[NSString fus_localString:@"直播间分享"]]; skeletonizeMsg = [NSString stringWithFormat:@"[%@]",[NSString fus_localString:@"直播间分享"]];
} }
break; break;
case FUSIMChatMessageTypeSubscribeContentUpdate: // 订阅内容更新
case FUSIMChatMessageTypeSubscribeStatusChanged: // 成功订阅/取消订阅
case FUSIMChatMessageTypeSubscribePriceChanged: // 订阅费用变更
{
NSDictionary *subscribeInfo = fus_subscribeMessageInfo(msg.ext);
NSString *subscribeTitle = [NSString isNull:subscribeInfo[@"showtit"]] ? [NSString fus_versionLocalString:@"订阅消息"] : [subscribeInfo[@"showtit"] description];
skeletonizeMsg = [NSString stringWithFormat:@"[%@]", subscribeTitle];
}
break;
default: default:
break; break;
} }
...@@ -1384,6 +1417,19 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) { ...@@ -1384,6 +1417,19 @@ typedef NS_ENUM(NSInteger, FUSIMChatMessageType) {
msgModel.liveRoomPassword = infoDict[@"password"]; msgModel.liveRoomPassword = infoDict[@"password"];
} }
break; break;
case FUSIMChatMessageTypeSubscribeContentUpdate: // 订阅内容更新
case FUSIMChatMessageTypeSubscribeStatusChanged: // 成功订阅/取消订阅
case FUSIMChatMessageTypeSubscribePriceChanged: // 订阅费用变更
{
NSDictionary *infoDict = fus_subscribeMessageInfo(extraDict);
msgModel.messageContentType = FUSMsgContentTypeSubscribe;
msgModel.subscribeTitle = [NSString isNull:infoDict[@"showtit"]] ? @"" : [infoDict[@"showtit"] description];
msgModel.subscribeDetail = fus_subscribeDisplayText(infoDict[@"showtxt"]);
msgModel.subscribeIconUrl = [NSString isNull:infoDict[@"showimg"]] ? @"" : [infoDict[@"showimg"] description];
msgModel.subscribeJumpUrl = [NSString isNull:infoDict[@"jumpurl"]] ? @"" : [infoDict[@"jumpurl"] description];
msgModel.subscribeJumpParam = [NSString isNull:infoDict[@"jumpparam"]] ? @"" : [infoDict[@"jumpparam"] description];
}
break;
default: default:
break; break;
} }
......
...@@ -100,6 +100,10 @@ ...@@ -100,6 +100,10 @@
self.frame = frameModel.liveRoomFrame; self.frame = frameModel.liveRoomFrame;
} }
break; break;
case FUSMsgContentTypeSubscribe: {
self.frame = frameModel.subscribeFrame;
}
break;
default: default:
break; break;
} }
......
#import <UIKit/UIKit.h>
#import "FUSIMChatCellBaseView.h"
#import "FUSIMChatCellCoverButton.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUSIMChatSubscribeCellView : FUSIMChatCellBaseView
/// 订阅消息卡片的点击按钮
@property (nonatomic, strong) FUSIMChatCellCoverButton *clickBtn;
@end
NS_ASSUME_NONNULL_END
#import "FUSIMChatSubscribeCellView.h"
#define title_font [UIFont systemFontOfSize:15 weight:UIFontWeightBold]
#define detail_font [UIFont systemFontOfSize:13 weight:UIFontWeightRegular]
#define icon_W 36
@interface FUSIMChatSubscribeCellView ()
/// 分割线
@property (nonatomic, strong) UIView *lineView;
/// 订阅封面
@property (nonatomic, strong) UIImageView *subscribeIconImageView;
/// 订阅标题
@property (nonatomic, strong) UILabel *subscribeTitleLabel;
/// 订阅内容
@property (nonatomic, strong) UILabel *subscribeDetailLabel;
/// 底部分割线
@property (nonatomic, strong) UILabel *separatorLine;
/// 底部提示文案
@property (nonatomic, strong) UILabel *tipsLabel;
/// 右侧箭头
@property (nonatomic, strong) UIImageView *arrowImageView;
@end
@implementation FUSIMChatSubscribeCellView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_subscribeIconImageView = [[UIImageView alloc] init];
_subscribeIconImageView.contentMode = UIViewContentModeScaleAspectFill;
_subscribeIconImageView.layer.cornerRadius = 4.0;
_subscribeIconImageView.clipsToBounds = YES;
_subscribeTitleLabel = [[UILabel alloc] init];
_subscribeTitleLabel.textColor = [UIColor fus_textColorRich];
_subscribeTitleLabel.font = title_font;
_arrowImageView = [[UIImageView alloc] initWithImage:UIImage.fus_rightArrowIcon];
_lineView = [[UIView alloc] init];
_lineView.backgroundColor = UIColor.fus_lineColor;
_subscribeDetailLabel = [[UILabel alloc] init];
_subscribeDetailLabel.numberOfLines = 0;
_subscribeDetailLabel.textColor = [UIColor fus_textColorMedium];
_subscribeDetailLabel.font = detail_font;
_separatorLine = [[UILabel alloc] init];
_separatorLine.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.1];
_tipsLabel = [[UILabel alloc] init];
_tipsLabel.textColor = messageBgColor;
_tipsLabel.font = [UIFont fus_themeBoldFont:13];
_tipsLabel.text = [NSString fus_versionLocalString:@"查看详情"];
[_tipsLabel sizeToFit];
self.backgroundView.layer.cornerRadius = BORDER_IMAGE_CORNERRADIUS;
self.backgroundView.clipsToBounds = YES;
self.backgroundView.backgroundColor = [UIColor fus_appBGColor];
_clickBtn = [FUSIMChatCellCoverButton buttonWithType:UIButtonTypeCustom];
_clickBtn.isNeedCopy = NO;
[self.backgroundView addSubview:_clickBtn];
[self.backgroundView addSubview:_subscribeTitleLabel];
[self.backgroundView addSubview:_arrowImageView];
[self.backgroundView addSubview:_lineView];
[self.backgroundView addSubview:_subscribeDetailLabel];
[self.backgroundView addSubview:_subscribeIconImageView];
[self.backgroundView addSubview:_separatorLine];
[self.backgroundView addSubview:_tipsLabel];
}
return self;
}
- (void)fus_layoutSubviewsWithModel:(FUSChatDetailFrameModel *)frameModel {
[super fus_layoutSubviewsWithModel:frameModel];
NSInteger textType = [frameModel.msgModel.message.ext[@"text_type"] integerValue];
BOOL needHideSubscribeIcon = (textType == 13 || textType == 14);
_clickBtn.frame = self.bounds;
_subscribeTitleLabel.frame = CGRectMake(13, 11, self.width - icon_W - 26, 15);
CGFloat arrowSize = 18;
_arrowImageView.left = self.width - arrowSize - 8;
_arrowImageView.size = CGSizeMake(arrowSize, arrowSize);
_arrowImageView.centerY = _subscribeTitleLabel.centerY;
self.lineView.frame = CGRectMake(13, CGRectGetMaxY(_subscribeTitleLabel.frame) + 6, self.width - 26, 0.5);
CGFloat subscribeDetailWidth = needHideSubscribeIcon ? (self.width - _subscribeTitleLabel.x * 2) : _subscribeTitleLabel.width;
_subscribeDetailLabel.frame = CGRectMake(_subscribeTitleLabel.x, CGRectGetMaxY(self.lineView.frame), subscribeDetailWidth, _subscribeTitleLabel.height * 3);
_subscribeIconImageView.frame = CGRectMake(self.width - icon_W - 12, _subscribeDetailLabel.y + 6, icon_W, icon_W);
_subscribeIconImageView.hidden = needHideSubscribeIcon;
_tipsLabel.text = [NSString fus_versionLocalString:@"点击进入"];
[_tipsLabel sizeToFit];
_tipsLabel.x = self.width - _tipsLabel.width - 12;
_tipsLabel.y = self.height - _tipsLabel.height - 8;
_separatorLine.frame = CGRectMake(10, _tipsLabel.y - 5, self.width - 20, 1);
_subscribeTitleLabel.text = frameModel.msgModel.subscribeTitle;
_subscribeDetailLabel.text = frameModel.msgModel.subscribeDetail;
if (needHideSubscribeIcon == NO) {
[_subscribeIconImageView setWebImageWithSubURLString:frameModel.msgModel.subscribeIconUrl placeholder:nil];
}
self.backgroundColor = [UIColor colorWithHex:@"#EFEFEF"];
self.clipsToBounds = NO;
self.layer.cornerRadius = BORDER_IMAGE_CORNERRADIUS;
self.layer.borderWidth = 1;
self.layer.borderColor = [UIColor fus_themeColor].CGColor;
// self.layer.shadowRadius = 4;
// self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
// self.layer.shadowColor = [UIColor fus_shadowColor].CGColor;
// self.layer.shadowOffset = CGSizeZero;
// self.layer.shadowOpacity = 0.3;
}
@end
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
@property (nonatomic, strong) FUSIMChatLiveRoomCellView *liveView; //进入直播间的 View @property (nonatomic, strong) FUSIMChatLiveRoomCellView *liveView; //进入直播间的 View
@property (nonatomic, strong) FUSIMChatSubscribeCellView *subscribeView; //订阅消息的 View
// 消息收益或者消耗的view // 消息收益或者消耗的view
@property (nonatomic, strong) UIButton *msgPainOrGainBtn; @property (nonatomic, strong) UIButton *msgPainOrGainBtn;
...@@ -317,6 +319,15 @@ ...@@ -317,6 +319,15 @@
[_eventManager fus_addLiveRoomClickEventToRoomView:_liveView withModel:frameModel]; [_eventManager fus_addLiveRoomClickEventToRoomView:_liveView withModel:frameModel];
} }
break; break;
case FUSMsgContentTypeSubscribe:
{
self.subscribeView.hidden = NO;
[self.contentView addSubview:self.subscribeView];
self.clickBtn = self.subscribeView.clickBtn;
[self.subscribeView fus_layoutSubviewsWithModel:frameModel];
[_eventManager fus_addSubscribeClickEventToSubscribeView:self.subscribeView withModel:frameModel];
}
break;
default: default:
break; break;
} }
...@@ -344,6 +355,7 @@ ...@@ -344,6 +355,7 @@
_noticeView.hidden = YES; _noticeView.hidden = YES;
_videoView.hidden = YES; _videoView.hidden = YES;
_liveView.hidden = YES; _liveView.hidden = YES;
_subscribeView.hidden = YES;
} }
...@@ -513,4 +525,11 @@ ...@@ -513,4 +525,11 @@
return _liveView; return _liveView;
} }
- (FUSIMChatSubscribeCellView *)subscribeView{
if (!_subscribeView) {
_subscribeView = [[FUSIMChatSubscribeCellView alloc] init];
}
return _subscribeView;
}
@end @end
...@@ -2889,6 +2889,7 @@ static NSInteger const kFUSPayRoomCompanionPopViewTagLeft = 90917002; ...@@ -2889,6 +2889,7 @@ static NSInteger const kFUSPayRoomCompanionPopViewTagLeft = 90917002;
- (void)setLiveType:(FUSLiveType)liveType - (void)setLiveType:(FUSLiveType)liveType
{ {
_liveType = liveType; _liveType = liveType;
[FUSSwiftCacheDataShare share].oc_liveType = liveType;
} }
- (void)setLiveRoomType:(FUSLiveRoomType)liveRoomType - (void)setLiveRoomType:(FUSLiveRoomType)liveRoomType
......
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