59 lines
2.2 KiB
Objective-C
59 lines
2.2 KiB
Objective-C
//
|
|
// KBSkinManager.h
|
|
// App & Keyboard Extension shared skin/theme manager.
|
|
//
|
|
// Stores a lightweight theme (colors, identifiers) to shared keychain so
|
|
// both targets see the same current skin. Cross-process updates are delivered
|
|
// via Darwin notification. Intended for immediate reflection in extension.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <UIKit/UIKit.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
extern NSString * const KBSkinDidChangeNotification; // in-process
|
|
extern NSString * const KBDarwinSkinChanged; // cross-process
|
|
|
|
/// Simple theme model (colors only; assets can be added later via App Group)
|
|
@interface KBSkinTheme : NSObject <NSSecureCoding>
|
|
@property (nonatomic, copy) NSString *skinId; // e.g. "mint"
|
|
@property (nonatomic, copy) NSString *name; // display name
|
|
@property (nonatomic, strong) UIColor *keyboardBackground;
|
|
@property (nonatomic, strong) UIColor *keyBackground;
|
|
@property (nonatomic, strong) UIColor *keyTextColor;
|
|
@property (nonatomic, strong) UIColor *keyHighlightBackground; // selected/highlighted
|
|
@property (nonatomic, strong) UIColor *accentColor; // function view accents
|
|
/// 可选:键盘背景图片的 PNG/JPEG 数据(若存在,优先显示图片)
|
|
@property (nonatomic, strong, nullable) NSData *backgroundImageData;
|
|
@end
|
|
|
|
/// Shared skin manager (Keychain Sharing based)
|
|
@interface KBSkinManager : NSObject
|
|
|
|
+ (instancetype)shared;
|
|
|
|
@property (atomic, strong, readonly) KBSkinTheme *current; // never nil (fallback to default)
|
|
|
|
/// Save theme from JSON dictionary (keys: id, name, background, key_bg, key_text, key_highlight, accent)
|
|
- (BOOL)applyThemeFromJSON:(NSDictionary *)json;
|
|
|
|
/// Save explicit theme
|
|
- (BOOL)applyTheme:(KBSkinTheme *)theme;
|
|
|
|
/// Reset to default theme
|
|
- (void)resetToDefault;
|
|
|
|
/// 直接应用图片皮肤(使用 JPEG/PNG 数据)。建议大小 < 512KB。
|
|
- (BOOL)applyImageSkinWithData:(NSData *)imageData skinId:(NSString *)skinId name:(NSString *)name;
|
|
|
|
/// 当前背景图片(若存在)
|
|
- (nullable UIImage *)currentBackgroundImage;
|
|
|
|
/// Parse a hex color string like "#RRGGBB"/"#RRGGBBAA"
|
|
+ (UIColor *)colorFromHexString:(NSString *)hex defaultColor:(UIColor *)fallback;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|