Guest User

Untitled

a guest
Jul 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. //
  2. // ThemesAuswahl.m
  3. // iLach
  4. //
  5. // Created by Gilo Gambuzza on 15.10.09.
  6. // Copyright 2009 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "ThemesAuswahl.h"
  10.  
  11.  
  12. @implementation ThemesAuswahl
  13. @synthesize lastIndexPath, cellBGDefault, cellBGElegance, cellBGCarbon;
  14.  
  15. -(void)testTheme
  16. {
  17. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  18. NSString *theme = [prefs stringForKey:@"Theme"];
  19.  
  20. if([theme isEqualToString:@"Elegance"])
  21. {
  22. self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
  23. }
  24.  
  25. else if([theme isEqualToString:@"Carbon"])
  26. {
  27. self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
  28. }
  29.  
  30. else
  31. {
  32. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  33. }
  34. }
  35.  
  36. - (void)viewDidLoad
  37. {
  38. self.tableView.separatorStyle = 0;
  39. self.tableView.backgroundColor = [UIColor clearColor];
  40. cellBGElegance.backgroundColor = [UIColor clearColor];
  41. cellBGElegance.backgroundColor = [UIColor clearColor];
  42. self.title = @"Themes";
  43.  
  44. [super viewDidLoad];
  45.  
  46. [self testTheme];
  47. }
  48.  
  49. - (void)didReceiveMemoryWarning
  50. {
  51. [super didReceiveMemoryWarning];
  52. }
  53.  
  54. - (void)viewDidUnload
  55. {
  56. }
  57.  
  58. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  59. {
  60. return 1;
  61. }
  62.  
  63.  
  64. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  65. {
  66. return 3;
  67. }
  68.  
  69. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  70.  
  71. static NSString *TopLevelCellIdentifier = @"TopLevelCellIdentifier";
  72.  
  73. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TopLevelCellIdentifier];
  74. if (cell == nil) {
  75. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:TopLevelCellIdentifier] autorelease];
  76. }
  77.  
  78. NSUInteger row = [indexPath row];
  79. NSUInteger oldRow = [lastIndexPath row];
  80.  
  81. cell.accessoryType = (row == oldRow && lastIndexPath != nil) ?
  82. UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
  83.  
  84. cell.selectionStyle = UITableViewCellSelectionStyleGray;
  85.  
  86. switch ([ indexPath indexAtPosition: 0]) {
  87. case(0):
  88. switch([ indexPath indexAtPosition: 1])
  89. {
  90. case(0):
  91. cell.backgroundView = cellBGDefault;
  92. break;
  93. case(1):
  94. cell.backgroundView = cellBGElegance;
  95. break;
  96. case(2):
  97. cell.backgroundView = cellBGCarbon;
  98. break;
  99. }
  100. break;
  101. }
  102. return cell;
  103. }
  104.  
  105. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  106. {
  107. return 60;
  108. }
  109.  
  110. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  111. {
  112. int newRow = [indexPath row];
  113. int oldRow = [lastIndexPath row];
  114.  
  115. if (newRow != oldRow)
  116. {
  117. UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
  118. newCell.accessoryType = UITableViewCellAccessoryCheckmark;
  119.  
  120. UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPath];
  121. oldCell.accessoryType = UITableViewCellAccessoryNone;
  122.  
  123. lastIndexPath = indexPath;
  124. }
  125.  
  126. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  127.  
  128. if(indexPath.row == 0)
  129. {
  130. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  131. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  132. self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"DeafultBG.png"]];
  133.  
  134. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  135. [prefs setObject:@"Default" forKey:kTheme];
  136.  
  137. }
  138.  
  139. if(indexPath.row == 1)
  140. {
  141. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
  142. self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
  143. self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"HolzBG.png"]];
  144.  
  145. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  146. [prefs setObject:@"Elegance" forKey:kTheme];
  147. }
  148.  
  149. if(indexPath.row == 2)
  150. {
  151. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
  152. self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
  153. self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"CarbonBG.png"]];
  154.  
  155. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  156. [prefs setObject:@"Carbon" forKey:kTheme];
  157. }
  158. }
  159.  
  160. - (void)dealloc
  161. {
  162. [cellBGCarbon release];
  163. [cellBGElegance release];
  164. [cellBGDefault release];
  165. [lastIndexPath release];
  166. [super dealloc];
  167. }
  168.  
  169. @end
Add Comment
Please, Sign In to add comment