From f4b021a2d1df286aa07e1ab1ec147f1dabbeaaf7 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 11 Sep 2014 19:59:11 -0700 Subject: [PATCH] Move theme settings cell setup logic to subclass. --- Settings.mm | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Settings.mm b/Settings.mm index 7aa8e89..c2599a0 100644 --- a/Settings.mm +++ b/Settings.mm @@ -145,6 +145,28 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { /* }}} */ /* Theme Settings Controller {{{ */ +@interface WBSThemesTableViewCell : UITableViewCell { +} + +@end + +@implementation WBSThemesTableViewCell + +- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuse { + if ((self = [super initWithFrame:frame reuseIdentifier:reuse]) != nil) { + } return self; +} + +- (void) setTheme:(NSDictionary *)theme { + self.text = [theme objectForKey:@"Name"]; + self.hidesAccessoryWhenEditing = NO; + NSNumber *active([theme objectForKey:@"Active"]); + BOOL inactive(active == nil || ![active boolValue]); + [self setImage:(inactive ? uncheckedImage : checkImage)]; +} + +@end + @interface WBSThemesController: PSViewController { UITableView *_tableView; NSMutableArray *_themes; @@ -275,18 +297,14 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { } - (id) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"]; + WBSThemesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease]; + cell = [[[WBSThemesTableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease]; //[cell setTableViewStyle:UITableViewCellStyleDefault]; } NSDictionary *theme([_themes objectAtIndex:indexPath.row]); - cell.text = [theme objectForKey:@"Name"]; - cell.hidesAccessoryWhenEditing = NO; - NSNumber *active([theme objectForKey:@"Active"]); - BOOL inactive(active == nil || ![active boolValue]); - [cell setImage:(inactive ? uncheckedImage : checkImage)]; + [cell setTheme:theme]; return cell; } -- 2.45.2