diff --git a/CustomKeyboard/Resource/Christmas.zip b/CustomKeyboard/Resource/Christmas.zip new file mode 100644 index 0000000..cf469e8 Binary files /dev/null and b/CustomKeyboard/Resource/Christmas.zip differ diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index eabacb6..fc9fdb9 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -52,6 +52,7 @@ 04791F952ED48028004E8522 /* KBFeedBackVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 04791F942ED48028004E8522 /* KBFeedBackVC.m */; }; 04791F982ED49CE7004E8522 /* KBFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 04791F972ED49CE7004E8522 /* KBFont.m */; }; 04791F992ED49CE7004E8522 /* KBFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 04791F972ED49CE7004E8522 /* KBFont.m */; }; + 04791FF52ED5A487004E8522 /* Christmas.zip in Resources */ = {isa = PBXBuildFile; fileRef = 04791FF42ED5A487004E8522 /* Christmas.zip */; }; 047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; }; 047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; }; 047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C654F2EBCBA9E0035E841 /* KBShopVC.m */; }; @@ -262,6 +263,7 @@ 04791F942ED48028004E8522 /* KBFeedBackVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFeedBackVC.m; sourceTree = ""; }; 04791F962ED49CE7004E8522 /* KBFont.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBFont.h; sourceTree = ""; }; 04791F972ED49CE7004E8522 /* KBFont.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFont.m; sourceTree = ""; }; + 04791FF42ED5A487004E8522 /* Christmas.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Christmas.zip; sourceTree = ""; }; 047C650B2EBC8A840035E841 /* KBPanModalView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPanModalView.h; sourceTree = ""; }; 047C650C2EBC8A840035E841 /* KBPanModalView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPanModalView.m; sourceTree = ""; }; 047C650E2EBCA8DD0035E841 /* HomeRankContentVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankContentVC.h; sourceTree = ""; }; @@ -499,6 +501,7 @@ 041007D12ECE012000D203BB /* KBSkinIconMap.strings */, 041007D32ECE012500D203BB /* 002.zip */, 046131102ECF3A6E00A6FADF /* fense.zip */, + 04791FF42ED5A487004E8522 /* Christmas.zip */, ); path = Resource; sourceTree = ""; @@ -1450,6 +1453,7 @@ 046131112ECF3A6E00A6FADF /* fense.zip in Resources */, 041007D42ECE012500D203BB /* 002.zip in Resources */, 041007D22ECE012000D203BB /* KBSkinIconMap.strings in Resources */, + 04791FF52ED5A487004E8522 /* Christmas.zip in Resources */, 04286A0B2ECD88B400CE730C /* KeyboardAssets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/keyBoard/Class/Home/VC/FunctionTest/KBSkinCenterVC.m b/keyBoard/Class/Home/VC/FunctionTest/KBSkinCenterVC.m index d3e5c10..b51602b 100644 --- a/keyBoard/Class/Home/VC/FunctionTest/KBSkinCenterVC.m +++ b/keyBoard/Class/Home/VC/FunctionTest/KBSkinCenterVC.m @@ -9,6 +9,7 @@ #import "KBHUD.h" #import "KBConfig.h" #import "KBSkinService.h" +#import "KBSkinInstallBridge.h" @interface KBSkinCell : UITableViewCell @property (nonatomic, strong) UIButton *applyBtn; @@ -46,110 +47,12 @@ [super viewDidLoad]; // self.title = KBLocalized(@"皮肤中心"); self.view.backgroundColor = [UIColor whiteColor]; - - // 本地测试用的皮肤数据:结构与后端最终返回的 JSON 一致。 - // 说明: - // - background_image:背景大图 URL(此处仍使用 picsum 测试) - // - 颜色字段:background/key_bg/key_text/key_highlight/accent 与 KBSkinManager.applyThemeFromJSON 一致 - // - hidden_keys:需要隐藏文字的按键 identifier - // - key_icons: - // * 当 KB_SKIN_ICON_USE_REMOTE==0 时,value 写本地 Assets 名称(如 "kb_space_melon") - // * 当 KB_SKIN_ICON_USE_REMOTE==1 时,value 写 Zip 包内的图标“短文件名”(如 "key_space";解压后路径为 Skins//icons/key_space.png) -// self.skins = @[ -// @{ -// @"id": @"melon", -// @"name": KBLocalized(@"蜜瓜主题"), -// @"background_image": @"https://picsum.photos/id/1018/800/450.jpg", -// @"background": @"#F5FFE8", -// @"key_bg": @"#FFFFFF", -// @"key_text": @"#4A4A4A", -// @"key_highlight": @"#D9F4C4", -// @"accent": @"#A4D68A", -// @"hidden_keys": @[ -// @"letter_q",@"letter_w",@"letter_e",@"letter_r",@"letter_t", -// @"letter_y",@"letter_u",@"letter_i",@"letter_o",@"letter_p", -// @"letter_a",@"letter_s",@"letter_d",@"letter_f",@"letter_g", -// @"letter_h",@"letter_j",@"letter_k",@"letter_l", -// @"letter_z",@"letter_x",@"letter_c",@"letter_v", -// @"letter_b",@"letter_n",@"letter_m", -// @"space" -// ], -// // 默认假设本地测试:这里的值写 Assets 名称。 -// // 如果开启远程 Zip 模式,可改为 Zip 内对应的图标短文件名(如 "key_space")。 -// @"key_icons": @{ -// // 字母键:大小写共用一套本地图(演示用) -// // 若后续需要不同图,只需改为 *_lower / *_upper 对应不同资源名即可。 -// @"letter_q_lower": @"key_q", -// @"letter_q_upper": @"key_q", -// @"letter_w_lower": @"key_w", -// @"letter_w_upper": @"key_w", -// @"letter_e_lower": @"key_e", -// @"letter_e_upper": @"key_e", -// @"letter_r_lower": @"key_r", -// @"letter_r_upper": @"key_r", -// @"letter_t_lower": @"key_t", -// @"letter_t_upper": @"key_t", -// @"letter_y_lower": @"key_y", -// @"letter_y_upper": @"key_y", -// @"letter_u_lower": @"key_u", -// @"letter_u_upper": @"key_u", -// @"letter_i_lower": @"key_i", -// @"letter_i_upper": @"key_i", -// @"letter_o_lower": @"key_o", -// @"letter_o_upper": @"key_o", -// @"letter_p_lower": @"key_p", -// @"letter_p_upper": @"key_p", -// -// @"letter_a_lower": @"key_a", -// @"letter_a_upper": @"key_a", -// @"letter_s_lower": @"key_s", -// @"letter_s_upper": @"key_s", -// @"letter_d_lower": @"key_d", -// @"letter_d_upper": @"key_d", -// @"letter_f_lower": @"key_f", -// @"letter_f_upper": @"key_f", -// @"letter_g_lower": @"key_g", -// @"letter_g_upper": @"key_g", -// @"letter_h_lower": @"key_h", -// @"letter_h_upper": @"key_h", -// @"letter_j_lower": @"key_j", -// @"letter_j_upper": @"key_j", -// @"letter_k_lower": @"key_k", -// @"letter_k_upper": @"key_k", -// @"letter_l_lower": @"key_l", -// @"letter_l_upper": @"key_l", -// -// @"letter_z_lower": @"key_z", -// @"letter_z_upper": @"key_z", -// @"letter_x_lower": @"key_x", -// @"letter_x_upper": @"key_x", -// @"letter_c_lower": @"key_c", -// @"letter_c_upper": @"key_c", -// @"letter_v_lower": @"key_v", -// @"letter_v_upper": @"key_v", -// @"letter_b_lower": @"key_b", -// @"letter_b_upper": @"key_b", -// @"letter_n_lower": @"key_n", -// @"letter_n_upper": @"key_n", -// @"letter_m_lower": @"key_m", -// @"letter_m_upper": @"key_m", -// -// // 功能键(无大小写变体) -// @"space": @"key_space", // 空格键 -// @"backspace": @"key_del", // 删除键 -// @"shift": @"key_up", // Shift(上箭头) -// @"mode_123": @"key_123", // 字母面板左下角 "123" -// @"ai": @"key_ai", // 自定义 AI 键 -// @"return": @"key_send" // 发送/换行键 -// } -// } -// ]; self.skins = @[ @{ - @"id": @"local001", - @"name": KBLocalized(@"本地001皮肤"), + @"id": @"local002", + @"name": KBLocalized(@"本地002皮肤"), // 关键:zip_url 写成 bundle:// 前缀 + 文件名 - @"zip_url": @"bundle://001.zip", + @"zip_url": @"bundle://002.zip", // 颜色你可以先随便写一套,或者继承默认 @"background": @"#F5FFE8", @@ -158,7 +61,35 @@ @"key_highlight": @"#D9F4C4", @"accent": @"#A4D68A" // 不写 key_icons,代码会自动用本地那份映射表 - } + }, + @{ + @"id": @"remote002", + @"name": KBLocalized(@"远程皮肤"), + // 关键:zip_url 写成 bundle:// 前缀 + 文件名 + @"zip_url": @"", + +// // 颜色你可以先随便写一套,或者继承默认 +// @"background": @"#F5FFE8", +// @"key_bg": @"#FFFFFF", +// @"key_text": @"#4A4A4A", +// @"key_highlight": @"#D9F4C4", +// @"accent": @"#A4D68A" + // 不写 key_icons,代码会自动用本地那份映射表 + }, + @{ + @"id": @"圣诞001", + @"name": KBLocalized(@"本地圣诞皮肤"), + // 关键:zip_url 写成 bundle:// 前缀 + 文件名 + @"zip_url": @"bundle://Christmas.zip", + + // 颜色你可以先随便写一套,或者继承默认 + @"background": @"#F5FFE8", + @"key_bg": @"#FFFFFF", + @"key_text": @"#4A4A4A", + @"key_highlight": @"#D9F4C4", + @"accent": @"#A4D68A" + // 不写 key_icons,代码会自动用本地那份映射表 + }, ]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, KB_NAV_TOTAL_HEIGHT, KB_SCREEN_WIDTH, KB_SCREEN_HEIGHT - KB_NAV_TOTAL_HEIGHT) style:UITableViewStyleInsetGrouped]; @@ -213,10 +144,29 @@ if (idx < 0 || idx >= self.skins.count) return; NSDictionary *skin = self.skins[idx]; if (!skin) return; - [[KBSkinService shared] applySkinWithJSON:skin - fromViewController:self - mode:KBSkinSourceModeLocalBundleZip - completion:nil]; + if (idx == 0) { + [[KBSkinService shared] applySkinWithJSON:skin + fromViewController:self + mode:KBSkinSourceModeLocalBundleZip + completion:nil]; + }else if (idx == 1){ + [[KBSkinService shared] applySkinWithJSON:skin + fromViewController:self + mode:KBSkinSourceModeRemoteZip + completion:nil]; + }else if (idx == 2){ +// [[KBSkinService shared] applySkinWithJSON:skin +// fromViewController:self +// mode:KBSkinSourceModeLocalBundleZip +// completion:nil]; + static NSString * const kKBBundleSkinId002 = @"bundle_Christmas"; + [KBSkinInstallBridge publishBundleSkinRequestWithId:kKBBundleSkinId002 + name:@"" ?: kKBBundleSkinId002 + zipName:@"Christmas.zip" + iconShortNames:nil]; + [KBHUD showInfo:KBLocalized(@"已通知键盘解压,切换到自定义键盘即可生效")]; + } + } - (void)onResetDefault:(UIButton *)sender { diff --git a/keyBoard/Class/Manager/KBSkinService.m b/keyBoard/Class/Manager/KBSkinService.m index 282ef29..c34ac3e 100644 --- a/keyBoard/Class/Manager/KBSkinService.m +++ b/keyBoard/Class/Manager/KBSkinService.m @@ -62,7 +62,7 @@ // 本地 bundle 模式:zip_url 为 bundle 内的 zip 文件名 [self kb_applySkinUsingLocalBundle:skinJSON completion:completion]; break; - case KBSkinSourceModeRemoteZip: +// case KBSkinSourceModeRemoteZip: default: // 远程模式:zip_url 为 http/https 地址 [self kb_applySkinUsingRemoteIcons:skinJSON completion:completion];