This commit is contained in:
2025-11-10 21:33:00 +08:00
parent dc0c55c495
commit 9059a24637
9 changed files with 258 additions and 7 deletions

View File

@@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface KBMyKeyBoardVC : UIViewController
@interface KBMyKeyBoardVC : BaseViewController
@end

View File

@@ -9,6 +9,7 @@
#import "BMLongPressDragCellCollectionView.h"
#import "UICollectionViewLeftAlignedLayout.h"
#import "KBMyKeyboardCell.h"
#import "KBAlert.h"
///
static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
@@ -24,6 +25,7 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
@property (nonatomic, strong) UIView *sheetView; //
@property (nonatomic, strong) BMLongPressDragCellCollectionView *collectionView; //
@property (nonatomic, strong) UIButton *saveButton; //
@property (nonatomic, strong) UIImageView *bgImageView; //
//
@property (nonatomic, strong) NSMutableArray<NSMutableArray<NSDictionary *> *> *dataSourceArray; // {emoji,title}
@@ -39,13 +41,18 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithHex:0xF6F8F9];
self.navigationController.title = @"My KeyBoard";
self.kb_navView.backgroundColor = [UIColor clearColor];
self.kb_titleLabel.text = @"My KeyBoard";
//
[self.view insertSubview:self.bgImageView belowSubview:self.kb_navView];
[self.view addSubview:self.sheetView];
[self.sheetView addSubview:self.collectionView];
[self.view addSubview:self.saveButton];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.height.mas_equalTo(323);
}];
[self.sheetView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT + 60);
@@ -149,6 +156,46 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
KBMyKeyboardCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kKBMyKeyboardCellId forIndexPath:indexPath];
NSDictionary *d = self.dataSourceArray[indexPath.section][indexPath.item];
[cell configEmoji:d[@"emoji"] title:d[@"title"]];
__weak typeof(self) weakSelf = self;
__weak typeof(collectionView) weakCV = collectionView;
cell.onMinusTapped = ^(KBMyKeyboardCell * _Nonnull tappedCell) {
__strong typeof(weakSelf) self = weakSelf;
if (!self) { return; }
NSIndexPath *tapIndexPath = [weakCV indexPathForCell:tappedCell];
if (!tapIndexPath) { return; }
// [KBAlert confirmTitle:@"删除该标签?" message:@"删除后不可恢复" completion:^(BOOL ok) {
// if (!ok) { return; }
// // item
// if (tapIndexPath.section < self.dataSourceArray.count) {
// NSMutableArray *section = self.dataSourceArray[tapIndexPath.section];
// if (tapIndexPath.item < section.count) {
// [section removeObjectAtIndex:tapIndexPath.item];
// [self.collectionView performBatchUpdates:^{
// [self.collectionView deleteItemsAtIndexPaths:@[tapIndexPath]];
// } completion:nil];
// }
// }
// }];
[KBAlert confirmTitle:@"删除该标签?"
message:@"删除后不可恢复"
ok:@"确定"
cancel:@"取消"
okColor:[UIColor redColor]
cancelColor:[UIColor blackColor]
completion:^(BOOL ok) {
if (!ok) { return; }
// item
if (tapIndexPath.section < self.dataSourceArray.count) {
NSMutableArray *section = self.dataSourceArray[tapIndexPath.section];
if (tapIndexPath.item < section.count) {
[section removeObjectAtIndex:tapIndexPath.item];
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:@[tapIndexPath]];
} completion:nil];
}
}
}];
};
return cell;
}
@@ -237,4 +284,12 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
return _saveButton;
}
- (UIImageView *)bgImageView{
if (!_bgImageView) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.image = [UIImage imageNamed:@"my_keyboard_bg"];
}
return _bgImageView;
}
@end