This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
forked from efrederickson/SettingsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SKStandardController.m
158 lines (142 loc) · 5.85 KB
/
SKStandardController.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#import "SKStandardController.h"
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
#import "common.h"
@implementation SKStandardController
-(BOOL) showHeartImage { return YES; }
-(BOOL) tintNavigationTitleText { return NO; }
-(BOOL) shiftHeartImage { return YES; }
-(NSString*) enabledDescription { return @"test"; }
-(BOOL) hasCellIcons { return YES; }
-(NSString *) enableLabelText {return @"ENABLE";}
-(NSString *) optionsLabelText {return @"OPTIONS";}
-(NSString *) makersLabelText {return @"MAKERS";}
-(NSString *) supportLabelText {return @"SUPPORT";}
-(NSArray*) customSpecifiers
{
/*
need a simpler way for hasCellIcons
like @"icon": (hasCellIcons ? @"enabled.png" : nill)
I don't know much about Obj-C yet.
and I don't want to complicate it with an NSMuteableDictionary array
*/
if (self.hasCellIcons) {
return @[
@{ @"cell": @"PSGroupCell",
@"footerText": self.enabledDescription
},
@{
@"cell": @"PSSwitchCell",
@"default": @YES,
@"defaults": self.defaultsFileName,
@"key": @"enabled",
@"label": self.enableLabelText,
@"PostNotification": self.postNotification,
@"cellClass": @"SKTintedSwitchCell",
@"icon": @"enabled.png",
},
@{ @"cell": @"PSGroupCell" },
@{
@"cell": @"PSLinkCell",
//@"action": @"loadSettingsListController",
@"detail": self.settingsListControllerClassName,
@"label": self.optionsLabelText,
@"icon": @"settings.png",
@"cellClass": @"SKTintedCell",
},
@{ @"cell": @"PSGroupCell" },
@{
@"cell": @"PSLinkCell",
//@"action": @"loadMakersListController",
@"detail": self.makersListControllerClassName,
@"label": self.makersLabelText,
@"icon": @"makers.png",
@"cellClass": @"SKTintedCell",
},
@{ @"cell": @"PSGroupCell",
@"footerText": self.footerText, },
@{
@"cell": @"PSLinkCell",
@"action": @"showSupportDialog",
@"label": self.supportLabelText,
@"icon": @"support.png",
@"cellClass": @"SKTintedCell",
},
];
} else {
return @[
@{ @"cell": @"PSGroupCell",
@"footerText": self.enabledDescription
},
@{
@"cell": @"PSSwitchCell",
@"default": @YES,
@"defaults": self.defaultsFileName,
@"key": @"enabled",
@"label": self.enableLabelText,
@"PostNotification": self.postNotification,
@"cellClass": @"SKTintedSwitchCell",
},
@{ @"cell": @"PSGroupCell" },
@{
@"cell": @"PSLinkCell",
//@"action": @"loadSettingsListController",
@"detail": self.settingsListControllerClassName,
@"label": self.optionsLabelText,
@"cellClass": @"SKTintedCell",
},
@{ @"cell": @"PSGroupCell" },
@{
@"cell": @"PSLinkCell",
//@"action": @"loadMakersListController",
@"detail": self.makersListControllerClassName,
@"label": self.makersLabelText,
@"cellClass": @"SKTintedCell",
},
@{ @"cell": @"PSGroupCell",
@"footerText": self.footerText, },
@{
@"cell": @"PSLinkCell",
@"action": @"showSupportDialog",
@"label": self.supportLabelText,
@"cellClass": @"SKTintedCell",
},
];
}
}
-(NSString*)postNotification { return @""; }
-(NSString*)defaultsFileName { return @""; }
-(NSArray*) emailAddresses { return @[]; }
-(NSString*) emailBody { return @""; }
-(NSString*) emailSubject { return @""; }
//-(void) loadSettingsListController { }
//-(void) loadMakersListController { }
-(NSString*) footerText { return @""; }
-(NSString*) settingsListControllerClassName { return @""; }
-(NSString*) makersListControllerClassName { return @""; }
-(void) showSupportDialog
{
MFMailComposeViewController *mailViewController;
if ([MFMailComposeViewController canSendMail])
{
mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:SK_LCL(self.emailSubject)];
[mailViewController setMessageBody:SK_LCL(self.emailBody) isHTML:NO];
[mailViewController setToRecipients:self.emailAddresses];
[self.rootController presentViewController:mailViewController animated:YES completion:nil];
}
}
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(UIColor*) iconColor
{
if ([self respondsToSelector:@selector(navigationTintColor)])
return self.navigationTintColor;
if ([self respondsToSelector:@selector(tintColor)])
return self.tintColor;
else
return [UIColor whiteColor];
}
@end