Commit 40a61486 authored by Alex朱枝文's avatar Alex朱枝文

TUI库文件更改:UI更改和添加文件本地预览

parent 83e7ade3
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
if (self.supportReEdit) { if (self.supportReEdit) {
NSString *reEditStr = TIMCommonLocalizableString(TUIKitMessageTipsReEditMessage); NSString *reEditStr = TIMCommonLocalizableString(TUIKitMessageTipsReEditMessage);
[attributeString appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", reEditStr]]]; [attributeString appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", reEditStr]]];
NSDictionary *attributeDict = @{NSForegroundColorAttributeName : [UIColor d_systemBlueColor]}; NSDictionary *attributeDict = @{NSForegroundColorAttributeName : [UIColor tui_colorWithHex:@"#0046B4"]};
[attributeString setAttributes:attributeDict range:NSMakeRange(self.content.length + 1, reEditStr.length)]; [attributeString setAttributes:attributeDict range:NSMakeRange(self.content.length + 1, reEditStr.length)];
[attributeString addAttribute:NSUnderlineStyleAttributeName [attributeString addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInteger:NSUnderlineStyleNone] value:[NSNumber numberWithInteger:NSUnderlineStyleNone]
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
_textView.scrollEnabled = NO; _textView.scrollEnabled = NO;
_textView.backgroundColor = [UIColor clearColor]; _textView.backgroundColor = [UIColor clearColor];
_textView.textColor = [UIColor d_systemGrayColor]; _textView.textColor = [UIColor d_systemGrayColor];
_textView.linkTextAttributes = @{
NSForegroundColorAttributeName: [UIColor tui_colorWithHex: @"#0046B4"],
NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)
};
_textView.textContainerInset = UIEdgeInsetsMake(5, 0, 5, 0); _textView.textContainerInset = UIEdgeInsetsMake(5, 0, 5, 0);
_textView.layer.cornerRadius = 3; _textView.layer.cornerRadius = 3;
_textView.delegate = self; _textView.delegate = self;
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
*/ */
@interface TUIBaseChatViewController : UIViewController @interface TUIBaseChatViewController : UIViewController
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, strong) TUIChatConversationModel *conversationData; @property(nonatomic, strong) TUIChatConversationModel *conversationData;
/** /**
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#import "TUIVideoMessageCellData.h" #import "TUIVideoMessageCellData.h"
#import "TUIVoiceMessageCellData.h" #import "TUIVoiceMessageCellData.h"
#import "TUIChatShortcutMenuView.h" #import "TUIChatShortcutMenuView.h"
#import "TUIFileViewController.h"
static UIView *gCustomTopView; static UIView *gCustomTopView;
static UIView *gTopExentsionView; static UIView *gTopExentsionView;
...@@ -57,7 +58,8 @@ static CGRect gCustomTopViewRect; ...@@ -57,7 +58,8 @@ static CGRect gCustomTopViewRect;
V2TIMConversationListener, V2TIMConversationListener,
TUINavigationControllerDelegate, TUINavigationControllerDelegate,
TUIChatMediaDataListener, TUIChatMediaDataListener,
TIMInputViewMoreActionProtocol> TIMInputViewMoreActionProtocol,
TUICustomOpenFileDelegate>
@property(nonatomic, strong) TUINaviBarIndicatorView *titleView; @property(nonatomic, strong) TUINaviBarIndicatorView *titleView;
@property(nonatomic, strong) TUIMessageMultiChooseView *multiChooseView; @property(nonatomic, strong) TUIMessageMultiChooseView *multiChooseView;
...@@ -327,6 +329,7 @@ static CGRect gCustomTopViewRect; ...@@ -327,6 +329,7 @@ static CGRect gCustomTopViewRect;
vc.isMsgNeedReadReceipt = self.conversationData.msgNeedReadReceipt && [TUIChatConfig defaultConfig].msgNeedReadReceipt; vc.isMsgNeedReadReceipt = self.conversationData.msgNeedReadReceipt && [TUIChatConfig defaultConfig].msgNeedReadReceipt;
_messageController = vc; _messageController = vc;
_messageController.delegate = self; _messageController.delegate = self;
_messageController.filePreviewDelegate = self;
[_messageController setConversation:self.conversationData]; [_messageController setConversation:self.conversationData];
CGFloat textViewHeight = TUIChatConfig.defaultConfig.enableMainPageInputBar? TTextView_Height:0; CGFloat textViewHeight = TUIChatConfig.defaultConfig.enableMainPageInputBar? TTextView_Height:0;
...@@ -1546,4 +1549,15 @@ static CGRect gCustomTopViewRect; ...@@ -1546,4 +1549,15 @@ static CGRect gCustomTopViewRect;
return self.responseKeyboard; return self.responseKeyboard;
} }
#pragma mark - TUICustomOpenFileDelegate
- (void)didTapInFileCell:(TUIFileMessageCellData *)cellData {
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
[self.filePreviewDelegate didTapInFileCell: cellData];
} else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = cellData;
[self.navigationController pushViewController:file animated:YES];
}
}
@end @end
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "TUIBaseMessageControllerDelegate.h" #import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h" #import "TUIChatConversationModel.h"
#import "TUIChatDefine.h" #import "TUIChatDefine.h"
#import "TUICustomOpenFileDelegate.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
...@@ -47,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -47,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, weak) id<TUIBaseMessageControllerDelegate> delegate; @property(nonatomic, weak) id<TUIBaseMessageControllerDelegate> delegate;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@property(nonatomic, assign) BOOL isInVC; @property(nonatomic, assign) BOOL isInVC;
/** /**
......
...@@ -1532,6 +1532,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID ...@@ -1532,6 +1532,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
self.hasCoverPage = YES; self.hasCoverPage = YES;
TUIRepliesDetailViewController *repliesDetailVC = [[TUIRepliesDetailViewController alloc] initWithCellData:data conversationData:self.conversationData]; TUIRepliesDetailViewController *repliesDetailVC = [[TUIRepliesDetailViewController alloc] initWithCellData:data conversationData:self.conversationData];
repliesDetailVC.delegate = self.delegate; repliesDetailVC.delegate = self.delegate;
repliesDetailVC.filePreviewDelegate = self.filePreviewDelegate;
[self.navigationController pushViewController:repliesDetailVC animated:YES]; [self.navigationController pushViewController:repliesDetailVC animated:YES];
repliesDetailVC.parentPageDataProvider = self.messageDataProvider; repliesDetailVC.parentPageDataProvider = self.messageDataProvider;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
...@@ -1855,10 +1856,13 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID ...@@ -1855,10 +1856,13 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
[fileData downloadFile]; [fileData downloadFile];
return; return;
} }
if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
TUIFileViewController *file = [[TUIFileViewController alloc] init]; [self.filePreviewDelegate didTapInFileCell: [cell fileData]];
file.data = [cell fileData]; } else {
[self.navigationController pushViewController:file animated:YES]; TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
[self.navigationController pushViewController:file animated:YES];
}
} }
- (void)showRelayMessage:(TUIMergeMessageCell *)cell { - (void)showRelayMessage:(TUIMergeMessageCell *)cell {
...@@ -1867,6 +1871,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID ...@@ -1867,6 +1871,7 @@ ReceiveReadMsgWithGroupID:(NSString *)groupID
mergeVc.mergerElem = cell.mergeData.mergerElem; mergeVc.mergerElem = cell.mergeData.mergerElem;
mergeVc.conversationData = self.conversationData; mergeVc.conversationData = self.conversationData;
mergeVc.parentPageDataProvider = self.messageDataProvider; mergeVc.parentPageDataProvider = self.messageDataProvider;
mergeVc.filePreviewDelegate = self.filePreviewDelegate;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
mergeVc.willCloseCallback = ^() { mergeVc.willCloseCallback = ^() {
[weakSelf.tableView reloadData]; [weakSelf.tableView reloadData];
......
//
// TUICustomOpenFileDelegate.h
// Pods
//
// Created by alexzzw on 2025/5/20.
//
#import <Foundation/Foundation.h>
@import ImSDK_Plus;
@class TUIFileMessageCellData;
NS_ASSUME_NONNULL_BEGIN
/////////////////////////////////////////////////////////////////////////////////
//
// TUICustomOpenFileDelegate
//
/////////////////////////////////////////////////////////////////////////////////
@protocol TUICustomOpenFileDelegate <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;
@end
NS_ASSUME_NONNULL_END
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "TUIBaseMessageControllerDelegate.h" #import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h" #import "TUIChatConversationModel.h"
#import "TUIMessageDataProvider.h" #import "TUIMessageDataProvider.h"
#import "TUICustomOpenFileDelegate.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
...@@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) dispatch_block_t willCloseCallback; @property(nonatomic, copy) dispatch_block_t willCloseCallback;
@property(nonatomic, strong) TUIChatConversationModel *conversationData; @property(nonatomic, strong) TUIChatConversationModel *conversationData;
@property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider; @property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@end @end
......
...@@ -475,9 +475,13 @@ ...@@ -475,9 +475,13 @@
} }
- (void)showFileMessage:(TUIFileMessageCell *)cell { - (void)showFileMessage:(TUIFileMessageCell *)cell {
TUIFileViewController *file = [[TUIFileViewController alloc] init]; if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
file.data = [cell fileData]; [self.filePreviewDelegate didTapInFileCell: [cell fileData]];
[self.navigationController pushViewController:file animated:YES]; } else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
[self.navigationController pushViewController:file animated:YES];
}
} }
- (void)showLinkMessage:(TUILinkCell *)cell { - (void)showLinkMessage:(TUILinkCell *)cell {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "TUIBaseMessageControllerDelegate.h" #import "TUIBaseMessageControllerDelegate.h"
#import "TUIChatConversationModel.h" #import "TUIChatConversationModel.h"
#import "TUIInputController.h" #import "TUIInputController.h"
#import "TUICustomOpenFileDelegate.h"
@class TUIMessageDataProvider; @class TUIMessageDataProvider;
...@@ -25,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -25,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) dispatch_block_t willCloseCallback; @property(nonatomic, copy) dispatch_block_t willCloseCallback;
@property(nonatomic, strong) TUIInputController *inputController; @property(nonatomic, strong) TUIInputController *inputController;
@property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider; @property(nonatomic, strong) TUIMessageDataProvider *parentPageDataProvider;
@property(nonatomic, weak) id<TUICustomOpenFileDelegate> filePreviewDelegate;
@end @end
......
...@@ -646,9 +646,13 @@ ...@@ -646,9 +646,13 @@
} }
- (void)showFileMessage:(TUIFileMessageCell *)cell { - (void)showFileMessage:(TUIFileMessageCell *)cell {
TUIFileViewController *file = [[TUIFileViewController alloc] init]; if (self.filePreviewDelegate && [self.filePreviewDelegate respondsToSelector:@selector(didTapInFileCell:)]) {
file.data = [cell fileData]; [self.filePreviewDelegate didTapInFileCell: [cell fileData]];
[self.navigationController pushViewController:file animated:YES]; } else {
TUIFileViewController *file = [[TUIFileViewController alloc] init];
file.data = [cell fileData];
[self.navigationController pushViewController:file animated:YES];
}
} }
- (void)showLinkMessage:(TUILinkCell *)cell { - (void)showLinkMessage:(TUILinkCell *)cell {
......
...@@ -72,7 +72,7 @@ typedef void (^TUIValueResultCallback)(NSDictionary *param); ...@@ -72,7 +72,7 @@ typedef void (^TUIValueResultCallback)(NSDictionary *param);
@interface UIViewController (TUIRoute) @interface UIViewController (TUIRoute)
- (void)pushViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback; - (nullable UIViewController*)pushViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback;
- (void)presentViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback; - (void)presentViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback;
- (void)presentViewController:(NSString *)viewControllerKey - (void)presentViewController:(NSString *)viewControllerKey
......
...@@ -106,15 +106,17 @@ static const void *navigateValueCallback = @"navigateValueCallback"; ...@@ -106,15 +106,17 @@ static const void *navigateValueCallback = @"navigateValueCallback";
@implementation UIViewController (TUIRoute) @implementation UIViewController (TUIRoute)
- (void)pushViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback { - (nullable UIViewController*)pushViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback {
NSAssert([self isKindOfClass:UINavigationController.class], @"self must be a navigation controller"); NSAssert([self isKindOfClass:UINavigationController.class], @"self must be a navigation controller");
UIViewController *vc = [TUIObjectFactoryManager.shareInstance createObject:viewControllerKey param:param]; UIViewController *vc = [TUIObjectFactoryManager.shareInstance createObject:viewControllerKey param:param];
if ([vc isKindOfClass:UIViewController.class]) { if ([vc isKindOfClass:UIViewController.class]) {
vc.navigateValueCallback = callback; vc.navigateValueCallback = callback;
[(UINavigationController *)self pushViewController:vc animated:YES]; [(UINavigationController *)self pushViewController:vc animated:YES];
return vc;
} else { } else {
NSAssert(false, @"viewControllerKey not exists or invalid"); NSAssert(false, @"viewControllerKey not exists or invalid");
} }
return nil;
} }
- (void)presentViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback { - (void)presentViewController:(NSString *)viewControllerKey param:(nullable NSDictionary *)param forResult:(nullable TUIValueResultCallback)callback {
......
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