Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ThemesAuswahl.m
- // iLach
- //
- // Created by Gilo Gambuzza on 15.10.09.
- // Copyright 2009 __MyCompanyName__. All rights reserved.
- //
- #import "ThemesAuswahl.h"
- @implementation ThemesAuswahl
- @synthesize lastIndexPath, cellBGDefault, cellBGElegance, cellBGCarbon;
- -(void)testTheme
- {
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
- NSString *theme = [prefs stringForKey:@"Theme"];
- if([theme isEqualToString:@"Elegance"])
- {
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
- }
- else if([theme isEqualToString:@"Carbon"])
- {
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
- }
- else
- {
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- }
- }
- - (void)viewDidLoad
- {
- self.tableView.separatorStyle = 0;
- self.tableView.backgroundColor = [UIColor clearColor];
- cellBGElegance.backgroundColor = [UIColor clearColor];
- cellBGElegance.backgroundColor = [UIColor clearColor];
- self.title = @"Themes";
- [super viewDidLoad];
- [self testTheme];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- - (void)viewDidUnload
- {
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 3;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *TopLevelCellIdentifier = @"TopLevelCellIdentifier";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TopLevelCellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:TopLevelCellIdentifier] autorelease];
- }
- NSUInteger row = [indexPath row];
- NSUInteger oldRow = [lastIndexPath row];
- cell.accessoryType = (row == oldRow && lastIndexPath != nil) ?
- UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
- cell.selectionStyle = UITableViewCellSelectionStyleGray;
- switch ([ indexPath indexAtPosition: 0]) {
- case(0):
- switch([ indexPath indexAtPosition: 1])
- {
- case(0):
- cell.backgroundView = cellBGDefault;
- break;
- case(1):
- cell.backgroundView = cellBGElegance;
- break;
- case(2):
- cell.backgroundView = cellBGCarbon;
- break;
- }
- break;
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 60;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- int newRow = [indexPath row];
- int oldRow = [lastIndexPath row];
- if (newRow != oldRow)
- {
- UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
- newCell.accessoryType = UITableViewCellAccessoryCheckmark;
- UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPath];
- oldCell.accessoryType = UITableViewCellAccessoryNone;
- lastIndexPath = indexPath;
- }
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- if(indexPath.row == 0)
- {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"DeafultBG.png"]];
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
- [prefs setObject:@"Default" forKey:kTheme];
- }
- if(indexPath.row == 1)
- {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
- self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"HolzBG.png"]];
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
- [prefs setObject:@"Elegance" forKey:kTheme];
- }
- if(indexPath.row == 2)
- {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
- self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"CarbonBG.png"]];
- NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
- [prefs setObject:@"Carbon" forKey:kTheme];
- }
- }
- - (void)dealloc
- {
- [cellBGCarbon release];
- [cellBGElegance release];
- [cellBGDefault release];
- [lastIndexPath release];
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment