添加扩展键盘本地皮肤
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#import "KBKeyboardPermissionManager.h"
|
||||
#import "KBNetworkManager.h"
|
||||
#import "KBHUD.h"
|
||||
#import "KBSkinInstallBridge.h"
|
||||
|
||||
#if __has_include(<SSZipArchive/SSZipArchive.h>)
|
||||
#import <SSZipArchive/SSZipArchive.h>
|
||||
@@ -19,28 +20,6 @@
|
||||
|
||||
#pragma mark - Icon short-name mapping (local default)
|
||||
|
||||
/// 本地维护的一份“逻辑按键标识 -> 图标短文件名”映射表。
|
||||
/// - 若后端 skinJSON 未提供 key_icons,则远程 Zip 模式会回退使用本表;仅依赖 zip_url + 命名规范即可。
|
||||
+ (NSDictionary<NSString *, NSString *> *)kb_defaultIconShortNames {
|
||||
static NSDictionary<NSString *, NSString *> *map;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
// 从配置文件加载映射,避免在代码里维护大段字面量。
|
||||
// 使用 .strings 形式,便于为每个键添加注释。
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"KBSkinIconMap" ofType:@"strings"];
|
||||
if (path.length > 0) {
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
|
||||
if ([dict isKindOfClass:NSDictionary.class]) {
|
||||
map = dict;
|
||||
}
|
||||
}
|
||||
if (!map) {
|
||||
map = @{}; // 防御:配置缺失时返回空表,避免崩溃
|
||||
}
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
+ (instancetype)shared {
|
||||
static KBSkinService *s; static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{ s = [KBSkinService new]; });
|
||||
@@ -104,12 +83,12 @@
|
||||
|
||||
// key_icons 可选:
|
||||
// - 若后端提供 key_icons,则优先使用服务端映射;
|
||||
// - 若未提供,则回退到本地默认映射(kb_defaultIconShortNames),这样后端只需返回 id/name/zip_url。
|
||||
// - 若未提供,则回退到本地默认映射(KBSkinInstallBridge.defaultIconShortNames),这样后端只需返回 id/name/zip_url。
|
||||
NSDictionary *iconShortNames = nil;
|
||||
if ([skin[@"key_icons"] isKindOfClass:NSDictionary.class]) {
|
||||
iconShortNames = skin[@"key_icons"];
|
||||
} else {
|
||||
iconShortNames = [self.class kb_defaultIconShortNames];
|
||||
iconShortNames = [KBSkinInstallBridge defaultIconShortNames];
|
||||
}
|
||||
|
||||
NSURL *containerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:AppGroup];
|
||||
@@ -284,7 +263,7 @@
|
||||
if ([skin[@"key_icons"] isKindOfClass:NSDictionary.class]) {
|
||||
iconShortNames = skin[@"key_icons"];
|
||||
} else {
|
||||
iconShortNames = [self.class kb_defaultIconShortNames];
|
||||
iconShortNames = [KBSkinInstallBridge defaultIconShortNames];
|
||||
}
|
||||
|
||||
NSURL *containerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:AppGroup];
|
||||
|
||||
@@ -93,8 +93,8 @@
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
// KBTestVC *vc = [[KBTestVC alloc] init];
|
||||
// [self.navigationController pushViewController:vc animated:true];
|
||||
KBTestVC *vc = [[KBTestVC alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:true];
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "KBSkinCardCell.h"
|
||||
#import "KBSkinInstallBridge.h"
|
||||
#import "KBHUD.h"
|
||||
|
||||
@interface KBShopItemVC ()<UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
||||
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
|
||||
@@ -113,6 +115,21 @@
|
||||
return 12.0;
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
[self kb_handleShopTapAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (void)kb_handleShopTapAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *title = (indexPath.item < self.dataSource.count) ? self.dataSource[indexPath.item] : KBLocalized(@"专属皮肤002");
|
||||
// 将需求固定到 002.zip,本地写死皮肤 id,便于键盘扩展识别并解压。
|
||||
static NSString * const kKBBundleSkinId002 = @"bundle_skin_002";
|
||||
[KBSkinInstallBridge publishBundleSkinRequestWithId:kKBBundleSkinId002
|
||||
name:title ?: kKBBundleSkinId002
|
||||
zipName:@"002.zip"
|
||||
iconShortNames:nil];
|
||||
[KBHUD showInfo:KBLocalized(@"已通知键盘解压,切换到自定义键盘即可生效")];
|
||||
}
|
||||
|
||||
#pragma mark - UIScrollView Delegate(转发给分页容器)
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
!self.scrollCallback ?: self.scrollCallback(scrollView);
|
||||
|
||||
Reference in New Issue
Block a user