2
This commit is contained in:
22
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/Contents.json
vendored
Normal file
22
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "close_icon@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "close_icon@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/close_icon@2x.png
vendored
Normal file
BIN
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/close_icon@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/close_icon@3x.png
vendored
Normal file
BIN
CustomKeyboard/KeyboardAssets.xcassets/close_icon.imageset/close_icon@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@@ -794,6 +794,26 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
|||||||
[self kb_playChatAudioAtPath:message.audioFilePath];
|
[self kb_playChatAudioAtPath:message.audioFilePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)chatPanelViewDidTapClose:(KBChatPanelView *)view {
|
||||||
|
for (KBChatMessage *msg in self.chatMessages) {
|
||||||
|
if (msg.audioFilePath.length > 0) {
|
||||||
|
NSString *tmpRoot = NSTemporaryDirectory();
|
||||||
|
if (tmpRoot.length > 0 &&
|
||||||
|
[msg.audioFilePath hasPrefix:tmpRoot]) {
|
||||||
|
[[NSFileManager defaultManager] removeItemAtPath:msg.audioFilePath
|
||||||
|
error:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[self.chatMessages removeAllObjects];
|
||||||
|
[self.chatPanelView kb_reloadWithMessages:@[]];
|
||||||
|
if (self.chatAudioPlayer.isPlaying) {
|
||||||
|
[self.chatAudioPlayer stop];
|
||||||
|
}
|
||||||
|
self.chatAudioPlayer = nil;
|
||||||
|
[self showChatPanel:NO];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Chat Helpers
|
#pragma mark - Chat Helpers
|
||||||
|
|
||||||
- (void)kb_handleChatSendAction {
|
- (void)kb_handleChatSendAction {
|
||||||
@@ -1432,6 +1452,7 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
|||||||
NSLog(@"⌨️[Keyboard] apply theme id=%@ hasBg=%d", t.skinId, (img != nil));
|
NSLog(@"⌨️[Keyboard] apply theme id=%@ hasBg=%d", t.skinId, (img != nil));
|
||||||
[self kb_logSkinDiagnosticsWithTheme:t backgroundImage:img];
|
[self kb_logSkinDiagnosticsWithTheme:t backgroundImage:img];
|
||||||
self.bgImageView.image = img;
|
self.bgImageView.image = img;
|
||||||
|
// [self.chatPanelView kb_setBackgroundImage:img];
|
||||||
BOOL hasImg = (img != nil);
|
BOOL hasImg = (img != nil);
|
||||||
// 触发键区按主题重绘
|
// 触发键区按主题重绘
|
||||||
if ([self.keyBoardMainView respondsToSelector:@selector(kb_applyTheme)]) {
|
if ([self.keyBoardMainView respondsToSelector:@selector(kb_applyTheme)]) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||||
self.backgroundColor = [UIColor clearColor];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
|
self.contentView.backgroundColor = [UIColor clearColor];
|
||||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||||
|
|
||||||
[self.contentView addSubview:self.avatarView];
|
[self.contentView addSubview:self.avatarView];
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@optional
|
@optional
|
||||||
- (void)chatPanelView:(KBChatPanelView *)view didSendText:(NSString *)text;
|
- (void)chatPanelView:(KBChatPanelView *)view didSendText:(NSString *)text;
|
||||||
- (void)chatPanelView:(KBChatPanelView *)view didTapMessage:(KBChatMessage *)message;
|
- (void)chatPanelView:(KBChatPanelView *)view didTapMessage:(KBChatMessage *)message;
|
||||||
|
- (void)chatPanelViewDidTapClose:(KBChatPanelView *)view;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface KBChatPanelView : UIView
|
@interface KBChatPanelView : UIView
|
||||||
@@ -20,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (nonatomic, strong, readonly) UITableView *tableView;
|
@property (nonatomic, strong, readonly) UITableView *tableView;
|
||||||
|
|
||||||
|
//- (void)kb_setBackgroundImage:(nullable UIImage *)image;
|
||||||
- (void)kb_reloadWithMessages:(NSArray<KBChatMessage *> *)messages;
|
- (void)kb_reloadWithMessages:(NSArray<KBChatMessage *> *)messages;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
#import "Masonry.h"
|
#import "Masonry.h"
|
||||||
|
|
||||||
@interface KBChatPanelView () <UITableViewDataSource, UITableViewDelegate>
|
@interface KBChatPanelView () <UITableViewDataSource, UITableViewDelegate>
|
||||||
|
//@property (nonatomic, strong) UIImageView *backgroundImageView;
|
||||||
|
@property (nonatomic, strong) UIView *headerView;
|
||||||
|
@property (nonatomic, strong) UILabel *titleLabel;
|
||||||
|
@property (nonatomic, strong) UIButton *closeButton;
|
||||||
@property (nonatomic, strong) UITableView *tableViewInternal;
|
@property (nonatomic, strong) UITableView *tableViewInternal;
|
||||||
@property (nonatomic, copy) NSArray<KBChatMessage *> *messages;
|
@property (nonatomic, copy) NSArray<KBChatMessage *> *messages;
|
||||||
@end
|
@end
|
||||||
@@ -17,13 +21,25 @@
|
|||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame {
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||||||
if (self = [super initWithFrame:frame]) {
|
if (self = [super initWithFrame:frame]) {
|
||||||
self.backgroundColor = [UIColor colorWithHex:0xD1D3DB];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
|
|
||||||
|
// [self addSubview:self.backgroundImageView];
|
||||||
|
[self addSubview:self.headerView];
|
||||||
[self addSubview:self.tableViewInternal];
|
[self addSubview:self.tableViewInternal];
|
||||||
|
|
||||||
|
// [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
// make.edges.equalTo(self);
|
||||||
|
// }];
|
||||||
|
|
||||||
|
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.left.right.equalTo(self);
|
||||||
|
make.top.equalTo(self.mas_top);
|
||||||
|
make.height.mas_equalTo(KBFit(36.0f));
|
||||||
|
}];
|
||||||
|
|
||||||
[self.tableViewInternal mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.tableViewInternal mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.right.equalTo(self);
|
make.left.right.equalTo(self);
|
||||||
make.top.equalTo(self.mas_top).offset(8);
|
make.top.equalTo(self.headerView.mas_bottom).offset(4);
|
||||||
make.bottom.equalTo(self.mas_bottom).offset(-8);
|
make.bottom.equalTo(self.mas_bottom).offset(-8);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -43,6 +59,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- (void)kb_setBackgroundImage:(UIImage *)image {
|
||||||
|
// self.backgroundImageView.image = image;
|
||||||
|
//}
|
||||||
|
|
||||||
|
#pragma mark - Actions
|
||||||
|
|
||||||
|
- (void)kb_onTapClose {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(chatPanelViewDidTapClose:)]) {
|
||||||
|
[self.delegate chatPanelViewDidTapClose:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - UITableViewDataSource
|
#pragma mark - UITableViewDataSource
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||||
@@ -80,6 +108,7 @@
|
|||||||
if (!_tableViewInternal) {
|
if (!_tableViewInternal) {
|
||||||
_tableViewInternal = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
_tableViewInternal = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||||
_tableViewInternal.backgroundColor = [UIColor clearColor];
|
_tableViewInternal.backgroundColor = [UIColor clearColor];
|
||||||
|
_tableViewInternal.backgroundView = nil;
|
||||||
_tableViewInternal.separatorStyle = UITableViewCellSeparatorStyleNone;
|
_tableViewInternal.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
_tableViewInternal.dataSource = self;
|
_tableViewInternal.dataSource = self;
|
||||||
_tableViewInternal.delegate = self;
|
_tableViewInternal.delegate = self;
|
||||||
@@ -90,6 +119,61 @@
|
|||||||
return _tableViewInternal;
|
return _tableViewInternal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UIView *)headerView {
|
||||||
|
if (!_headerView) {
|
||||||
|
_headerView = [[UIView alloc] init];
|
||||||
|
_headerView.backgroundColor = [UIColor clearColor];
|
||||||
|
[_headerView addSubview:self.titleLabel];
|
||||||
|
[_headerView addSubview:self.closeButton];
|
||||||
|
|
||||||
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.left.equalTo(_headerView.mas_left).offset(12);
|
||||||
|
make.centerY.equalTo(_headerView);
|
||||||
|
}];
|
||||||
|
|
||||||
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.right.equalTo(_headerView.mas_right).offset(-12);
|
||||||
|
make.centerY.equalTo(_headerView);
|
||||||
|
make.width.height.mas_equalTo(KBFit(24.0f));
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
return _headerView;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UILabel *)titleLabel {
|
||||||
|
if (!_titleLabel) {
|
||||||
|
_titleLabel = [[UILabel alloc] init];
|
||||||
|
_titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
||||||
|
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||||
|
_titleLabel.text = KBLocalized(@"AI对话");
|
||||||
|
}
|
||||||
|
return _titleLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIButton *)closeButton {
|
||||||
|
if (!_closeButton) {
|
||||||
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
|
UIImage *icon = [UIImage imageNamed:@"close_icon"];
|
||||||
|
[_closeButton setImage:icon forState:UIControlStateNormal];
|
||||||
|
_closeButton.backgroundColor = [UIColor clearColor];
|
||||||
|
[_closeButton addTarget:self
|
||||||
|
action:@selector(kb_onTapClose)
|
||||||
|
forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
}
|
||||||
|
return _closeButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- (UIImageView *)backgroundImageView {
|
||||||
|
// if (!_backgroundImageView) {
|
||||||
|
// _backgroundImageView = [[UIImageView alloc] init];
|
||||||
|
// _backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||||
|
// _backgroundImageView.clipsToBounds = YES;
|
||||||
|
// _backgroundImageView.backgroundColor = [UIColor clearColor];
|
||||||
|
// _backgroundImageView.userInteractionEnabled = NO;
|
||||||
|
// }
|
||||||
|
// return _backgroundImageView;
|
||||||
|
//}
|
||||||
|
|
||||||
#pragma mark - Expose
|
#pragma mark - Expose
|
||||||
|
|
||||||
- (UITableView *)tableView { return self.tableViewInternal; }
|
- (UITableView *)tableView { return self.tableViewInternal; }
|
||||||
|
|||||||
Reference in New Issue
Block a user