-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCPreferencesManager.m
59 lines (44 loc) · 1.36 KB
/
SCPreferencesManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#import "SCPreferencesManager.h"
#import <Cephei/HBPreferences.h>
#import <libcolorpicker.h>
static NSString *const kSCEnabledKey = @"isImageEnabled";
static NSString *const kSCEnabledTKey = @"isTintEnabled";
@implementation SCPreferencesManager {
HBPreferences *_preferences;
}
+ (instancetype)sharedInstance {
static SCPreferencesManager *sharedInstance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
- (instancetype)init {
if (self = [super init]) {
_preferences = [[HBPreferences alloc] initWithIdentifier:@"com.wizage.SpringPrefs"];
[_preferences registerBool:&_isImageEnabled default:NO forKey:kSCEnabledKey];
[_preferences registerBool:&_isTintEnabled default:YES forKey:kSCEnabledTKey];
}
return self;
}
- (UIColor *)colorForPreference:(NSString *)string fallback:(NSString *)fallback {
NSString *potentialIndividualTint = _preferences[string];
if (potentialIndividualTint) {
return LCPParseColorString(potentialIndividualTint, @"#000000");
}
return LCPParseColorString(fallback, @"#000000");
}
-(UIImage *)imageForShowing{
NSData *imageData = _preferences[@"photo"];
if (imageData == nil){
return nil;
}
return [[UIImage alloc]initWithData:imageData];
}
#pragma mark - Memory management
- (void)dealloc {
[_preferences release];
[super dealloc];
}
@end