添加删除按钮
This commit is contained in:
@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (void)emojiPanelView:(KBEmojiPanelView *)panel didSelectEmoji:(NSString *)emoji;
|
- (void)emojiPanelView:(KBEmojiPanelView *)panel didSelectEmoji:(NSString *)emoji;
|
||||||
- (void)emojiPanelViewDidRequestClose:(KBEmojiPanelView *)panel;
|
- (void)emojiPanelViewDidRequestClose:(KBEmojiPanelView *)panel;
|
||||||
- (void)emojiPanelViewDidTapSearch:(KBEmojiPanelView *)panel;
|
- (void)emojiPanelViewDidTapSearch:(KBEmojiPanelView *)panel;
|
||||||
|
@optional
|
||||||
|
- (void)emojiPanelViewDidTapDelete:(KBEmojiPanelView *)panel;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface KBEmojiPanelView : UIView
|
@interface KBEmojiPanelView : UIView
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
@property (nonatomic, strong) UIView *bottomBar;
|
@property (nonatomic, strong) UIView *bottomBar;
|
||||||
@property (nonatomic, strong) UIScrollView *tabScrollView;
|
@property (nonatomic, strong) UIScrollView *tabScrollView;
|
||||||
@property (nonatomic, strong) UIStackView *tabStackView;
|
@property (nonatomic, strong) UIStackView *tabStackView;
|
||||||
|
@property (nonatomic, strong) UIButton *deleteButton;
|
||||||
//@property (nonatomic, strong) UIButton *searchButton;
|
//@property (nonatomic, strong) UIButton *searchButton;
|
||||||
@property (nonatomic, strong) NSArray<UIButton *> *tabButtons;
|
@property (nonatomic, strong) NSArray<UIButton *> *tabButtons;
|
||||||
@property (nonatomic, strong) KBEmojiDataProvider *dataProvider;
|
@property (nonatomic, strong) KBEmojiDataProvider *dataProvider;
|
||||||
@@ -119,6 +120,15 @@
|
|||||||
self.tabStackView.alignment = UIStackViewAlignmentFill;
|
self.tabStackView.alignment = UIStackViewAlignmentFill;
|
||||||
[self.tabScrollView addSubview:self.tabStackView];
|
[self.tabScrollView addSubview:self.tabStackView];
|
||||||
|
|
||||||
|
self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
|
self.deleteButton.layer.cornerRadius = 16;
|
||||||
|
self.deleteButton.layer.masksToBounds = YES;
|
||||||
|
self.deleteButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||||
|
[self.deleteButton setTitle:@"⌫" forState:UIControlStateNormal];
|
||||||
|
[self.deleteButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||||
|
[self.deleteButton addTarget:self action:@selector(onDelete) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
[self.bottomBar addSubview:self.deleteButton];
|
||||||
|
|
||||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.equalTo(self.mas_left).offset(12);
|
make.left.equalTo(self.mas_left).offset(12);
|
||||||
make.right.equalTo(self.mas_right).offset(-12);
|
make.right.equalTo(self.mas_right).offset(-12);
|
||||||
@@ -140,8 +150,7 @@
|
|||||||
|
|
||||||
[self.tabScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.tabScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.equalTo(self.bottomBar.mas_left).offset(12);
|
make.left.equalTo(self.bottomBar.mas_left).offset(12);
|
||||||
// make.right.equalTo(self.searchButton.mas_left).offset(-12);
|
make.right.equalTo(self.deleteButton.mas_left).offset(-12);
|
||||||
make.right.equalTo(self.bottomBar.mas_right).offset(-12);
|
|
||||||
make.top.equalTo(self.bottomBar.mas_top).offset(4);
|
make.top.equalTo(self.bottomBar.mas_top).offset(4);
|
||||||
make.bottom.equalTo(self.bottomBar.mas_bottom).offset(-4);
|
make.bottom.equalTo(self.bottomBar.mas_bottom).offset(-4);
|
||||||
}];
|
}];
|
||||||
@@ -151,6 +160,13 @@
|
|||||||
make.height.equalTo(self.tabScrollView);
|
make.height.equalTo(self.tabScrollView);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.right.equalTo(self.bottomBar.mas_right).offset(-12);
|
||||||
|
make.centerY.equalTo(self.bottomBar);
|
||||||
|
make.width.mas_equalTo(44);
|
||||||
|
make.height.equalTo(self.tabScrollView);
|
||||||
|
}];
|
||||||
|
|
||||||
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onSwipe:)];
|
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onSwipe:)];
|
||||||
leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
|
leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
|
||||||
[self addGestureRecognizer:leftSwipe];
|
[self addGestureRecognizer:leftSwipe];
|
||||||
@@ -167,7 +183,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateTabButtonCornerRadii {
|
- (void)updateTabButtonCornerRadii {
|
||||||
if (self.tabButtons.count == 0) { return; }
|
|
||||||
for (UIButton *btn in self.tabButtons) {
|
for (UIButton *btn in self.tabButtons) {
|
||||||
CGFloat radius = MIN(CGRectGetHeight(btn.bounds), CGRectGetWidth(btn.bounds)) / 2.0;
|
CGFloat radius = MIN(CGRectGetHeight(btn.bounds), CGRectGetWidth(btn.bounds)) / 2.0;
|
||||||
if (radius <= 0) { continue; }
|
if (radius <= 0) { continue; }
|
||||||
@@ -176,6 +191,15 @@
|
|||||||
btn.layer.cornerCurve = kCACornerCurveContinuous;
|
btn.layer.cornerCurve = kCACornerCurveContinuous;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (self.deleteButton) {
|
||||||
|
CGFloat radius = MIN(CGRectGetHeight(self.deleteButton.bounds), CGRectGetWidth(self.deleteButton.bounds)) / 2.0;
|
||||||
|
if (radius > 0) {
|
||||||
|
self.deleteButton.layer.cornerRadius = radius;
|
||||||
|
if (@available(iOS 13.0, *)) {
|
||||||
|
self.deleteButton.layer.cornerCurve = kCACornerCurveContinuous;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerNotifications {
|
- (void)registerNotifications {
|
||||||
@@ -283,6 +307,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)onDelete {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(emojiPanelViewDidTapDelete:)]) {
|
||||||
|
[self.delegate emojiPanelViewDidTapDelete:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)onTabTapped:(UIButton *)sender {
|
- (void)onTabTapped:(UIButton *)sender {
|
||||||
[self updateSelectionToIndex:sender.tag];
|
[self updateSelectionToIndex:sender.tag];
|
||||||
}
|
}
|
||||||
@@ -321,6 +351,11 @@
|
|||||||
self.tabNormalColor = [UIColor colorWithWhite:1 alpha:0.08];
|
self.tabNormalColor = [UIColor colorWithWhite:1 alpha:0.08];
|
||||||
self.tabSelectedColor = theme.accentColor ?: [UIColor colorWithWhite:1 alpha:0.25];
|
self.tabSelectedColor = theme.accentColor ?: [UIColor colorWithWhite:1 alpha:0.25];
|
||||||
[self updateTabHighlightStates];
|
[self updateTabHighlightStates];
|
||||||
|
if (self.deleteButton) {
|
||||||
|
self.deleteButton.backgroundColor = self.tabNormalColor;
|
||||||
|
UIColor *deleteTitleColor = theme.keyTextColor ?: [UIColor whiteColor];
|
||||||
|
[self.deleteButton setTitleColor:deleteTitleColor forState:UIControlStateNormal];
|
||||||
|
}
|
||||||
if (self.magnifierView) {
|
if (self.magnifierView) {
|
||||||
self.magnifierView.backgroundColor = theme.keyBackground ?: [UIColor colorWithWhite:1 alpha:0.9];
|
self.magnifierView.backgroundColor = theme.keyBackground ?: [UIColor colorWithWhite:1 alpha:0.9];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)emojiPanelViewDidTapDelete:(KBEmojiPanelView *)panel {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(keyBoardMainView:didTapKey:)]) {
|
||||||
|
KBKey *backspace = [KBKey keyWithTitle:@"" type:KBKeyTypeBackspace];
|
||||||
|
[self.delegate keyBoardMainView:self didTapKey:backspace];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Theme
|
#pragma mark - Theme
|
||||||
|
|
||||||
- (void)kb_applyTheme {
|
- (void)kb_applyTheme {
|
||||||
|
|||||||
Reference in New Issue
Block a user