Commit 095a3a1b authored by Alex朱枝文's avatar Alex朱枝文

IM增加卡片消息跳转

parent c0755736
......@@ -52,7 +52,8 @@
if (data.imageUrl == nil) {
[self.iconView setImage:TUIChatBundleThemeImage(@"chat_custom_order_message_img", @"message_custom_order")];
} else {
[self.iconView setImage:[UIImage sd_imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:data.imageUrl]]]];
[self.iconView sd_setImageWithURL:[NSURL URLWithString:data.imageUrl]];
//[self.iconView setImage:[UIImage sd_imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:data.imageUrl]]]];
}
// tell constraints they need updating
[self setNeedsUpdateConstraints];
......
......@@ -47,7 +47,7 @@
@interface TUIBaseChatViewController : UIViewController
// 文件预览代理
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, weak) id<TUIYHCustomCellClickDelegate> yhCustomCellClickDelegate;
@property(nonatomic, strong) TUIChatConversationModel *conversationData;
......
......@@ -41,6 +41,7 @@
#import "TUIVoiceMessageCellData.h"
#import "TUIChatShortcutMenuView.h"
#import "TUIFileViewController.h"
#import "TUIOrderCellData.h"
static UIView *gCustomTopView;
static UIView *gTopExentsionView;
......@@ -59,7 +60,7 @@ static CGRect gCustomTopViewRect;
TUINavigationControllerDelegate,
TUIChatMediaDataListener,
TIMInputViewMoreActionProtocol,
TUICustomOpenFileDelegate>
TUIYHCustomCellClickDelegate>
@property(nonatomic, strong) TUINaviBarIndicatorView *titleView;
@property(nonatomic, strong) TUIMessageMultiChooseView *multiChooseView;
......@@ -332,7 +333,7 @@ static CGRect gCustomTopViewRect;
vc.isMsgNeedReadReceipt = self.conversationData.msgNeedReadReceipt && [TUIChatConfig defaultConfig].msgNeedReadReceipt;
_messageController = vc;
_messageController.delegate = self;
_messageController.filePreviewDelegate = self;
_messageController.yhCustomCellClickDelegate = self;
[_messageController setConversation:self.conversationData];
CGFloat textViewHeight = TUIChatConfig.defaultConfig.enableMainPageInputBar? TTextView_Height:0;
......@@ -1558,10 +1559,10 @@ static CGRect gCustomTopViewRect;
return self.responseKeyboard;
}
#pragma mark - TUICustomOpenFileDelegate
#pragma mark - TUIYHCustomCellClickDelegate
- (void)didTapInFileCell:(TUIFileMessageCellData *)cellData {
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.filePreviewDelegate didTapInFileCell: cellData];
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.yhCustomCellClickDelegate didTapInFileCell: cellData];
} else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = cellData;
......@@ -1569,4 +1570,12 @@ static CGRect gCustomTopViewRect;
}
}
- (void)didTapCustomOrderCell:(TUIOrderCellData *)cellData {
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapCustomOrderCell:)]) {
[self.yhCustomCellClickDelegate didTapCustomOrderCell: cellData];
} else {
[TUITool openLinkWithURL:[NSURL URLWithString:cellData.link]];
}
}
@end
......@@ -16,7 +16,7 @@
#import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h"
#import "TUIChatDefine.h"
#import "TUICustomOpenFileDelegate.h"
#import "TUIYHCustomCellClickDelegate.h"
NS_ASSUME_NONNULL_BEGIN
......@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, weak) id<TUIBaseMessageControllerDelegate> delegate;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, weak) id<TUIYHCustomCellClickDelegate> yhCustomCellClickDelegate;
@property(nonatomic, assign) BOOL isInVC;
......
......@@ -1532,7 +1532,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
self.hasCoverPage = YES;
TUIRepliesDetailViewController *repliesDetailVC = [[TUIRepliesDetailViewController alloc] initWithCellData:data conversationData:self.conversationData];
repliesDetailVC.delegate = self.delegate;
repliesDetailVC.filePreviewDelegate = self.filePreviewDelegate;
repliesDetailVC.yhCustomCellClickDelegate = self.yhCustomCellClickDelegate;
[self.navigationController pushViewController:repliesDetailVC animated:YES];
repliesDetailVC.parentPageDataProvider = self.messageDataProvider;
__weak typeof(self) weakSelf = self;
......@@ -1856,8 +1856,8 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
[fileData downloadFile];
return;
}
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.filePreviewDelegate didTapInFileCell: [cell fileData]];
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.yhCustomCellClickDelegate didTapInFileCell: [cell fileData]];
} else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
......@@ -1871,7 +1871,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
mergeVc.mergerElem = cell.mergeData.mergerElem;
mergeVc.conversationData = self.conversationData;
mergeVc.parentPageDataProvider = self.messageDataProvider;
mergeVc.filePreviewDelegate = self.filePreviewDelegate;
mergeVc.yhCustomCellClickDelegate = self.yhCustomCellClickDelegate;
__weak typeof(self) weakSelf = self;
mergeVc.willCloseCallback = ^() {
[weakSelf.tableView reloadData];
......@@ -1887,10 +1887,14 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
}
- (void)showOrderMessage:(TUIOrderCell *)cell {
TUIOrderCellData *cellData = cell.customData;
if (cellData.link) {
[TUITool openLinkWithURL:[NSURL URLWithString:cellData.link]];
}
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.yhCustomCellClickDelegate didTapCustomOrderCell: cell.customData];
} else {
TUIOrderCellData *cellData = cell.customData;
if (cellData.link) {
[TUITool openLinkWithURL:[NSURL URLWithString:cellData.link]];
}
}
}
- (void)showReplyMessage:(TUIReplyMessageCell *)cell {
......
......@@ -11,7 +11,7 @@
#import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h"
#import "TUIMessageDataProvider.h"
#import "TUICustomOpenFileDelegate.h"
#import "TUIYHCustomCellClickDelegate.h"
NS_ASSUME_NONNULL_BEGIN
......@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) dispatch_block_t willCloseCallback;
@property(nonatomic, strong) TUIChatConversationModel *conversationData;
@property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, weak) id<TUIYHCustomCellClickDelegate> yhCustomCellClickDelegate;
@end
......
......@@ -475,8 +475,8 @@
}
- (void)showFileMessage:(TUIFileMessageCell *)cell {
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.filePreviewDelegate didTapInFileCell: [cell fileData]];
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.yhCustomCellClickDelegate didTapInFileCell: [cell fileData]];
} else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
......
......@@ -11,7 +11,7 @@
#import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h"
#import "TUIInputController.h"
#import "TUICustomOpenFileDelegate.h"
#import "TUIYHCustomCellClickDelegate.h"
@class TUIMessageDataProvider;
......@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) dispatch_block_t willCloseCallback;
@property(nonatomic, strong) TUIInputController *inputController;
@property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, weak) id<TUIYHCustomCellClickDelegate> yhCustomCellClickDelegate;
@end
......
......@@ -646,8 +646,8 @@
}
- (void)showFileMessage:(TUIFileMessageCell *)cell {
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.filePreviewDelegate didTapInFileCell: [cell fileData]];
if (self.yhCustomCellClickDelegate && [self.yhCustomCellClickDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.yhCustomCellClickDelegate didTapInFileCell: [cell fileData]];
} else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
......
//
// TUIYHCustomCellClickDelegate.h
// Pods
//
// Created by alexzzw on 2025/5/20.
//
#import <Foundation/Foundation.h>
@import ImSDK_Plus;
@class TUIFileMessageCellData;
@class TUIOrderCellData;
NS_ASSUME_NONNULL_BEGIN
/////////////////////////////////////////////////////////////////////////////////
//
// TUIYHCustomCellClickDelegate
//
/////////////////////////////////////////////////////////////////////////////////
@protocol TUIYHCustomCellClickDelegate <NSObject>
/**
* Callback for clicking file cell
* You can use this callback to: preview file inside the app
*
* @param cellData include local file data
*/
- (void)didTapInFileCell:(TUIFileMessageCellData *)cellData;
/**
* Callback for clicking Custom cell
* You can use this callback to: preview file inside the app
*
* @param cellData include local file data
*/
- (void)didTapCustomOrderCell:(TUIOrderCellData *)cellData;
@end
NS_ASSUME_NONNULL_END
......@@ -47,10 +47,11 @@ platform :ios do
webFix = "develop_bugfix_web"
kjzf = "kjzf"
develop_fix_adopter = "develop_fix_adopter"
txim_add_card = "txim_add_card"
#打包正使用的分支
myPack_branch = develop_fix_adopter
myPack_branch = txim_add_card
# 打adhoc包 执行命令 fastlane galaxyTest
......
......@@ -21,7 +21,14 @@ class YHNavigationController: UINavigationController {
override func popViewController(animated: Bool) -> UIViewController? {
printLog("popViewController")
return super.popViewController(animated: animated)
let popedVC = super.popViewController(animated: animated)
if let lastVC = viewControllers.last { // 回到腾讯TUI页面,显示NavigationBar
let className = String(describing: type(of: lastVC))
if className.hasPrefix("TUI") {
super.setNavigationBarHidden(false, animated: false)
}
}
return popedVC
}
override func setNavigationBarHidden(_ hidden: Bool, animated: Bool) {
......@@ -31,8 +38,15 @@ class YHNavigationController: UINavigationController {
// }
if let lastVC = viewControllers.last {
let className = String(describing: type(of: lastVC))
if !className.hasPrefix("TUI") { // 模糊匹配类名
super.setNavigationBarHidden(hidden, animated: animated)
if !className.hasPrefix("TUI") { // 模糊匹配类名,使得腾讯IM页面不用隐藏NavigationBar
var needAnimated = false
let lastSecondCount = viewControllers.count - 2
if lastSecondCount >= 0 {
let lastSecondVC = viewControllers[lastSecondCount]
let lastSecondVCClassName = String(describing: type(of: lastSecondVC))
needAnimated = lastSecondVCClassName.hasPrefix("TUI") // 当从TUI页面跳到普通页面需要缓慢隐藏,免得出现黑条
}
super.setNavigationBarHidden(hidden, animated: needAnimated)
}
}
}
......
......@@ -12,6 +12,7 @@ import TUIConversation
import TUIChat
import IQKeyboardManagerSwift
import GKNavigationBarSwift
import SafariServices
class YHMessageListVC: YHBaseViewController {
private let messageListManager = YHTUIMessageListManager.shared
......@@ -502,7 +503,7 @@ extension YHMessageListVC {
if let vc = vc as? TUIBaseChatViewController {
vc.navigationItem.rightBarButtonItem = nil
vc.navigationItem.rightBarButtonItems = nil
vc.filePreviewDelegate = self
vc.yhCustomCellClickDelegate = self
}
}
......@@ -585,7 +586,7 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
if let vc = vc as? TUIBaseChatViewController {
vc.navigationItem.rightBarButtonItem = nil
vc.navigationItem.rightBarButtonItems = nil
vc.filePreviewDelegate = self
vc.yhCustomCellClickDelegate = self
}
return
......@@ -721,7 +722,7 @@ extension YHMessageListVC: YHMessageListDelegate {
}
}
extension YHMessageListVC: TUICustomOpenFileDelegate {
extension YHMessageListVC: TUIYHCustomCellClickDelegate {
func didTap(inFileCell cellData: TUIFileMessageCellData) {
var isExist: ObjCBool = false
let path = cellData.getFilePath(&isExist)
......@@ -732,4 +733,66 @@ extension YHMessageListVC: TUICustomOpenFileDelegate {
cellData.downloadFile()
}
}
func didTapCustomOrderCell(_ cellData: TUIOrderCellData) {
let linkAddress = cellData.link ?? ""
guard linkAddress.count > 0, linkAddress.isValidHttpUrl || linkAddress.isValidHttpsUrl || linkAddress.isValidFileUrl, let url = URL(string: linkAddress) else {
handelMessageType(linkAddress)
return
}
let safariViewController = SFSafariViewController(url: url)
safariViewController.dismissButtonStyle = .close
safariViewController.modalPresentationStyle = .fullScreen
UIViewController.current?.present(safariViewController, animated: true, completion: nil)
}
private func handelMessageType(_ content: String?) {
if let dicData = content, dicData.count > 0, let data = dicData.data(using: .utf8) {
do {
if let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
// 转换成功,jsonObject 是一个字典
printLog("JSON字符串转换为字典成功: \(jsonObject)")
/*
"{\"order_id\":151824,\"type\":27}"
*/
if !jsonObject.isEmpty {
let msgType: String = jsonObject["msg_type"] as? String ?? ""
let navH5Url: String = jsonObject["nav_h5_url"] as? String ?? ""
let orderID: Int = jsonObject["order_id"] as? Int ?? -1
let type: Int = jsonObject["type"] as? Int ?? -1
let batchId: Int = jsonObject["batch_id"] as? Int ?? 0
if msgType == "card_msg", navH5Url.count > 0 {
let title = jsonObject["title"] as? String ?? ""
var url = ""
if YHLoginManager.shared.isLogin() {
let token = YHLoginManager.shared.h5Token
if navH5Url.contains("?") {
url = navH5Url + "&param=" + token
} else {
url = navH5Url + "?param=" + token
}
} else {
url = navH5Url
}
let vc = YHH5WebViewVC()
vc.isFullScreenFlag = false
vc.navTitle = title
vc.url = url
UIViewController.current?.navigationController?.pushViewController(vc)
} else if orderID > -1, type > -1 {
YHServiceOrderListViewController.jumpToMessageController(type: type, orderId: orderID, batchId)
}
} else {
printLog("ddddd")
}
} else {
printLog("JSON字符串不是有效的字典格式")
}
} catch {
printLog("JSON解析错误: \(error)")
}
}
}
}
......@@ -168,7 +168,7 @@ class YHMemberCenterViewController: YHBaseViewController, UIGestureRecognizerDel
if isNeedLoading, let index = YHMembershipLevel.allCases.firstIndex(where: { data in
data.rawValue == memberCenterInfo.currentLevel
}) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) {
self.headerView.bannerView.scrollToItem(at: index, animated: false)
self.switchCard(YHMembershipLevel.allCases[index])
}
......
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 to comment