23 -(void) viewDidLoad { |
23 -(void) viewDidLoad { |
24 [super viewDidLoad]; |
24 [super viewDidLoad]; |
25 |
25 |
26 CGSize screenSize = [[UIScreen mainScreen] bounds].size; |
26 CGSize screenSize = [[UIScreen mainScreen] bounds].size; |
27 self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); |
27 self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); |
|
28 self.tableView.backgroundColor = [UIColor redColor]; |
28 } |
29 } |
29 |
30 |
30 -(void) viewWillAppear:(BOOL)animated { |
31 -(void) viewWillAppear:(BOOL)animated { |
31 [super viewWillAppear:animated]; |
32 [super viewWillAppear:animated]; |
32 |
33 |
33 unsigned int colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 }; |
34 // integer representation of various color (defined in SquareButtonView) |
|
35 NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 }; |
34 NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL]; |
36 NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL]; |
35 NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]]; |
37 NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]]; |
36 for (int i = 0; i < [contentsOfDir count]; i++) { |
38 for (int i = 0; i < [contentsOfDir count]; i++) { |
37 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
39 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
38 [contentsOfDir objectAtIndex:i],@"team", |
40 [contentsOfDir objectAtIndex:i],@"team", |
49 [emptyArray release]; |
51 [emptyArray release]; |
50 |
52 |
51 [self.tableView reloadData]; |
53 [self.tableView reloadData]; |
52 } |
54 } |
53 |
55 |
54 /* |
|
55 - (void)viewDidAppear:(BOOL)animated { |
|
56 [super viewDidAppear:animated]; |
|
57 } |
|
58 */ |
|
59 /* |
|
60 - (void)viewWillDisappear:(BOOL)animated { |
|
61 [super viewWillDisappear:animated]; |
|
62 } |
|
63 */ |
|
64 /* |
|
65 - (void)viewDidDisappear:(BOOL)animated { |
|
66 [super viewDidDisappear:animated]; |
|
67 } |
|
68 */ |
|
69 |
|
70 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
56 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
71 return rotationManager(interfaceOrientation); |
57 return rotationManager(interfaceOrientation); |
72 } |
58 } |
73 |
59 |
74 |
60 |
91 else |
77 else |
92 return NSLocalizedString(@"Available Teams",@""); |
78 return NSLocalizedString(@"Available Teams",@""); |
93 } |
79 } |
94 |
80 |
95 // Customize the appearance of table view cells. |
81 // Customize the appearance of table view cells. |
96 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
82 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
97 static NSString *CellIdentifier0 = @"Cell0"; |
83 static NSString *CellIdentifier0 = @"Cell0"; |
98 static NSString *CellIdentifier1 = @"Cell1"; |
84 static NSString *CellIdentifier1 = @"Cell1"; |
99 NSInteger section = [indexPath section]; |
85 NSInteger section = [indexPath section]; |
100 UITableViewCell *cell; |
86 UITableViewCell *cell; |
101 |
87 |
102 if (section == 0) { |
88 if (section == 0) { |
103 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
89 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
104 if (cell == nil) { |
90 if (cell == nil) { |
105 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
91 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
106 |
92 |
107 UIButton *numberButton = [[HogButtonView alloc] initWithFrame:CGRectMake(12, 5, 88, 32)]; |
93 UIButton *numberButton = [[HogButtonView alloc] initWithFrame:CGRectMake(12, 5, 88, 32)]; |
108 numberButton.tag = NUMBERBUTTON_TAG; |
94 numberButton.tag = NUMBERBUTTON_TAG; |
134 |
120 |
135 SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG]; |
121 SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG]; |
136 [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]]; |
122 [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]]; |
137 squareButton.ownerDictionary = selectedRow; |
123 squareButton.ownerDictionary = selectedRow; |
138 } else { |
124 } else { |
139 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
125 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
140 if (cell == nil) |
126 if (cell == nil) |
141 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease]; |
127 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease]; |
142 |
128 |
143 cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension]; |
129 cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension]; |
144 } |
130 } |
185 } |
171 } |
186 */ |
172 */ |
187 |
173 |
188 #pragma mark - |
174 #pragma mark - |
189 #pragma mark Table view delegate |
175 #pragma mark Table view delegate |
190 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
176 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
191 NSInteger row = [indexPath row]; |
177 NSInteger row = [indexPath row]; |
192 NSInteger section = [indexPath section]; |
178 NSInteger section = [indexPath section]; |
193 |
179 |
194 if (section == 0) { |
180 if (section == 0) { |
195 [self.listOfTeams addObject:[self.listOfSelectedTeams objectAtIndex:row]]; |
181 [self.listOfTeams addObject:[self.listOfSelectedTeams objectAtIndex:row]]; |
196 [self.listOfSelectedTeams removeObjectAtIndex:row]; |
182 [self.listOfSelectedTeams removeObjectAtIndex:row]; |
197 } else { |
183 } else { |
198 [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]]; |
184 [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]]; |
199 [self.listOfTeams removeObjectAtIndex:row]; |
185 [self.listOfTeams removeObjectAtIndex:row]; |
200 } |
186 } |
201 [self.tableView reloadData]; |
187 [aTableView reloadData]; |
202 } |
188 } |
203 |
189 |
204 |
190 |
205 #pragma mark - |
191 #pragma mark - |
206 #pragma mark Memory management |
192 #pragma mark Memory management |