-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScrollyPrefManager.m
62 lines (46 loc) · 1.6 KB
/
ScrollyPrefManager.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
60
61
62
#import "ScrollyPrefManager.h"
#import <Cephei/HBPreferences.h>
static NSString *const kSMEnabledKey = @"enabled";
static NSString *const kSMTopEnabledKey = @"top_enabled";
static NSString *const kSMBotEnabledKey = @"bot_enabled";
static NSString *const kSMTopIntKey = @"top_intensity";
static NSString *const kSMBotIntKey = @"bot_intensity";
@interface HBPreferences (private)
-(void)_preferencesChanged;
@end
@implementation ScrollyPrefManager {
HBPreferences *_preferences;
}
+ (instancetype)sharedInstance {
static ScrollyPrefManager *sharedInstance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
[sharedInstance updatePrefs];
return sharedInstance;
}
-(void)updatePrefs
{
[_preferences _preferencesChanged];
}
- (instancetype)init {
if (self = [super init]) {
_preferences = [[HBPreferences alloc] initWithIdentifier:@"com.wizages.scrollyprefs"];
[_preferences registerBool:&_enabled default:true forKey:kSMEnabledKey];
[_preferences registerBool:&_top_enabled default:true forKey:kSMTopEnabledKey];
[_preferences registerInteger:&_top_intensity default:10 forKey:kSMTopIntKey];
[_preferences registerBool:&_bot_enabled default:true forKey:kSMBotEnabledKey];
[_preferences registerInteger:&_bot_intensity default:10 forKey:kSMBotIntKey];
}
return self;
}
-(BOOL)isApplicationEnabled:(NSString *)bundleName{
return [_preferences boolForKey:[NSString stringWithFormat:@"disabled-%@", bundleName] default:false];
}
#pragma mark - Memory management
- (void)dealloc {
[_preferences release];
[super dealloc];
}
@end