/
ApplicationHelper.m
125 lines (102 loc) · 3.05 KB
/
ApplicationHelper.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
//
// ApplicationHelper.m
// Ideas
//
// Created by Oscar Del Ben on 1/2/11.
// Copyright 2011 Dibi Store di Del Ben Oscar. All rights reserved.
//
#import "ApplicationHelper.h"
@implementation ApplicationHelper
+ (void)showApplicationError
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"We experienced an error. Please quit the application by pressing the Home button."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
+ (NSDictionary *)themes
{
NSArray *keys = [NSArray arrayWithObjects:@"name", @"red", @"green", @"blue", @"background", @"foreground", @"selected", nil];
NSDictionary *theme1 = [NSDictionary
dictionaryWithObjects:
[NSArray arrayWithObjects:
@"Ocean",
[NSNumber numberWithInt:19],
[NSNumber numberWithInt:60],
[NSNumber numberWithInt:101],
@"bg-white.png",
@"bg-yellow.png",
@"bg-yellow.png",
nil]
forKeys: keys];
NSDictionary *theme2 = [NSDictionary
dictionaryWithObjects:
[NSArray arrayWithObjects:
@"Vibrant",
[NSNumber numberWithInt:101],
[NSNumber numberWithInt:94],
[NSNumber numberWithInt:57],
@"bg-blue.png",
@"bg-yellow.png",
@"bg-yellow.png",
nil]
forKeys: keys];
NSDictionary *theme3 = [NSDictionary
dictionaryWithObjects:
[NSArray arrayWithObjects:
@"Fashion",
[NSNumber numberWithInt:208],
[NSNumber numberWithInt:31],
[NSNumber numberWithInt:60],
@"bg-white.png",
@"bg-yellow.png",
@"bg-yellow.png",
nil]
forKeys: keys];
NSDictionary *theme4 = [NSDictionary
dictionaryWithObjects:
[NSArray arrayWithObjects:
@"Nature",
[NSNumber numberWithInt:53],
[NSNumber numberWithInt:161],
[NSNumber numberWithInt:95],
@"bg-green-dark.png",
@"bg-green-light.png",
@"bg-green-middle.png",
nil]
forKeys: keys];
NSDictionary *themes = [NSDictionary
dictionaryWithObjects:[NSArray arrayWithObjects:
theme1, theme2, theme3, theme4, nil]
forKeys:[NSArray arrayWithObjects:
@"theme1", @"theme2", @"theme3", @"theme4", nil]];
return themes;
}
+ (NSDictionary *)theme
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *themeID = [userDefaults objectForKey:@"themeID"];
if (themeID == nil) {
return [[self themes] objectForKey:@"theme1"];
} else {
return [[self themes] objectForKey:themeID];
}
}
+ (void)saveTheme:(NSString *)themeID
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:themeID forKey:@"themeID"];
}
+ (NSString *)recipient
{
NSUserDefaults *useDefaults = [NSUserDefaults standardUserDefaults];
NSString *recipient = [useDefaults objectForKey:@"recipient"];
if (recipient == nil) {
return @"";
} else {
return recipient;
}
}
@end