diff --git a/CustomKeyboard/View/KBFunctionView.m b/CustomKeyboard/View/KBFunctionView.m index cfe0dd4..605636d 100644 --- a/CustomKeyboard/View/KBFunctionView.m +++ b/CustomKeyboard/View/KBFunctionView.m @@ -16,6 +16,7 @@ #import "KBFullAccessManager.h" #import "KBSkinManager.h" #import "KBURLOpenBridge.h" // 兜底从扩展侧直接尝试 openURL: +#import "KBStreamTextView.h" // 流式文本视图 static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId"; @@ -30,6 +31,10 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId"; @property (nonatomic, strong) UIButton *clearButtonInternal; @property (nonatomic, strong) UIButton *sendButtonInternal; +// 临时:点击标签后展示的“流式文本视图”与其删除按钮 +@property (nonatomic, strong, nullable) KBStreamTextView *streamTextView; +@property (nonatomic, strong, nullable) UIButton *streamDeleteButton; + // Data @property (nonatomic, strong) NSArray *itemsInternal; @@ -182,12 +187,68 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId"; return 12.0; } -// 用户点击功能标签:优先 UL 拉起主App,失败再 Scheme;两次都失败则提示开启完全访问 +- (void)kb_showStreamTextViewIfNeededWithTitle:(NSString *)title { + // 已有则不重复创建 + if (self.streamTextView.superview) { return; } + + // 隐藏标签列表,使用同一区域展示流式文本 + self.collectionViewInternal.hidden = YES; + + KBStreamTextView *sv = [[KBStreamTextView alloc] init]; + sv.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.92]; + sv.layer.cornerRadius = 12.0; sv.layer.masksToBounds = YES; + // 演示:可选填充一段初始文本 + if (title.length > 0) { + [sv appendStreamText:[NSString stringWithFormat:@"%@\t", title]]; // 以制表符结尾,生成一个段落 + } + [self addSubview:sv]; + [sv mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.mas_left).offset(12); + make.right.equalTo(self).offset(-12); + make.top.equalTo(self.pasteViewInternal.mas_bottom).offset(10); + make.bottom.equalTo(self.mas_bottom).offset(-10); + }]; + self.streamTextView = sv; + + // 右上角删除按钮 + UIButton *del = [UIButton buttonWithType:UIButtonTypeSystem]; + del.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.35]; + del.layer.cornerRadius = 14; del.layer.masksToBounds = YES; + del.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; + [del setTitle:@"删除" forState:UIControlStateNormal]; + [del setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [del addTarget:self action:@selector(kb_onTapStreamDelete) forControlEvents:UIControlEventTouchUpInside]; + [sv addSubview:del]; + [del mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(sv.mas_top).offset(8); + make.right.equalTo(sv.mas_right).offset(-8); + make.height.mas_equalTo(28); + make.width.mas_greaterThanOrEqualTo(56); + }]; + self.streamDeleteButton = del; +} + +- (void)kb_onTapStreamDelete { + // 关闭并销毁流式视图,恢复标签列表 + [self.streamDeleteButton removeFromSuperview]; + self.streamDeleteButton = nil; + [self.streamTextView removeFromSuperview]; + self.streamTextView = nil; + self.collectionViewInternal.hidden = NO; +} + +// 用户点击功能标签:优先 UL 拉起主App,失败再 Scheme;两次都失败则提示开启完全访问。 +// 若已开启“完全访问”,则直接在键盘侧创建 KBStreamTextView,并在其右上角提供删除按钮关闭。 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - + // 权限全部打开(键盘已启用 + 完全访问)。在扩展进程中仅需判断“完全访问”。 + if ([[KBFullAccessManager shared] hasFullAccess]) { + NSString *title = (indexPath.item < self.itemsInternal.count) ? self.itemsInternal[indexPath.item] : @""; + [self kb_showStreamTextViewIfNeededWithTitle:title]; + return; + } + [KBHUD showInfo:@"处理中…"]; -// return; - + UIInputViewController *ivc = KBFindInputViewController(self); if (!ivc) return; diff --git a/keyBoard/Class/Me/V/KBMyHeaderView.m b/keyBoard/Class/Me/V/KBMyHeaderView.m index f92d15a..d59c75a 100644 --- a/keyBoard/Class/Me/V/KBMyHeaderView.m +++ b/keyBoard/Class/Me/V/KBMyHeaderView.m @@ -7,6 +7,7 @@ #import #import "UIColor+Extension.h" #import "KBPersonInfoVC.h" +#import "KBMyKeyBoardVC.h" @interface KBMyHeaderView () @property (nonatomic, strong) UILabel *titleLabel; @@ -193,7 +194,10 @@ } #pragma mark - Actions -- (void)onKeyboardTap { if (self.onKeyboardTapped) { self.onKeyboardTapped(); } } +- (void)onKeyboardTap { + KBMyKeyBoardVC *vc = [[KBMyKeyBoardVC alloc] init]; + [KB_CURRENT_NAV pushViewController:vc animated:true]; +} - (void)onAvatarTap { KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init]; [KB_CURRENT_NAV pushViewController:vc animated:true]; diff --git a/keyBoard/Class/Me/V/KBMyKeyboardCell.m b/keyBoard/Class/Me/V/KBMyKeyboardCell.m index 855aa63..28ecaae 100644 --- a/keyBoard/Class/Me/V/KBMyKeyboardCell.m +++ b/keyBoard/Class/Me/V/KBMyKeyboardCell.m @@ -2,12 +2,6 @@ // KBMyKeyboardCell.m // keyBoard // -// 截图页标签样式 cell,实现: -// - 左侧 Emoji,中间标题; -// - 右上角小圆点(减号),用于删除编辑态展示; -// - 白底圆角,阴影/描边轻微以贴近设计; -// - 暴露 +sizeForEmoji:title: 以便外部根据文本动态决定 item 宽度。 -// #import "KBMyKeyboardCell.h" @@ -18,6 +12,7 @@ @property (nonatomic, strong) UILabel *titleLabel; // 标题 @property (nonatomic, strong) UIView *minusBadge; // 右上角减号圆点 @property (nonatomic, strong) UILabel *minusLabel; // 减号 +@property (nonatomic, strong) UIControl *minusTapArea; // 放大点击区域(透明) @end @implementation KBMyKeyboardCell @@ -65,7 +60,15 @@ make.center.equalTo(self.minusBadge); }]; - // 点击右上角减号 + // 点击右上角减号:在其上方覆盖一层更大的透明点击区域,提升可点性 + [self.contentView addSubview:self.minusTapArea]; + [self.minusTapArea mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.contentView).offset(0); + make.right.equalTo(self.contentView).offset(0); + make.width.height.mas_equalTo(32); // 扩大到 32x32,更易点中 + }]; + // 将可点事件绑定到透明区域;保留 minusBadge 的手势作为兜底 + [self.minusTapArea addTarget:self action:@selector(didTapMinus) forControlEvents:UIControlEventTouchUpInside]; self.minusBadge.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMinus)]; [self.minusBadge addGestureRecognizer:tap]; @@ -152,6 +155,16 @@ return _minusLabel; } +- (UIControl *)minusTapArea { + if (!_minusTapArea) { + _minusTapArea = [[UIControl alloc] init]; + _minusTapArea.backgroundColor = [UIColor clearColor]; + // 提高命中率:即使轻微偏离也能点中 + _minusTapArea.accessibilityLabel = @"删除"; + } + return _minusTapArea; +} + - (UIView *)coverView{ if (!_coverView) { _coverView = [[UIView alloc] init]; diff --git a/keyBoard/Class/Me/VC/MyVC.m b/keyBoard/Class/Me/VC/MyVC.m index dc2ae13..85991fe 100644 --- a/keyBoard/Class/Me/VC/MyVC.m +++ b/keyBoard/Class/Me/VC/MyVC.m @@ -10,7 +10,6 @@ #import "KBSkinDetailVC.h" #import "KBMyHeaderView.h" // 顶部视图独立封装 #import "KBMyListCell.h" -#import "KBMyKeyBoardVC.h" @interface MyVC () @property (nonatomic, strong) BaseTableView *tableView; // 列表 @@ -93,8 +92,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; - KBMyKeyBoardVC *vc = [[KBMyKeyBoardVC alloc] init]; - [self.navigationController pushViewController:vc animated:true]; + } #pragma mark - Lazy