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

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

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