-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccvibrato.m
54 lines (42 loc) · 1.55 KB
/
ccvibrato.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
#import "ccvibrato.h"
@implementation ccvibrato
// Most third-party Control Center modules out there use non-CAML approach because it's easier to get icon images than create CAML
// Choose either CAML and non-CAML portion of the code for your final implementation of the toggle
// IMPORTANT: To prepare your icons and configure the toggle to its fullest, check out CCSupport Wiki: https://github.com/opa334/CCSupport/wiki
{
NSUserDefaults* vibrationDefault;
}
#pragma mark - Non-CAML approach
-(id)init {
self = [super init];
if(!self) return nil;
vibrationDefault = [[NSUserDefaults alloc] initWithSuiteName:nil];
return self;
}
// Icon of your module
- (UIImage *)iconGlyph {
return [UIImage imageNamed:@"icon" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
}
// Optional: Icon of your module, once selected
- (UIImage *)selectedIconGlyph {
return [UIImage imageNamed:@"icon-selected" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
}
// Selected color of your module
- (UIColor *)selectedColor {
return UIColor.systemBlueColor;
}
#pragma mark - End Non-CAML approach
// Current state of your module
- (BOOL)isSelected {
BOOL selectionBool = ![vibrationDefault boolForKey:@"silent-vibrate"];
return selectionBool;
}
- (void)setSelected:(BOOL)selected {
BOOL passBool;
passBool = !selected;
[vibrationDefault setBool:passBool forKey:@"silent-vibrate"];
[vibrationDefault synchronize];
[super refreshState];
[super setSelected:passBool];
}
@end