-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsEditor.m
125 lines (106 loc) · 3.79 KB
/
SettingsEditor.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
//
// SettingsEditor.m
// Allowance
//
// Created by Pablo Collins on 7/5/10.
//
#import "SettingsEditor.h"
@implementation SettingsEditor
@synthesize opener;
- (void)viewDidLoad {
self.title = @"Settings";
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
switch (section) {
case 0:
return @"Allowance Day";
break;
default:
return nil;
break;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
return section == 0 ? @"Allowance will be credited automatically once a week." : nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
switch ([indexPath indexAtPosition:0]) {
case 0:
cell = [self payDayCell];
break;
case 1:
cell = [self doneCell];
break;
default:
break;
}
return cell;
}
- (void)pushAllowanceDayEditor {
AllowanceDayEditor *e = [[AllowanceDayEditor alloc] initWithNibName:@"AllowanceDayEditor" bundle:nil];
e.reloadableParent = self;
[self.navigationController pushViewController:e animated:YES];
}
/*
- (void)pushCurrencyEditor {
CurrencyEditor *e = [[CurrencyEditor alloc] initWithNibName:@"CurrencyEditor" bundle:nil];
e.reloadableParent = self;
[self.navigationController pushViewController:e animated:YES];
[e release];
}
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch ([indexPath section]) {
case 0:
[self pushAllowanceDayEditor];
break;
default:
break;
}
}
- (UITableViewCell *)payDayCell {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int payDay = [defaults integerForKey:@"payDay"];
cell.textLabel.text = [WeekDays nameForNum:[NSNumber numberWithInt:payDay]];
return cell;
}
/*
- (UITableViewCell *)currencyCell {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = [NSString stringWithFormat:@"%@12%@34",[AllowanceAppDelegate currency],[AllowanceAppDelegate delimiter]];
return cell;
}
*/
- (UITableViewCell *)doneCell {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell2"];
UIImage *blueImage = [UIImage imageNamed:@"blueButton.png"];
UIImage *whiteImage = [UIImage imageNamed:@"whiteButton.png"];
CGRect frame = cell.bounds;
frame.size.width = 300; //originally 320
UIButton *btn = [AllowanceAppDelegate newButtonWithTitle:@"Done"
target:self
selector:@selector(doneButtonClicked:)
frame:frame
image:whiteImage
imagePressed:blueImage
darkTextColor:YES];
[cell.contentView addSubview:btn];
return cell;
}
- (void)readAndReload {
[self.tableView reloadData];
}
- (void)doneButtonClicked:(id)sender {
[opener dismissModalEditor];
}
@end