├── .gitignore ├── FRPreferences.podspec ├── FRPreferences ├── FRPCell.h ├── FRPCell.m ├── FRPDeveloperCell.h ├── FRPDeveloperCell.m ├── FRPLinkCell.h ├── FRPLinkCell.m ├── FRPListCell.h ├── FRPListCell.m ├── FRPSection.h ├── FRPSection.m ├── FRPSegmentCell.h ├── FRPSegmentCell.m ├── FRPSelectListTable.h ├── FRPSelectListTable.m ├── FRPSettings.h ├── FRPSettings.m ├── FRPSliderCell.h ├── FRPSliderCell.m ├── FRPSwitchCell.h ├── FRPSwitchCell.m ├── FRPTextFieldCell.h ├── FRPTextFieldCell.m ├── FRPValueCell.h ├── FRPValueCell.m ├── FRPViewCell.h ├── FRPViewCell.m ├── FRPViewSection.h ├── FRPViewSection.m ├── FRPreferences.h ├── FRPreferences.m └── FRPrefs.h ├── FRPreferencesExample ├── FRPreferences.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── FRPreferences │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── heart.png │ ├── heart@2x.png │ ├── logo.png │ └── main.m └── FRPreferencesTests │ ├── FRPreferencesTests.m │ └── Info.plist ├── LICENSE ├── README.md └── Screenshot └── screenshots.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /FRPreferences.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'FRPreferences' 3 | s.version = '1.0.10' 4 | s.summary = "In-App Preferences controls built easily" 5 | s.homepage = "https://github.com/FouadRaheb/FRPreferences" 6 | s.license = 'GPL' 7 | s.authors = { "Fouad Raheb" => "fouad.raheb@gmail.com" } 8 | s.social_media_url = "https://twitter.com/FouadRaheb" 9 | s.platform = :ios, '7.0' 10 | s.source = { :git => "https://github.com/FouadRaheb/FRPreferences.git", :tag => s.version.to_s } 11 | s.source_files = 'FRPreferences/*.{h,m}', 'FRPreferences/**/*.{h,m}' 12 | s.requires_arc = true 13 | end -------------------------------------------------------------------------------- /FRPreferences/FRPCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | typedef void (^FRPValueChanged)(id sender); 13 | 14 | @interface FRPCell : UITableViewCell 15 | 16 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting; 17 | - (instancetype)initWithTitle:(NSString *)title setting:(FRPSettings *)setting; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | @property (nonatomic, strong) FRPSettings *setting; 22 | 23 | @property (nonatomic, strong) NSString *title; 24 | 25 | @property (nonatomic, strong) NSString *postNotification; 26 | 27 | @property (nonatomic, copy) FRPValueChanged valueChanged; 28 | 29 | @property (nonatomic, assign) int height; 30 | 31 | - (void)didSelectFromTable:(FRPreferences *)viewController; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /FRPreferences/FRPCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @implementation FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting { 14 | return [[self alloc] initWithTitle:title setting:setting]; 15 | } 16 | 17 | - (instancetype)initWithTitle:(NSString *)title setting:(FRPSettings *)setting { 18 | if (self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil]) { 19 | self.clipsToBounds = YES; 20 | self.textLabel.text = title; 21 | self.setting = setting; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)didSelectFromTable:(FRPreferences *)viewController { 27 | // NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 28 | // NSLog(@"Did Select Cell At Index: %@",indexPath); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /FRPreferences/FRPDeveloperCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPDeveloperCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPDeveloperCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url; 14 | 15 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPDeveloperCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPDeveloperCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPDeveloperCell.h" 10 | 11 | @interface FRPDeveloperCell () 12 | @property (nonatomic, strong) NSString *url; 13 | @property (nonatomic, strong) UIImage *image; 14 | @end 15 | 16 | @implementation FRPDeveloperCell 17 | 18 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url { 19 | return [[self alloc] cellWithTitle:title detail:detail image:image url:url]; 20 | } 21 | 22 | - (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url { 23 | FRPDeveloperCell *cell = [super initWithTitle:title setting:nil]; 24 | cell.url = url; 25 | cell.image = image; 26 | cell.detailTextLabel.text = detail; 27 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 28 | 29 | CGSize size = CGSizeMake(35,35); 30 | UIGraphicsBeginImageContextWithOptions(size, NO, UIScreen.mainScreen.scale); 31 | [self.image drawInRect:CGRectMake(0, 0, size.width, size.height)]; 32 | UIImage *newThumbnail = UIGraphicsGetImageFromCurrentImageContext(); 33 | UIGraphicsEndImageContext(); 34 | cell.imageView.image = newThumbnail;; 35 | return cell; 36 | } 37 | 38 | - (void)layoutSubviews { 39 | [super layoutSubviews]; 40 | self.imageView.layer.cornerRadius = self.imageView.frame.size.width / 2; 41 | self.imageView.clipsToBounds = YES; 42 | } 43 | 44 | - (void)didSelectFromTable:(FRPreferences *)viewController { 45 | [viewController.tableView deselectRowAtIndexPath:[viewController.tableView indexPathForCell:self] animated:YES]; 46 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.url]]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /FRPreferences/FRPLinkCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPLinkCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPLinkCellSelected)(UITableViewCell *sender); 12 | 13 | @interface FRPLinkCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /FRPreferences/FRPLinkCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPLinkCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPLinkCell.h" 10 | 11 | @interface FRPLinkCell () 12 | @end 13 | 14 | @implementation FRPLinkCell 15 | 16 | + (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block { 17 | return [[self alloc] cellWithTitle:title selectedBlock:block]; 18 | } 19 | 20 | - (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block { 21 | FRPLinkCell *cell = [super initWithTitle:title setting:nil]; 22 | cell.valueChanged = block; 23 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 24 | return cell; 25 | } 26 | 27 | - (void)didSelectFromTable:(FRPreferences *)viewController { 28 | NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 29 | [viewController.tableView deselectRowAtIndexPath:indexPath animated:YES]; 30 | if (self.valueChanged) { 31 | self.valueChanged(self); 32 | } 33 | } 34 | 35 | - (void)layoutSubviews { 36 | [super layoutSubviews]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /FRPreferences/FRPListCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRListCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPListItemChange)(NSString *value); 12 | 13 | @interface FRPListCell : FRPCell 14 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block; 15 | @property (nonatomic, strong) NSArray *items; 16 | @property (nonatomic, strong) NSArray *values; 17 | @property (nonatomic, assign) BOOL popView; 18 | @end 19 | -------------------------------------------------------------------------------- /FRPreferences/FRPListCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRListCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPListCell.h" 10 | #import "FRPSelectListTable.h" 11 | 12 | @interface FRPListCell () 13 | @end 14 | 15 | @implementation FRPListCell 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block { 18 | return [[self alloc] cellWithTitle:title setting:setting items:items value:values popViewOnSelect:pop postNotification:(NSString *)notification changedBlock:block]; 19 | } 20 | 21 | 22 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block { 23 | FRPListCell *cell = [super initWithTitle:title setting:setting]; 24 | [cell setValueChanged:block]; 25 | cell.items = items; 26 | cell.values = values; 27 | self.popView = pop; 28 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 29 | if ([self.values containsObject:setting.value]) 30 | cell.detailTextLabel.text = [self.items objectAtIndex:[self.values indexOfObject:setting.value]]; 31 | 32 | return cell; 33 | } 34 | 35 | - (void)didSelectFromTable:(FRPreferences *)viewController { 36 | NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 37 | [viewController.tableView deselectRowAtIndexPath:indexPath animated:YES]; 38 | UITableViewCell *cell = [viewController.tableView cellForRowAtIndexPath:indexPath]; 39 | 40 | FRPSelectListTable *selectionList = [[FRPSelectListTable alloc] initWithStyle:UITableViewStyleGrouped title:cell.textLabel.text items:self.items values:self.values currentValue:self.setting.value popViewOnSelect:self.popView changeBlock:^(NSString *item) { 41 | cell.detailTextLabel.text = item; 42 | NSString *valueOfItem = [self.values objectAtIndex:[self.items indexOfObject:item]]; 43 | self.setting.value = valueOfItem; 44 | if (self.valueChanged) { 45 | self.valueChanged(valueOfItem); 46 | } 47 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:valueOfItem]; 48 | }]; 49 | selectionList.tintUIColor = self.tintUIColor; 50 | if (viewController.navigationController) { 51 | [viewController.navigationController pushViewController:selectionList animated:YES]; 52 | } else { 53 | [viewController.navigationController presentViewController:selectionList animated:YES completion:nil]; 54 | } 55 | } 56 | 57 | - (void)layoutSubviews { 58 | [super layoutSubviews]; 59 | } 60 | @end 61 | -------------------------------------------------------------------------------- /FRPreferences/FRPSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface FRPSection : UITableViewCell 13 | 14 | @property (nonatomic, strong) NSString *headerTitle; 15 | @property (nonatomic, strong) NSString *footerTitle; 16 | 17 | @property (nonatomic, strong) NSMutableArray *cells; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | + (instancetype)sectionWithTitle:(NSString *)title footer:(NSString *)footer; 22 | 23 | - (void)addCell:(UITableViewCell *)cell; 24 | - (void)addCells:(NSArray *)cells; 25 | 26 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPSection.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSection.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSection.h" 10 | 11 | @interface FRPSection () 12 | 13 | @end 14 | 15 | 16 | @implementation FRPSection 17 | 18 | + (instancetype)sectionWithTitle:(NSString *)title footer:(NSString *)footer { 19 | return [[self alloc] initWithTitle:title footer:footer]; 20 | } 21 | 22 | - (instancetype)initWithTitle:(NSString *)title footer:(NSString *)footer { 23 | if (self = [super init]) { 24 | self.headerTitle = title; 25 | self.footerTitle = footer; 26 | self.cells = [NSMutableArray new]; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | - (void)addCell:(UITableViewCell *)cell { 33 | [self.cells addObject:cell]; 34 | } 35 | 36 | - (void)addCells:(NSArray *)cells { 37 | [self.cells addObjectsFromArray:cells]; 38 | } 39 | 40 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPSegmentCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSegmentCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/19/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSegmentValueChanged)(NSString *value); 12 | 13 | @interface FRPSegmentCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block __attribute__((deprecated("use instead +cellWithTitle:setting:values:displayedValues:postNotification:changeBlock"))); 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 18 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /FRPreferences/FRPSegmentCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSegmentCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/19/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSegmentCell.h" 10 | 11 | @interface FRPSegmentCell () 12 | @property (nonatomic, strong) UISegmentedControl *segment; 13 | @property (nonatomic, strong) NSArray *values; 14 | @property (nonatomic, strong) NSArray *displayedValues; 15 | @end 16 | 17 | @implementation FRPSegmentCell 18 | 19 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 20 | return [[self alloc] cellWithTitle:title setting:setting values:items displayedValues:items postNotification:notification changeBlock:block]; 21 | } 22 | 23 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 24 | return [[self alloc] cellWithTitle:title setting:setting values:values displayedValues:displayedValues postNotification:notification changeBlock:block]; 25 | } 26 | 27 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 28 | return [[self alloc] cellWithTitle:title setting:setting values:values displayedValues:nil postNotification:notification changeBlock:block]; 29 | } 30 | 31 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 32 | FRPSegmentCell *cell = [super initWithTitle:title setting:setting]; 33 | cell.setting = setting; 34 | cell.postNotification = notification; 35 | [cell setValueChanged:block]; 36 | self.values = values; 37 | self.displayedValues = displayedValues; 38 | if (!self.displayedValues) { 39 | self.displayedValues = values; 40 | } 41 | 42 | self.segment = [[UISegmentedControl alloc] initWithItems:self.displayedValues]; 43 | [self.segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; 44 | self.segment.selectedSegmentIndex = [self.values indexOfObject:cell.setting.value]; 45 | 46 | cell.accessoryView = self.segment; 47 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 48 | 49 | return cell; 50 | } 51 | 52 | - (void)segmentAction:(UISegmentedControl *)segment { 53 | NSString *selectedItem = [self.values objectAtIndex:segment.selectedSegmentIndex]; 54 | self.setting.value = selectedItem; 55 | if (self.valueChanged) { 56 | self.valueChanged(selectedItem); 57 | } 58 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:selectedItem]; 59 | } 60 | 61 | 62 | - (void)layoutSubviews { 63 | [super layoutSubviews]; 64 | self.segment.tintColor = self.tintUIColor; 65 | } 66 | @end 67 | -------------------------------------------------------------------------------- /FRPreferences/FRPSelectListTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSelectionListViewController.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/10/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FRPListCell.h" 11 | 12 | @interface FRPSelectListTable : UITableViewController { 13 | NSArray *listItems; 14 | NSArray *listValues; 15 | NSString *currentValue; 16 | NSString *pageTitle; 17 | BOOL popView; 18 | } 19 | @property (nonatomic, copy) FRPListItemChange itemChanged; 20 | @property (nonatomic, copy) UIColor *tintUIColor; 21 | 22 | - (instancetype)initWithStyle:(UITableViewStyle)style title:(NSString *)title items:(NSArray *)items values:(NSArray *)values currentValue:(NSString *)value popViewOnSelect:(BOOL)back changeBlock:(FRPListItemChange)block; 23 | 24 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPSelectListTable.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSelectionListViewController.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/10/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSelectListTable.h" 10 | 11 | @implementation FRPSelectListTable 12 | 13 | - (instancetype)initWithStyle:(UITableViewStyle)style title:(NSString *)title items:(NSArray *)items values:(NSArray *)values currentValue:(NSString *)value popViewOnSelect:(BOOL)back changeBlock:(FRPListItemChange)block { 14 | listItems = items; 15 | listValues = values; 16 | currentValue = value; 17 | popView = back; 18 | pageTitle = title; 19 | self.itemChanged = ^(id sender) { 20 | if (block) block(sender); 21 | }; 22 | return [self initWithStyle:style]; 23 | } 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | self.title = pageTitle; 28 | self.view.tintColor = self.tintUIColor; 29 | self.tableView.tintColor = self.tintUIColor; 30 | self.navigationController.navigationBar.tintColor = self.tintUIColor; 31 | } 32 | 33 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView { 34 | return 1; 35 | } 36 | 37 | - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section { 38 | return [listItems count]; 39 | } 40 | 41 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 42 | static NSString *cellIdentifier = @"LinkCellIdentifier"; 43 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 44 | 45 | if (cell == nil) { 46 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 47 | } 48 | cell.textLabel.text = [listItems objectAtIndex:[indexPath row]]; 49 | if ([[listValues objectAtIndex:[indexPath row]] isEqualToString:currentValue]) { 50 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 51 | } 52 | else { 53 | cell.accessoryType = UITableViewCellAccessoryNone; 54 | } 55 | 56 | return cell; 57 | } 58 | 59 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 60 | self.itemChanged([listItems objectAtIndex:[indexPath row]]); 61 | 62 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 63 | for (UITableViewCell *cell in tableView.visibleCells) { 64 | cell.accessoryType = UITableViewCellAccessoryNone; 65 | } 66 | [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; 67 | if (popView) 68 | [self.navigationController popViewControllerAnimated:YES]; 69 | } 70 | 71 | - (void)didReceiveMemoryWarning { 72 | [super didReceiveMemoryWarning]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /FRPreferences/FRPSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSettings.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPSettings : NSObject 12 | 13 | @property (nonatomic, strong) NSString *key; 14 | @property (nonatomic, strong) id value; 15 | @property (nonatomic, strong) NSString *fileSave; 16 | 17 | + (instancetype)settingsWithKey:(NSString *)key defaultValue:(id)defaultValue; 18 | @end 19 | -------------------------------------------------------------------------------- /FRPreferences/FRPSettings.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSettings.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSettings.h" 10 | 11 | @interface FRPSettings () 12 | typedef void(^FRPSettingValueDidChangeBlock)(void); 13 | @property (nonatomic, copy) FRPSettingValueDidChangeBlock valueDidChangeBlock; 14 | @end 15 | 16 | @implementation FRPSettings 17 | 18 | + (instancetype)settingsWithKey:(NSString *)key defaultValue:(id)defaultValue { 19 | return [[self alloc] initWithKey:key defaultValue:defaultValue]; 20 | } 21 | 22 | - (instancetype)initWithKey:(NSString *)key defaultValue:(id)defaultValue { 23 | if (self = [super init]) { 24 | self.key = key; 25 | [[NSUserDefaults standardUserDefaults] registerDefaults:@{self.key: defaultValue}]; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 32 | if (self.valueDidChangeBlock) { 33 | self.valueDidChangeBlock(); 34 | } 35 | } 36 | 37 | - (id)value { 38 | return [[NSUserDefaults standardUserDefaults] objectForKey:self.key]; 39 | } 40 | 41 | - (void)setValue:(id)value { 42 | if (self.value != value) { 43 | [[NSUserDefaults standardUserDefaults] setObject:value forKey:self.key]; 44 | [[NSUserDefaults standardUserDefaults] synchronize]; 45 | if ([self.fileSave length] > 0) { 46 | [self saveValue:value]; 47 | } 48 | } 49 | } 50 | 51 | - (void)saveValue:(id)value { 52 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:self.fileSave]; 53 | if (dict == nil) dict = [NSMutableDictionary new]; 54 | [dict setObject:value forKey:self.key]; 55 | [dict writeToFile:self.fileSave atomically:YES]; 56 | } 57 | 58 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPSliderCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRSliderCellTableViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 6/14/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSliderCellChanged)(UISlider *sender); 12 | 13 | @interface FRPSliderCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISlider *sliderCell; 16 | @property (nonatomic, strong) UILabel *lLabel; 17 | @property (nonatomic, strong) UILabel *rLabel; 18 | @property (nonatomic, strong) UILabel *cLabel; 19 | @property (nonatomic, strong) UILabel *vLabel; 20 | 21 | @property (nonatomic) float min; 22 | @property (nonatomic) float max; 23 | 24 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /FRPreferences/FRPSliderCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRSliderCellTableViewCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 6/14/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSliderCell.h" 10 | 11 | @implementation FRPSliderCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block { 14 | return [[self alloc] cellWithTitle:title setting:setting min:min max:max postNotification:notification changeBlock:block]; 15 | } 16 | 17 | 18 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block { 19 | FRPSliderCell *cell = [super initWithTitle:nil setting:setting]; 20 | cell.postNotification = notification; 21 | cell.valueChanged = block; 22 | 23 | UISlider *sliderCell = [[UISlider alloc] initWithFrame:CGRectZero]; 24 | sliderCell.minimumValue = min; 25 | sliderCell.maximumValue = max; 26 | sliderCell.value = [setting.value floatValue]; 27 | [sliderCell addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; 28 | [cell.contentView addSubview:sliderCell]; 29 | cell.sliderCell = sliderCell; 30 | 31 | UILabel *lLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 32 | lLabel.text = [NSString stringWithFormat:@"%.2f",min]; 33 | lLabel.numberOfLines = 1; 34 | lLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 35 | lLabel.adjustsFontSizeToFitWidth = YES; 36 | lLabel.clipsToBounds = YES; 37 | lLabel.backgroundColor = [UIColor clearColor]; 38 | lLabel.textColor = [UIColor blackColor]; 39 | lLabel.textAlignment = NSTextAlignmentCenter; 40 | [cell.contentView addSubview:lLabel]; 41 | cell.lLabel = lLabel; 42 | 43 | UILabel *rLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 44 | rLabel.text = [NSString stringWithFormat:@"%.2f",max]; 45 | rLabel.numberOfLines = 1; 46 | rLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 47 | rLabel.adjustsFontSizeToFitWidth = YES; 48 | rLabel.clipsToBounds = YES; 49 | rLabel.backgroundColor = [UIColor clearColor]; 50 | rLabel.textColor = [UIColor blackColor]; 51 | rLabel.textAlignment = NSTextAlignmentCenter; 52 | [cell.contentView addSubview:rLabel]; 53 | cell.rLabel = rLabel; 54 | 55 | UILabel *cLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 56 | cLabel.text = title; 57 | cLabel.numberOfLines = 1; 58 | cLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 59 | cLabel.adjustsFontSizeToFitWidth = YES; 60 | cLabel.clipsToBounds = YES; 61 | cLabel.backgroundColor = [UIColor clearColor]; 62 | cLabel.textColor = [UIColor blackColor]; 63 | cLabel.textAlignment = NSTextAlignmentLeft; 64 | [cell.contentView addSubview:cLabel]; 65 | cell.cLabel = cLabel; 66 | 67 | UILabel *vLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 68 | vLabel.text = [NSString stringWithFormat:@"%.2f",[setting.value floatValue]]; 69 | vLabel.numberOfLines = 1; 70 | vLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 71 | vLabel.adjustsFontSizeToFitWidth = YES; 72 | vLabel.clipsToBounds = YES; 73 | vLabel.backgroundColor = [UIColor clearColor]; 74 | vLabel.textColor = [UIColor grayColor]; 75 | vLabel.textAlignment = NSTextAlignmentRight; 76 | [cell.contentView addSubview:vLabel]; 77 | cell.vLabel = vLabel; 78 | 79 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 80 | cell.height = 75; 81 | return cell; 82 | } 83 | 84 | - (void)layoutSubviews { 85 | [super layoutSubviews]; 86 | 87 | float sliderW = self.contentView.frame.size.width/1.8; 88 | float sliderH = 25; 89 | float sliderX = self.contentView.frame.size.width/2-sliderW/2; 90 | float sliderY = self.contentView.frame.size.height-sliderH-10; 91 | self.sliderCell.frame = CGRectMake(sliderX, sliderY, sliderW, sliderH); 92 | 93 | float lLabelW = (self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8))/2-10; 94 | float lLabelH = 25; 95 | float lLabelX = sliderX-lLabelW-5; 96 | float lLabelY = self.contentView.frame.size.height-lLabelH-10; 97 | self.lLabel.frame = CGRectMake(lLabelX, lLabelY, lLabelW, lLabelH); 98 | 99 | float rLabelW = (self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8))/2-10; 100 | float rLabelH = 25; 101 | float rLabelX = sliderX+sliderW+5; 102 | float rLabelY = self.contentView.frame.size.height-rLabelH-10; 103 | self.rLabel.frame = CGRectMake(rLabelX, rLabelY, rLabelW, rLabelH); 104 | 105 | float cLabelW = self.contentView.frame.size.width/1.8; 106 | float cLabelH = 25; 107 | float cLabelX = 17; 108 | float cLabelY = 8; 109 | self.cLabel.frame = CGRectMake(cLabelX, cLabelY, cLabelW, cLabelH); 110 | 111 | float vLabelW = self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8); 112 | float vLabelH = 25; 113 | float vLabelX = self.contentView.frame.size.width-vLabelW-25; 114 | float vLabelY = 8; 115 | self.vLabel.frame = CGRectMake(vLabelX, vLabelY, vLabelW, vLabelH); 116 | } 117 | 118 | - (void)sliderChanged:(UISlider *)slider { 119 | self.vLabel.text = [NSString stringWithFormat:@"%.2f",[slider value]]; 120 | self.setting.value = [NSNumber numberWithFloat:[slider value]]; 121 | if (self.valueChanged) { 122 | self.valueChanged(slider); 123 | } 124 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:slider]; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /FRPreferences/FRPSwitchCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSwitchCellChanged)(UISwitch *sender); 12 | 13 | @interface FRPSwitchCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISwitch *switchView; 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /FRPreferences/FRPSwitchCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSwitchCell.h" 10 | 11 | @implementation FRPSwitchCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block { 14 | return [[self alloc] cellWithTitle:title setting:setting postNotification:notification changeBlock:block]; 15 | } 16 | 17 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block { 18 | FRPSwitchCell *cell = [super initWithTitle:title setting:setting]; 19 | cell.postNotification = notification; 20 | cell.valueChanged = block; 21 | self.switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; 22 | [self.switchView setOn:[self.setting.value boolValue] animated:NO]; 23 | [self.switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; 24 | cell.accessoryView = self.switchView; 25 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 26 | return cell; 27 | } 28 | 29 | - (void)switchChanged:(UISwitch *)switchItem { 30 | self.setting.value = [NSNumber numberWithBool:[switchItem isOn]]; 31 | if (self.valueChanged) { 32 | self.valueChanged(switchItem); 33 | } 34 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:switchItem]; 35 | } 36 | 37 | - (void)layoutSubviews { 38 | [super layoutSubviews]; 39 | self.switchView.onTintColor = self.tintUIColor; 40 | // self.switchView.tintColor = self.tintUIColor; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /FRPreferences/FRPTextFieldCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPTextFieldCellChanged)(UITextField *sender); 12 | 13 | @interface FRPTextFieldCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /FRPreferences/FRPTextFieldCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPTextFieldCell.h" 10 | 11 | @interface FRPTextFieldCell () 12 | 13 | @property (nonatomic, strong) UITextField *textField; 14 | 15 | @end 16 | 17 | @implementation FRPTextFieldCell 18 | 19 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block { 20 | return [[self alloc] cellWithTitle:title setting:setting placeholder:placeholder postNotification:notification changeBlock:block]; 21 | } 22 | 23 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block { 24 | FRPTextFieldCell *cell = [super initWithTitle:title setting:setting]; 25 | cell.setting = setting; 26 | cell.postNotification = notification; 27 | cell.valueChanged = block; 28 | self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 190, 30)]; 29 | [self.textField setDelegate:self]; 30 | [self.textField setTextAlignment:NSTextAlignmentRight]; 31 | [self.textField setClearButtonMode:UITextFieldViewModeWhileEditing]; 32 | [self.textField setText:setting.value]; 33 | [self.textField setPlaceholder:placeholder]; 34 | [self.textField addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged]; 35 | self.textField.returnKeyType = UIReturnKeyDone; 36 | cell.accessoryView = self.textField; 37 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 38 | 39 | return cell; 40 | } 41 | 42 | - (void)textFieldChanged:(UITextField *)textField { 43 | self.setting.value = [textField text]; 44 | if (self.valueChanged) { 45 | self.valueChanged(textField); 46 | } 47 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:textField]; 48 | } 49 | 50 | - (BOOL)textFieldShouldReturn:(id)textField { 51 | [textField resignFirstResponder]; 52 | return NO; 53 | } 54 | 55 | - (void)layoutSubviews { 56 | [super layoutSubviews]; 57 | self.textField.tintColor = self.tintUIColor; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /FRPreferences/FRPValueCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPValueCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/22/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPValueCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /FRPreferences/FRPValueCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPValueCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/22/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPValueCell.h" 10 | 11 | @implementation FRPValueCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail { 14 | return [[self alloc] cellWithTitle:title detail:detail]; 15 | } 16 | 17 | - (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail { 18 | FRPValueCell *cell = [super initWithTitle:title setting:nil]; 19 | cell.accessoryType = UITableViewCellAccessoryNone; 20 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 21 | cell.detailTextLabel.text = detail; 22 | return cell; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /FRPreferences/FRPViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPViewCellBlock)(UITableViewCell *cell); 12 | 13 | @interface FRPViewCell : FRPCell 14 | 15 | + (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 16 | 17 | @property (nonatomic, strong) FRPViewCellBlock layoutBlock; 18 | @property (nonatomic, assign) BOOL hideSeperators; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /FRPreferences/FRPViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewCell.h" 10 | 11 | @implementation FRPViewCell 12 | 13 | + (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 14 | return [[self alloc] cellWithHeight:height initBlock:initBlock layoutBlock:layoutBlock]; 15 | } 16 | 17 | - (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 18 | FRPViewCell *cell = [super initWithTitle:nil setting:nil]; 19 | if (layoutBlock) self.layoutBlock = layoutBlock; 20 | cell.accessoryType = UITableViewCellAccessoryNone; 21 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 22 | cell.height = height; 23 | initBlock(cell); 24 | return cell; 25 | } 26 | 27 | - (void)layoutSubviews { 28 | [super layoutSubviews]; 29 | if (self.layoutBlock) self.layoutBlock(self); 30 | } 31 | 32 | - (void)addSubview:(UIView *)view { 33 | // The separator has a height of 0.5pt on a retina display and 1pt on non-retina. 34 | // Prevent subviews with this height from being added. 35 | if (self.hideSeperators && CGRectGetHeight(view.frame)*[UIScreen mainScreen].scale == 1) { 36 | return; 37 | } 38 | [super addSubview:view]; 39 | } 40 | 41 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPViewSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewCell.h" 10 | #import "FRPSection.h" 11 | 12 | @interface FRPViewSection : FRPSection 13 | 14 | @property (nonatomic, copy) FRPViewCellBlock cellBlock; 15 | 16 | + (instancetype)sectionWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /FRPreferences/FRPViewSection.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewSection.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewSection.h" 10 | 11 | @implementation FRPViewSection 12 | 13 | + (instancetype)sectionWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 14 | return [[self alloc] initWithHeight:height initBlock:initBlock layoutBlock:layoutBlock]; 15 | } 16 | 17 | - (instancetype)initWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 18 | FRPViewSection *section = [[super class] sectionWithTitle:nil footer:nil]; 19 | FRPViewCell *cell = [FRPViewCell cellWithHeight:height 20 | initBlock:^(UITableViewCell *cell) { 21 | initBlock(cell); 22 | } 23 | layoutBlock:^(UITableViewCell *cell) { 24 | layoutBlock(cell); 25 | }]; 26 | cell.hideSeperators = YES; 27 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 28 | [section addCell:cell]; 29 | return section; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /FRPreferences/FRPreferences.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPPreferences.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPreferences : UITableViewController 12 | 13 | @property (nonatomic, strong) NSArray *sections; 14 | @property (nonatomic, strong) NSString *plistPath; 15 | 16 | + (instancetype)tableWithSections:(NSArray *)sections title:(NSString *)title tintColor:(UIColor *)color; 17 | 18 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPreferences.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPPreferences.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPCell.h" 11 | #import "FRPSection.h" 12 | 13 | @interface FRPreferences () 14 | 15 | @property (nonatomic, strong) UIColor *tintUIColor; 16 | 17 | @end 18 | 19 | @implementation FRPreferences 20 | 21 | + (instancetype)tableWithSections:(NSArray *)sections title:(NSString *)title tintColor:(UIColor *)color { 22 | FRPreferences *table = [[self alloc] initTableWithSections:sections]; 23 | table.title = title; 24 | table.tintUIColor = color; 25 | return table; 26 | } 27 | 28 | - (instancetype)initTableWithSections:(NSArray *)sections { 29 | if (self = [super initWithStyle:UITableViewStyleGrouped]) { 30 | self.sections = sections; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)updateTintColors { 36 | UIColor *tintUIColor = self.tintUIColor; 37 | for (FRPSection *section in self.sections) { 38 | for (FRPCell *cell in section.cells) { 39 | cell.tintUIColor = tintUIColor; 40 | if ([self.plistPath length] > 0 && cell.setting) { 41 | cell.setting.fileSave = self.plistPath; 42 | } 43 | } 44 | section.tintUIColor = tintUIColor; 45 | } 46 | self.view.tintColor = tintUIColor; 47 | self.tableView.tintColor = tintUIColor; 48 | } 49 | 50 | - (void)viewDidDisappear:(BOOL)animated { 51 | [super viewDidDisappear:animated]; 52 | } 53 | 54 | - (void)viewWillAppear:(BOOL)animated { 55 | [super viewWillAppear:animated]; 56 | [self updateTintColors]; 57 | 58 | NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; 59 | 60 | if (selectedRowIndexPath) { 61 | [self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES]; 62 | 63 | [[self.navigationController transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id context) { 64 | if ([context isCancelled]) { 65 | [self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; 66 | } 67 | }]; 68 | } 69 | } 70 | 71 | - (FRPCell *)cellForIndexPath:(NSIndexPath *)indexPath { 72 | return [self.sections[indexPath.section] cells][indexPath.row]; 73 | } 74 | 75 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 76 | return self.sections.count; 77 | } 78 | 79 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 80 | return [self.sections[section] headerTitle]; 81 | } 82 | 83 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex { 84 | FRPSection *section = self.sections[sectionIndex]; 85 | 86 | return section.cells.count; 87 | } 88 | 89 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 90 | FRPCell *cell = [self cellForIndexPath:indexPath]; 91 | 92 | return (cell.height > 0)?cell.height:UITableViewAutomaticDimension; 93 | } 94 | 95 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 96 | FRPCell *cell = [self cellForIndexPath:indexPath]; 97 | 98 | return cell; 99 | } 100 | 101 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 102 | FRPCell *cell = [self cellForIndexPath:indexPath]; 103 | if ([cell respondsToSelector:@selector(didSelectFromTable:)]) [cell didSelectFromTable:self]; 104 | } 105 | 106 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { 107 | return [self.sections[section] footerTitle]; 108 | } 109 | 110 | @end -------------------------------------------------------------------------------- /FRPreferences/FRPrefs.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPrefs.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | #import "FRPViewSection.h" 13 | #import "FRPSection.h" 14 | 15 | #import "FRPSwitchCell.h" 16 | #import "FRPTextFieldCell.h" 17 | #import "FRPLinkCell.h" 18 | #import "FRPSliderCell.h" 19 | #import "FRPListCell.h" 20 | #import "FRPSegmentCell.h" 21 | #import "FRPValueCell.h" 22 | #import "FRPDeveloperCell.h" 23 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 291C0B221AFED1A000D829EB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D15E931AF8B6F900F28A97 /* ViewController.m */; }; 11 | 292815671B5806AD0028A3B7 /* heart.png in Resources */ = {isa = PBXBuildFile; fileRef = 292815651B5806AD0028A3B7 /* heart.png */; }; 12 | 292815681B5806AD0028A3B7 /* heart@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 292815661B5806AD0028A3B7 /* heart@2x.png */; }; 13 | 29409D571B6C171D00AC2304 /* FRPCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D391B6C171D00AC2304 /* FRPCell.m */; }; 14 | 29409D581B6C171D00AC2304 /* FRPDeveloperCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D3B1B6C171D00AC2304 /* FRPDeveloperCell.m */; }; 15 | 29409D591B6C171D00AC2304 /* FRPLinkCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D3D1B6C171D00AC2304 /* FRPLinkCell.m */; }; 16 | 29409D5A1B6C171D00AC2304 /* FRPListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D3F1B6C171D00AC2304 /* FRPListCell.m */; }; 17 | 29409D5B1B6C171D00AC2304 /* FRPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D411B6C171D00AC2304 /* FRPreferences.m */; }; 18 | 29409D5C1B6C171D00AC2304 /* FRPSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D441B6C171D00AC2304 /* FRPSection.m */; }; 19 | 29409D5D1B6C171D00AC2304 /* FRPSegmentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D461B6C171D00AC2304 /* FRPSegmentCell.m */; }; 20 | 29409D5E1B6C171D00AC2304 /* FRPSelectListTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D481B6C171D00AC2304 /* FRPSelectListTable.m */; }; 21 | 29409D5F1B6C171D00AC2304 /* FRPSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D4A1B6C171D00AC2304 /* FRPSettings.m */; }; 22 | 29409D601B6C171D00AC2304 /* FRPSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D4C1B6C171D00AC2304 /* FRPSliderCell.m */; }; 23 | 29409D611B6C171D00AC2304 /* FRPSwitchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D4E1B6C171D00AC2304 /* FRPSwitchCell.m */; }; 24 | 29409D621B6C171D00AC2304 /* FRPTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D501B6C171D00AC2304 /* FRPTextFieldCell.m */; }; 25 | 29409D631B6C171D00AC2304 /* FRPValueCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D521B6C171D00AC2304 /* FRPValueCell.m */; }; 26 | 29409D641B6C171D00AC2304 /* FRPViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D541B6C171D00AC2304 /* FRPViewCell.m */; }; 27 | 29409D651B6C171D00AC2304 /* FRPViewSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 29409D561B6C171D00AC2304 /* FRPViewSection.m */; }; 28 | 29409D671B6C17D900AC2304 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 29409D661B6C17D900AC2304 /* logo.png */; }; 29 | 29D15E8E1AF8B6F900F28A97 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D15E8D1AF8B6F900F28A97 /* main.m */; }; 30 | 29D15E911AF8B6F900F28A97 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D15E901AF8B6F900F28A97 /* AppDelegate.m */; }; 31 | 29D15E971AF8B6F900F28A97 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29D15E951AF8B6F900F28A97 /* Main.storyboard */; }; 32 | 29D15E991AF8B6F900F28A97 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29D15E981AF8B6F900F28A97 /* Images.xcassets */; }; 33 | 29D15E9C1AF8B6F900F28A97 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29D15E9A1AF8B6F900F28A97 /* LaunchScreen.xib */; }; 34 | 29D15EA81AF8B6F900F28A97 /* FRPreferencesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D15EA71AF8B6F900F28A97 /* FRPreferencesTests.m */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXContainerItemProxy section */ 38 | 29D15EA21AF8B6F900F28A97 /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = 29D15E801AF8B6F900F28A97 /* Project object */; 41 | proxyType = 1; 42 | remoteGlobalIDString = 29D15E871AF8B6F900F28A97; 43 | remoteInfo = FRPreferences; 44 | }; 45 | /* End PBXContainerItemProxy section */ 46 | 47 | /* Begin PBXFileReference section */ 48 | 292815651B5806AD0028A3B7 /* heart.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = heart.png; sourceTree = ""; }; 49 | 292815661B5806AD0028A3B7 /* heart@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heart@2x.png"; sourceTree = ""; }; 50 | 29409D381B6C171D00AC2304 /* FRPCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPCell.h; sourceTree = ""; }; 51 | 29409D391B6C171D00AC2304 /* FRPCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPCell.m; sourceTree = ""; }; 52 | 29409D3A1B6C171D00AC2304 /* FRPDeveloperCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPDeveloperCell.h; sourceTree = ""; }; 53 | 29409D3B1B6C171D00AC2304 /* FRPDeveloperCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPDeveloperCell.m; sourceTree = ""; }; 54 | 29409D3C1B6C171D00AC2304 /* FRPLinkCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPLinkCell.h; sourceTree = ""; }; 55 | 29409D3D1B6C171D00AC2304 /* FRPLinkCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPLinkCell.m; sourceTree = ""; }; 56 | 29409D3E1B6C171D00AC2304 /* FRPListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPListCell.h; sourceTree = ""; }; 57 | 29409D3F1B6C171D00AC2304 /* FRPListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPListCell.m; sourceTree = ""; }; 58 | 29409D401B6C171D00AC2304 /* FRPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPreferences.h; sourceTree = ""; }; 59 | 29409D411B6C171D00AC2304 /* FRPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPreferences.m; sourceTree = ""; }; 60 | 29409D421B6C171D00AC2304 /* FRPrefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPrefs.h; sourceTree = ""; }; 61 | 29409D431B6C171D00AC2304 /* FRPSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSection.h; sourceTree = ""; }; 62 | 29409D441B6C171D00AC2304 /* FRPSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSection.m; sourceTree = ""; }; 63 | 29409D451B6C171D00AC2304 /* FRPSegmentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSegmentCell.h; sourceTree = ""; }; 64 | 29409D461B6C171D00AC2304 /* FRPSegmentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSegmentCell.m; sourceTree = ""; }; 65 | 29409D471B6C171D00AC2304 /* FRPSelectListTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSelectListTable.h; sourceTree = ""; }; 66 | 29409D481B6C171D00AC2304 /* FRPSelectListTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSelectListTable.m; sourceTree = ""; }; 67 | 29409D491B6C171D00AC2304 /* FRPSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSettings.h; sourceTree = ""; }; 68 | 29409D4A1B6C171D00AC2304 /* FRPSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSettings.m; sourceTree = ""; }; 69 | 29409D4B1B6C171D00AC2304 /* FRPSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSliderCell.h; sourceTree = ""; }; 70 | 29409D4C1B6C171D00AC2304 /* FRPSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSliderCell.m; sourceTree = ""; }; 71 | 29409D4D1B6C171D00AC2304 /* FRPSwitchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPSwitchCell.h; sourceTree = ""; }; 72 | 29409D4E1B6C171D00AC2304 /* FRPSwitchCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPSwitchCell.m; sourceTree = ""; }; 73 | 29409D4F1B6C171D00AC2304 /* FRPTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPTextFieldCell.h; sourceTree = ""; }; 74 | 29409D501B6C171D00AC2304 /* FRPTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPTextFieldCell.m; sourceTree = ""; }; 75 | 29409D511B6C171D00AC2304 /* FRPValueCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPValueCell.h; sourceTree = ""; }; 76 | 29409D521B6C171D00AC2304 /* FRPValueCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPValueCell.m; sourceTree = ""; }; 77 | 29409D531B6C171D00AC2304 /* FRPViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPViewCell.h; sourceTree = ""; }; 78 | 29409D541B6C171D00AC2304 /* FRPViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPViewCell.m; sourceTree = ""; }; 79 | 29409D551B6C171D00AC2304 /* FRPViewSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPViewSection.h; sourceTree = ""; }; 80 | 29409D561B6C171D00AC2304 /* FRPViewSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPViewSection.m; sourceTree = ""; }; 81 | 29409D661B6C17D900AC2304 /* logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = logo.png; sourceTree = ""; }; 82 | 29D15E881AF8B6F900F28A97 /* FRPreferences.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FRPreferences.app; sourceTree = BUILT_PRODUCTS_DIR; }; 83 | 29D15E8C1AF8B6F900F28A97 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 84 | 29D15E8D1AF8B6F900F28A97 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 85 | 29D15E8F1AF8B6F900F28A97 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 86 | 29D15E901AF8B6F900F28A97 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 87 | 29D15E921AF8B6F900F28A97 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 88 | 29D15E931AF8B6F900F28A97 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 89 | 29D15E961AF8B6F900F28A97 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 90 | 29D15E981AF8B6F900F28A97 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 91 | 29D15E9B1AF8B6F900F28A97 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 92 | 29D15EA11AF8B6F900F28A97 /* FRPreferencesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FRPreferencesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 93 | 29D15EA61AF8B6F900F28A97 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 94 | 29D15EA71AF8B6F900F28A97 /* FRPreferencesTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FRPreferencesTests.m; sourceTree = ""; }; 95 | /* End PBXFileReference section */ 96 | 97 | /* Begin PBXFrameworksBuildPhase section */ 98 | 29D15E851AF8B6F900F28A97 /* Frameworks */ = { 99 | isa = PBXFrameworksBuildPhase; 100 | buildActionMask = 2147483647; 101 | files = ( 102 | ); 103 | runOnlyForDeploymentPostprocessing = 0; 104 | }; 105 | 29D15E9E1AF8B6F900F28A97 /* Frameworks */ = { 106 | isa = PBXFrameworksBuildPhase; 107 | buildActionMask = 2147483647; 108 | files = ( 109 | ); 110 | runOnlyForDeploymentPostprocessing = 0; 111 | }; 112 | /* End PBXFrameworksBuildPhase section */ 113 | 114 | /* Begin PBXGroup section */ 115 | 29409D371B6C171D00AC2304 /* FRPreferences */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 29409D421B6C171D00AC2304 /* FRPrefs.h */, 119 | 29409D401B6C171D00AC2304 /* FRPreferences.h */, 120 | 29409D411B6C171D00AC2304 /* FRPreferences.m */, 121 | 29409D431B6C171D00AC2304 /* FRPSection.h */, 122 | 29409D441B6C171D00AC2304 /* FRPSection.m */, 123 | 29409D381B6C171D00AC2304 /* FRPCell.h */, 124 | 29409D391B6C171D00AC2304 /* FRPCell.m */, 125 | 29409D3A1B6C171D00AC2304 /* FRPDeveloperCell.h */, 126 | 29409D3B1B6C171D00AC2304 /* FRPDeveloperCell.m */, 127 | 29409D3C1B6C171D00AC2304 /* FRPLinkCell.h */, 128 | 29409D3D1B6C171D00AC2304 /* FRPLinkCell.m */, 129 | 29409D3E1B6C171D00AC2304 /* FRPListCell.h */, 130 | 29409D3F1B6C171D00AC2304 /* FRPListCell.m */, 131 | 29409D451B6C171D00AC2304 /* FRPSegmentCell.h */, 132 | 29409D461B6C171D00AC2304 /* FRPSegmentCell.m */, 133 | 29409D471B6C171D00AC2304 /* FRPSelectListTable.h */, 134 | 29409D481B6C171D00AC2304 /* FRPSelectListTable.m */, 135 | 29409D491B6C171D00AC2304 /* FRPSettings.h */, 136 | 29409D4A1B6C171D00AC2304 /* FRPSettings.m */, 137 | 29409D4B1B6C171D00AC2304 /* FRPSliderCell.h */, 138 | 29409D4C1B6C171D00AC2304 /* FRPSliderCell.m */, 139 | 29409D4D1B6C171D00AC2304 /* FRPSwitchCell.h */, 140 | 29409D4E1B6C171D00AC2304 /* FRPSwitchCell.m */, 141 | 29409D4F1B6C171D00AC2304 /* FRPTextFieldCell.h */, 142 | 29409D501B6C171D00AC2304 /* FRPTextFieldCell.m */, 143 | 29409D511B6C171D00AC2304 /* FRPValueCell.h */, 144 | 29409D521B6C171D00AC2304 /* FRPValueCell.m */, 145 | 29409D531B6C171D00AC2304 /* FRPViewCell.h */, 146 | 29409D541B6C171D00AC2304 /* FRPViewCell.m */, 147 | 29409D551B6C171D00AC2304 /* FRPViewSection.h */, 148 | 29409D561B6C171D00AC2304 /* FRPViewSection.m */, 149 | ); 150 | name = FRPreferences; 151 | path = ../../FRPreferences; 152 | sourceTree = ""; 153 | }; 154 | 29D15E7F1AF8B6F900F28A97 = { 155 | isa = PBXGroup; 156 | children = ( 157 | 29D15E8A1AF8B6F900F28A97 /* FRPreferences */, 158 | 29D15EA41AF8B6F900F28A97 /* FRPreferencesTests */, 159 | 29D15E891AF8B6F900F28A97 /* Products */, 160 | ); 161 | sourceTree = ""; 162 | }; 163 | 29D15E891AF8B6F900F28A97 /* Products */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 29D15E881AF8B6F900F28A97 /* FRPreferences.app */, 167 | 29D15EA11AF8B6F900F28A97 /* FRPreferencesTests.xctest */, 168 | ); 169 | name = Products; 170 | sourceTree = ""; 171 | }; 172 | 29D15E8A1AF8B6F900F28A97 /* FRPreferences */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | 29409D371B6C171D00AC2304 /* FRPreferences */, 176 | 29D15E8F1AF8B6F900F28A97 /* AppDelegate.h */, 177 | 29D15E901AF8B6F900F28A97 /* AppDelegate.m */, 178 | 29D15E921AF8B6F900F28A97 /* ViewController.h */, 179 | 29D15E931AF8B6F900F28A97 /* ViewController.m */, 180 | 29D15E951AF8B6F900F28A97 /* Main.storyboard */, 181 | 29D15E981AF8B6F900F28A97 /* Images.xcassets */, 182 | 29D15E9A1AF8B6F900F28A97 /* LaunchScreen.xib */, 183 | 29D15E8B1AF8B6F900F28A97 /* Supporting Files */, 184 | ); 185 | path = FRPreferences; 186 | sourceTree = ""; 187 | }; 188 | 29D15E8B1AF8B6F900F28A97 /* Supporting Files */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 29409D661B6C17D900AC2304 /* logo.png */, 192 | 292815651B5806AD0028A3B7 /* heart.png */, 193 | 292815661B5806AD0028A3B7 /* heart@2x.png */, 194 | 29D15E8C1AF8B6F900F28A97 /* Info.plist */, 195 | 29D15E8D1AF8B6F900F28A97 /* main.m */, 196 | ); 197 | name = "Supporting Files"; 198 | sourceTree = ""; 199 | }; 200 | 29D15EA41AF8B6F900F28A97 /* FRPreferencesTests */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | 29D15EA71AF8B6F900F28A97 /* FRPreferencesTests.m */, 204 | 29D15EA51AF8B6F900F28A97 /* Supporting Files */, 205 | ); 206 | path = FRPreferencesTests; 207 | sourceTree = ""; 208 | }; 209 | 29D15EA51AF8B6F900F28A97 /* Supporting Files */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | 29D15EA61AF8B6F900F28A97 /* Info.plist */, 213 | ); 214 | name = "Supporting Files"; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXGroup section */ 218 | 219 | /* Begin PBXNativeTarget section */ 220 | 29D15E871AF8B6F900F28A97 /* FRPreferences */ = { 221 | isa = PBXNativeTarget; 222 | buildConfigurationList = 29D15EAB1AF8B6F900F28A97 /* Build configuration list for PBXNativeTarget "FRPreferences" */; 223 | buildPhases = ( 224 | 29D15E841AF8B6F900F28A97 /* Sources */, 225 | 29D15E851AF8B6F900F28A97 /* Frameworks */, 226 | 29D15E861AF8B6F900F28A97 /* Resources */, 227 | ); 228 | buildRules = ( 229 | ); 230 | dependencies = ( 231 | ); 232 | name = FRPreferences; 233 | productName = FRPreferences; 234 | productReference = 29D15E881AF8B6F900F28A97 /* FRPreferences.app */; 235 | productType = "com.apple.product-type.application"; 236 | }; 237 | 29D15EA01AF8B6F900F28A97 /* FRPreferencesTests */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = 29D15EAE1AF8B6F900F28A97 /* Build configuration list for PBXNativeTarget "FRPreferencesTests" */; 240 | buildPhases = ( 241 | 29D15E9D1AF8B6F900F28A97 /* Sources */, 242 | 29D15E9E1AF8B6F900F28A97 /* Frameworks */, 243 | 29D15E9F1AF8B6F900F28A97 /* Resources */, 244 | ); 245 | buildRules = ( 246 | ); 247 | dependencies = ( 248 | 29D15EA31AF8B6F900F28A97 /* PBXTargetDependency */, 249 | ); 250 | name = FRPreferencesTests; 251 | productName = FRPreferencesTests; 252 | productReference = 29D15EA11AF8B6F900F28A97 /* FRPreferencesTests.xctest */; 253 | productType = "com.apple.product-type.bundle.unit-test"; 254 | }; 255 | /* End PBXNativeTarget section */ 256 | 257 | /* Begin PBXProject section */ 258 | 29D15E801AF8B6F900F28A97 /* Project object */ = { 259 | isa = PBXProject; 260 | attributes = { 261 | LastUpgradeCheck = 0730; 262 | ORGANIZATIONNAME = F0u4d; 263 | TargetAttributes = { 264 | 29D15E871AF8B6F900F28A97 = { 265 | CreatedOnToolsVersion = 6.1; 266 | }; 267 | 29D15EA01AF8B6F900F28A97 = { 268 | CreatedOnToolsVersion = 6.1; 269 | TestTargetID = 29D15E871AF8B6F900F28A97; 270 | }; 271 | }; 272 | }; 273 | buildConfigurationList = 29D15E831AF8B6F900F28A97 /* Build configuration list for PBXProject "FRPreferences" */; 274 | compatibilityVersion = "Xcode 3.2"; 275 | developmentRegion = English; 276 | hasScannedForEncodings = 0; 277 | knownRegions = ( 278 | en, 279 | Base, 280 | ); 281 | mainGroup = 29D15E7F1AF8B6F900F28A97; 282 | productRefGroup = 29D15E891AF8B6F900F28A97 /* Products */; 283 | projectDirPath = ""; 284 | projectRoot = ""; 285 | targets = ( 286 | 29D15E871AF8B6F900F28A97 /* FRPreferences */, 287 | 29D15EA01AF8B6F900F28A97 /* FRPreferencesTests */, 288 | ); 289 | }; 290 | /* End PBXProject section */ 291 | 292 | /* Begin PBXResourcesBuildPhase section */ 293 | 29D15E861AF8B6F900F28A97 /* Resources */ = { 294 | isa = PBXResourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 292815671B5806AD0028A3B7 /* heart.png in Resources */, 298 | 29D15E971AF8B6F900F28A97 /* Main.storyboard in Resources */, 299 | 292815681B5806AD0028A3B7 /* heart@2x.png in Resources */, 300 | 29409D671B6C17D900AC2304 /* logo.png in Resources */, 301 | 29D15E9C1AF8B6F900F28A97 /* LaunchScreen.xib in Resources */, 302 | 29D15E991AF8B6F900F28A97 /* Images.xcassets in Resources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | 29D15E9F1AF8B6F900F28A97 /* Resources */ = { 307 | isa = PBXResourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | /* End PBXResourcesBuildPhase section */ 314 | 315 | /* Begin PBXSourcesBuildPhase section */ 316 | 29D15E841AF8B6F900F28A97 /* Sources */ = { 317 | isa = PBXSourcesBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | 29409D591B6C171D00AC2304 /* FRPLinkCell.m in Sources */, 321 | 29409D581B6C171D00AC2304 /* FRPDeveloperCell.m in Sources */, 322 | 29409D641B6C171D00AC2304 /* FRPViewCell.m in Sources */, 323 | 29409D5D1B6C171D00AC2304 /* FRPSegmentCell.m in Sources */, 324 | 29409D571B6C171D00AC2304 /* FRPCell.m in Sources */, 325 | 291C0B221AFED1A000D829EB /* ViewController.m in Sources */, 326 | 29409D5C1B6C171D00AC2304 /* FRPSection.m in Sources */, 327 | 29409D5B1B6C171D00AC2304 /* FRPreferences.m in Sources */, 328 | 29409D621B6C171D00AC2304 /* FRPTextFieldCell.m in Sources */, 329 | 29D15E911AF8B6F900F28A97 /* AppDelegate.m in Sources */, 330 | 29409D5E1B6C171D00AC2304 /* FRPSelectListTable.m in Sources */, 331 | 29409D5F1B6C171D00AC2304 /* FRPSettings.m in Sources */, 332 | 29409D611B6C171D00AC2304 /* FRPSwitchCell.m in Sources */, 333 | 29409D5A1B6C171D00AC2304 /* FRPListCell.m in Sources */, 334 | 29409D601B6C171D00AC2304 /* FRPSliderCell.m in Sources */, 335 | 29409D651B6C171D00AC2304 /* FRPViewSection.m in Sources */, 336 | 29409D631B6C171D00AC2304 /* FRPValueCell.m in Sources */, 337 | 29D15E8E1AF8B6F900F28A97 /* main.m in Sources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | 29D15E9D1AF8B6F900F28A97 /* Sources */ = { 342 | isa = PBXSourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | 29D15EA81AF8B6F900F28A97 /* FRPreferencesTests.m in Sources */, 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXSourcesBuildPhase section */ 350 | 351 | /* Begin PBXTargetDependency section */ 352 | 29D15EA31AF8B6F900F28A97 /* PBXTargetDependency */ = { 353 | isa = PBXTargetDependency; 354 | target = 29D15E871AF8B6F900F28A97 /* FRPreferences */; 355 | targetProxy = 29D15EA21AF8B6F900F28A97 /* PBXContainerItemProxy */; 356 | }; 357 | /* End PBXTargetDependency section */ 358 | 359 | /* Begin PBXVariantGroup section */ 360 | 29D15E951AF8B6F900F28A97 /* Main.storyboard */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | 29D15E961AF8B6F900F28A97 /* Base */, 364 | ); 365 | name = Main.storyboard; 366 | sourceTree = ""; 367 | }; 368 | 29D15E9A1AF8B6F900F28A97 /* LaunchScreen.xib */ = { 369 | isa = PBXVariantGroup; 370 | children = ( 371 | 29D15E9B1AF8B6F900F28A97 /* Base */, 372 | ); 373 | name = LaunchScreen.xib; 374 | sourceTree = ""; 375 | }; 376 | /* End PBXVariantGroup section */ 377 | 378 | /* Begin XCBuildConfiguration section */ 379 | 29D15EA91AF8B6F900F28A97 /* Debug */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ALWAYS_SEARCH_USER_PATHS = NO; 383 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 384 | CLANG_CXX_LIBRARY = "libc++"; 385 | CLANG_ENABLE_MODULES = YES; 386 | CLANG_ENABLE_OBJC_ARC = YES; 387 | CLANG_WARN_BOOL_CONVERSION = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_EMPTY_BODY = YES; 391 | CLANG_WARN_ENUM_CONVERSION = YES; 392 | CLANG_WARN_INT_CONVERSION = YES; 393 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 394 | CLANG_WARN_UNREACHABLE_CODE = YES; 395 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 396 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 397 | COPY_PHASE_STRIP = NO; 398 | ENABLE_STRICT_OBJC_MSGSEND = YES; 399 | ENABLE_TESTABILITY = YES; 400 | GCC_C_LANGUAGE_STANDARD = gnu99; 401 | GCC_DYNAMIC_NO_PIC = NO; 402 | GCC_OPTIMIZATION_LEVEL = 0; 403 | GCC_PREPROCESSOR_DEFINITIONS = ( 404 | "DEBUG=1", 405 | "$(inherited)", 406 | ); 407 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 415 | MTL_ENABLE_DEBUG_INFO = YES; 416 | ONLY_ACTIVE_ARCH = YES; 417 | SDKROOT = iphoneos; 418 | }; 419 | name = Debug; 420 | }; 421 | 29D15EAA1AF8B6F900F28A97 /* Release */ = { 422 | isa = XCBuildConfiguration; 423 | buildSettings = { 424 | ALWAYS_SEARCH_USER_PATHS = NO; 425 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 426 | CLANG_CXX_LIBRARY = "libc++"; 427 | CLANG_ENABLE_MODULES = YES; 428 | CLANG_ENABLE_OBJC_ARC = YES; 429 | CLANG_WARN_BOOL_CONVERSION = YES; 430 | CLANG_WARN_CONSTANT_CONVERSION = YES; 431 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 432 | CLANG_WARN_EMPTY_BODY = YES; 433 | CLANG_WARN_ENUM_CONVERSION = YES; 434 | CLANG_WARN_INT_CONVERSION = YES; 435 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 436 | CLANG_WARN_UNREACHABLE_CODE = YES; 437 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 438 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 439 | COPY_PHASE_STRIP = YES; 440 | ENABLE_NS_ASSERTIONS = NO; 441 | ENABLE_STRICT_OBJC_MSGSEND = YES; 442 | GCC_C_LANGUAGE_STANDARD = gnu99; 443 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 444 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 445 | GCC_WARN_UNDECLARED_SELECTOR = YES; 446 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 447 | GCC_WARN_UNUSED_FUNCTION = YES; 448 | GCC_WARN_UNUSED_VARIABLE = YES; 449 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 450 | MTL_ENABLE_DEBUG_INFO = NO; 451 | SDKROOT = iphoneos; 452 | VALIDATE_PRODUCT = YES; 453 | }; 454 | name = Release; 455 | }; 456 | 29D15EAC1AF8B6F900F28A97 /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 460 | CODE_SIGN_IDENTITY = ""; 461 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 462 | INFOPLIST_FILE = FRPreferences/Info.plist; 463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 464 | PRODUCT_BUNDLE_IDENTIFIER = "com.f0u4d.$(PRODUCT_NAME:rfc1034identifier)"; 465 | PRODUCT_NAME = "$(TARGET_NAME)"; 466 | }; 467 | name = Debug; 468 | }; 469 | 29D15EAD1AF8B6F900F28A97 /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 473 | CODE_SIGN_IDENTITY = ""; 474 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 475 | INFOPLIST_FILE = FRPreferences/Info.plist; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 477 | PRODUCT_BUNDLE_IDENTIFIER = "com.f0u4d.$(PRODUCT_NAME:rfc1034identifier)"; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | }; 480 | name = Release; 481 | }; 482 | 29D15EAF1AF8B6F900F28A97 /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | BUNDLE_LOADER = "$(TEST_HOST)"; 486 | FRAMEWORK_SEARCH_PATHS = ( 487 | "$(SDKROOT)/Developer/Library/Frameworks", 488 | "$(inherited)", 489 | ); 490 | GCC_PREPROCESSOR_DEFINITIONS = ( 491 | "DEBUG=1", 492 | "$(inherited)", 493 | ); 494 | INFOPLIST_FILE = FRPreferencesTests/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 496 | PRODUCT_BUNDLE_IDENTIFIER = "com.f0u4d.$(PRODUCT_NAME:rfc1034identifier)"; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FRPreferences.app/FRPreferences"; 499 | }; 500 | name = Debug; 501 | }; 502 | 29D15EB01AF8B6F900F28A97 /* Release */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | BUNDLE_LOADER = "$(TEST_HOST)"; 506 | FRAMEWORK_SEARCH_PATHS = ( 507 | "$(SDKROOT)/Developer/Library/Frameworks", 508 | "$(inherited)", 509 | ); 510 | INFOPLIST_FILE = FRPreferencesTests/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = "com.f0u4d.$(PRODUCT_NAME:rfc1034identifier)"; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FRPreferences.app/FRPreferences"; 515 | }; 516 | name = Release; 517 | }; 518 | /* End XCBuildConfiguration section */ 519 | 520 | /* Begin XCConfigurationList section */ 521 | 29D15E831AF8B6F900F28A97 /* Build configuration list for PBXProject "FRPreferences" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | 29D15EA91AF8B6F900F28A97 /* Debug */, 525 | 29D15EAA1AF8B6F900F28A97 /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | defaultConfigurationName = Release; 529 | }; 530 | 29D15EAB1AF8B6F900F28A97 /* Build configuration list for PBXNativeTarget "FRPreferences" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 29D15EAC1AF8B6F900F28A97 /* Debug */, 534 | 29D15EAD1AF8B6F900F28A97 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | 29D15EAE1AF8B6F900F28A97 /* Build configuration list for PBXNativeTarget "FRPreferencesTests" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | 29D15EAF1AF8B6F900F28A97 /* Debug */, 543 | 29D15EB01AF8B6F900F28A97 /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | defaultConfigurationName = Release; 547 | }; 548 | /* End XCConfigurationList section */ 549 | }; 550 | rootObject = 29D15E801AF8B6F900F28A97 /* Project object */; 551 | } 552 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | @property (nonatomic, retain) NSMutableArray *data; 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "FRPrefs.h" 11 | 12 | #define greenColor [UIColor colorWithRed:1/255.0f green:152/255.0f blue:117/255.0f alpha:1.0f] 13 | 14 | @implementation ViewController 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 19 | [button addTarget:self action:@selector(loadNewSettings:) 20 | forControlEvents:UIControlEventTouchUpInside]; 21 | [button setTitle:@"Show Table" forState:UIControlStateNormal]; 22 | button.frame = CGRectMake(self.view.frame.size.width/2 - 160/2, self.view.frame.size.height/2 - 40/2, 160.0, 40.0); 23 | [self.view addSubview:button]; 24 | 25 | 26 | UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 27 | [button2 addTarget:self action:@selector(logCurrentValue:) 28 | forControlEvents:UIControlEventTouchUpInside]; 29 | [button2 setTitle:@"Log the current values" forState:UIControlStateNormal]; 30 | button2.frame = CGRectMake(self.view.frame.size.width/2 - 160/2, (self.view.frame.size.height/2 - 40/2)+ 60, 160.0, 40.0); 31 | [self.view addSubview:button2]; 32 | } 33 | 34 | 35 | - (void)loadNewSettings:(id)sender { 36 | FRPViewSection *headerSection = [FRPViewSection sectionWithHeight:70 37 | initBlock:^(UITableViewCell *cell) { 38 | /* design your cell as you wish */ 39 | /* block of code executed during cell initialization */ 40 | cell.backgroundColor = [UIColor clearColor]; 41 | 42 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; 43 | label.font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:48]; 44 | [label setText:@"FRPreferences"]; 45 | [label setTextColor:[UIColor blackColor]]; 46 | [label setShadowColor:[UIColor colorWithRed:1/255.0f green:152/255.0f blue:117/255.0f alpha:1.0f]]; 47 | [label setShadowOffset:CGSizeMake(1,1)]; 48 | [label setTextAlignment:NSTextAlignmentCenter]; 49 | [label setTag:111]; 50 | 51 | UILabel *underLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 52 | [underLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:14]]; 53 | [underLabel setText:@"Thank you for using our preferences!"]; 54 | [underLabel setTextColor:[UIColor grayColor]]; 55 | [underLabel setTextAlignment:NSTextAlignmentCenter]; 56 | [underLabel setTag:222]; 57 | 58 | [cell.contentView addSubview:label]; 59 | [cell.contentView addSubview:underLabel]; 60 | } 61 | layoutBlock:^(UITableViewCell *cell) { 62 | /* block of code executed during cell layoutSubviews */ 63 | [[cell.contentView viewWithTag:111] setFrame:CGRectMake(0, -5, cell.frame.size.width, 60)]; 64 | [[cell.contentView viewWithTag:222] setFrame:CGRectMake(0, 30, cell.frame.size.width, 60)]; 65 | }]; 66 | 67 | 68 | 69 | FRPSection *section1 = [FRPSection sectionWithTitle:@"Section 1 Title" footer:@"Some footer for section 1"]; 70 | 71 | 72 | 73 | FRPSwitchCell *switchCell = [FRPSwitchCell cellWithTitle:@"Switch 1" 74 | setting:[FRPSettings settingsWithKey:@"Switch1" defaultValue:@NO] 75 | postNotification:nil 76 | changeBlock:^(UISwitch *switchView) { 77 | NSLog(@"switch 1 is: %@",[(UISwitch *)switchView isOn]?@"ENABLED":@"DISABLED"); 78 | }]; 79 | // [switchCell.switchView setOnTintColor:[UIColor colorWithRed:0 green:0.545 blue:0.894 alpha:1]]; 80 | [section1 addCell:switchCell]; 81 | 82 | 83 | 84 | FRPTextFieldCell *textFieldCell = [FRPTextFieldCell cellWithTitle:@"Text Field 1" 85 | setting:[FRPSettings settingsWithKey:@"Field1" defaultValue:@""] 86 | placeholder:@"Enter Some text" 87 | postNotification:nil 88 | changeBlock:^(UITextField *sender) { 89 | NSLog(@"textfield 1 text is: %@",[(UITextField *)sender text]); 90 | }]; 91 | [section1 addCell:textFieldCell]; 92 | 93 | 94 | 95 | [section1 addCell:[FRPLinkCell cellWithTitle:@"Link Cell" selectedBlock:^(id sender) { 96 | NSLog(@"%@ is selected",[sender class]); 97 | }]]; 98 | 99 | 100 | 101 | FRPListCell *listCell = [FRPListCell cellWithTitle:@"List Cell" 102 | setting:[FRPSettings settingsWithKey:@"ListCellKey" defaultValue:@"Value1"] 103 | items:@[@"Item 1",@"Item 2",@"Item 3",@"Item 4"] 104 | value:@[@"value1",@"value2",@"value3",@"value4"] 105 | popViewOnSelect:YES 106 | postNotification:nil 107 | changedBlock:^(NSString *value) { 108 | NSLog(@"Did Select Value: %@",value); 109 | }]; 110 | [section1 addCell:listCell]; 111 | 112 | 113 | 114 | FRPSliderCell *sliderCell = [FRPSliderCell cellWithTitle:@"Slider Cell" 115 | setting:[FRPSettings settingsWithKey:@"SliderKey" defaultValue:[NSNumber numberWithFloat:150]] 116 | min:0.0 117 | max:255.0 118 | postNotification:nil 119 | changeBlock:^(UISlider *slider) { 120 | NSLog(@"Slider Value changed: %f",[(UISlider *)slider value]); 121 | }]; 122 | [section1 addCell:sliderCell]; 123 | 124 | 125 | 126 | FRPSegmentCell *segmentCell = [FRPSegmentCell cellWithTitle:@"Segment Cell" 127 | setting:[FRPSettings settingsWithKey:@"SegmentValue" defaultValue:@"6"] 128 | values:@[@"2",@"5",@"6",@"All"] 129 | displayedValues:@[@"Two",@"Five",@"Six",@"All"] 130 | postNotification:nil 131 | changeBlock:^(NSString *item) { 132 | NSLog(@"Selected Item: %@",item); 133 | }]; 134 | [section1 addCell:segmentCell]; 135 | 136 | 137 | FRPViewCell *viewCell = [FRPViewCell cellWithHeight:60 138 | initBlock:^(UITableViewCell *cell) { 139 | cell.backgroundColor = [UIColor colorWithRed:245/255.0f green:245/255.0f blue:245/255.0f alpha:1.0f]; 140 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; 141 | label.text = @"Customized Cell View"; 142 | label.textColor = greenColor; 143 | label.textAlignment = NSTextAlignmentCenter; 144 | label.tag = 123; 145 | [cell.contentView addSubview:label]; 146 | } 147 | layoutBlock:^(UITableViewCell *cell) { 148 | UILabel *label = (UILabel *)[cell.contentView viewWithTag:123]; 149 | label.frame = CGRectMake(0, 0, cell.contentView.frame.size.width, 60); 150 | }]; 151 | 152 | 153 | [section1 addCell:viewCell]; 154 | 155 | 156 | [section1 addCell:[FRPValueCell cellWithTitle:@"Title" detail:@"Detail Text"]]; 157 | 158 | 159 | /* ANOTHER SECTION */ 160 | 161 | FRPSection *section2 = [FRPSection sectionWithTitle:@"Section 2 Title" footer:@"Some footer for section 2"]; 162 | 163 | 164 | [section2 addCell:[FRPSwitchCell cellWithTitle:@"Switch 2" setting:[FRPSettings settingsWithKey:@"Switch1" defaultValue:@NO] postNotification:nil changeBlock:^(id sender) { 165 | NSLog(@"switch 1 is: %@",[(UISwitch *)sender isOn]?@"ENABLED":@"DISABLED"); 166 | }]]; 167 | 168 | 169 | FRPLinkCell *subTableLinkCell = [FRPLinkCell cellWithTitle:@"New Settings Window" selectedBlock:^(id sender) { 170 | 171 | FRPSection *subSection1 = [FRPSection sectionWithTitle:@"Section 1 Title" footer:@"Some footer for section 1"]; 172 | [subSection1 addCell:[FRPSwitchCell cellWithTitle:@"Switch 1" setting:[FRPSettings settingsWithKey:@"Switch1" defaultValue:@NO] postNotification:nil changeBlock:^(id sender) { }]]; 173 | 174 | FRPSection *subSection2 = [FRPSection sectionWithTitle:@"Section 2 Title" footer:@"Some footer for section 1"]; 175 | [subSection2 addCell:[FRPSwitchCell cellWithTitle:@"Switch 2" setting:[FRPSettings settingsWithKey:@"Switch2" defaultValue:@NO] postNotification:nil changeBlock:^(id sender) { }]]; 176 | 177 | FRPreferences *subTable = [FRPreferences tableWithSections:@[subSection1,subSection2] title:@"Sub Table" tintColor:greenColor]; 178 | [self.navigationController pushViewController:subTable animated:YES]; 179 | 180 | }]; 181 | 182 | [section2 addCell:subTableLinkCell]; 183 | 184 | [section2 addCell:[FRPDeveloperCell cellWithTitle:@"Fouad Raheb" detail:@"@iF0u4d" image:[UIImage imageNamed:@"logo.png"] url:@"http://f0u4d.com/twitter"]]; 185 | 186 | 187 | FRPreferences *table = [FRPreferences tableWithSections:@[headerSection,section1,section2] 188 | title:@"FRPreferences" 189 | tintColor:greenColor]; 190 | // table.plistPath = @"some/path/to/file.plist"; // You can set a plistPath if you wish to save values into plist file 191 | 192 | UIBarButtonItem *heart = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"heart.png"] style:UIBarButtonItemStylePlain target:self action:@selector(shareTapped:)]; 193 | table.navigationItem.rightBarButtonItem = heart; 194 | 195 | [self.navigationController pushViewController:table animated:YES]; 196 | 197 | table.navigationController.navigationBar.tintColor = greenColor; 198 | } 199 | 200 | 201 | - (void)logCurrentValue:(id)sender { 202 | NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 203 | 204 | NSLog(@"Switch1: %@",[[userDefaults objectForKey:@"Switch1"] boolValue]?@"Enabled":@"Disabled"); 205 | 206 | NSLog(@"Field1: %@",[userDefaults objectForKey:@"Field1"]); 207 | 208 | NSLog(@"SliderKey2: %f",[[userDefaults objectForKey:@"SliderKey2"] floatValue]); 209 | 210 | NSLog(@"List Cell Value: %@",[userDefaults objectForKey:@"ListCellKey"]); 211 | } 212 | 213 | - (void)shareTapped:(id)sender { 214 | NSLog(@"Share Tapped!"); 215 | } 216 | 217 | @end 218 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FouadRaheb/FRPreferences/d33c8cf6c03d53643c2e8a7526bf015c4bed3a5d/FRPreferencesExample/FRPreferences/heart.png -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/heart@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FouadRaheb/FRPreferences/d33c8cf6c03d53643c2e8a7526bf015c4bed3a5d/FRPreferencesExample/FRPreferences/heart@2x.png -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FouadRaheb/FRPreferences/d33c8cf6c03d53643c2e8a7526bf015c4bed3a5d/FRPreferencesExample/FRPreferences/logo.png -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferences/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferencesTests/FRPreferencesTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPreferencesTests.m 3 | // FRPreferencesTests 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface FRPreferencesTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation FRPreferencesTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /FRPreferencesExample/FRPreferencesTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FRPreferences 2 | 3 | FRPreferences allows you to easily setup an In-App preferences table. 4 | 5 | ![](https://raw.githubusercontent.com/FouadRaheb/FRPreferences/master/Screenshot/screenshots.png) 6 | 7 | ## Installation 8 | 9 | ```ruby 10 | pod 'FRPreferences', :git => 'https://github.com/FouadRaheb/FRPreferences' 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```obj-c 16 | #import 17 | ``` 18 | **Creating Section** 19 | 20 | FRPreferences has 2 types of sections: 21 | 22 | - `FRPSection`: used to create a section with multiple cells 23 | - `FRPViewSection`: used to create a view section 24 | 25 | ***FRPSection*** 26 | 27 | ```obj-c 28 | FRPSection *section1 = [FRPSection sectionWithTitle:@"Section 1 Title" footer:@"Some footer for section 1"]; 29 | ``` 30 | 31 | 32 | 33 | **Adding cells to a section** 34 | 35 | - `FRPSwitchCell`: used to create a cell with a UISwitch 36 | - `FRPTextFieldCell`: used to create a cell with a UITextField 37 | - `FRPLinkCell`: used to a cell with disclosure indicator 38 | - `FRPListCell`: used to create a list of items to select one 39 | - `FRPSliderCell`: used to create a cell with a UISlider 40 | - `FRPSegmentCell`: used to create cell with a UISegmentedControl 41 | - `FRPViewCell`: used to customize a view inside a cell 42 | - `FRPValueCell`: used to create a cell with just a title and detail text 43 | 44 | 45 | ***FRPSwitchCell*** 46 | 47 | ```obj-c 48 | FRPSwitchCell *switchCell = [FRPSwitchCell cellWithTitle:@"Switch 1" 49 | setting:[FRPSettings settingsWithKey:@"Switch1" defaultValue:@NO] 50 | postNotification:nil 51 | changeBlock:^(UISwitch *switch) { 52 | NSLog(@"switch 1 is: %@",[(UISwitch *)switch isOn]?@"ENABLED":@"DISABLED"); 53 | }]; 54 | [section1 addCell:switchCell]; 55 | 56 | ``` 57 | 58 | 59 | ***FRPTextFieldCell*** 60 | 61 | ```obj-c 62 | FRPTextFieldCell *textFieldCell = [FRPTextFieldCell cellWithTitle:@"Text Field 1" 63 | setting:[FRPSettings settingsWithKey:@"Field1" defaultValue:@""] 64 | placeholder:@"Enter Some text" 65 | postNotification:nil 66 | changeBlock:^(UITextField *field) { 67 | NSLog(@"textfield 1 text is: %@",[(UITextField *)field text]); 68 | }]; 69 | [section1 addCell:textFieldCell]; 70 | ``` 71 | 72 | ***FRPLinkCell*** 73 | 74 | ```obj-c 75 | [section1 addCell:[FRPLinkCell cellWithTitle:@"Link Cell" selectedBlock:^{ 76 | NSLog(@"Link Cell Selected"); 77 | }]]; 78 | ``` 79 | 80 | ***FRPListCell*** 81 | 82 | ```obj-c 83 | FRPListCell *listCell = [FRPListCell cellWithTitle:@"List Cell" 84 | setting:[FRPSettings settingsWithKey:@"ListCellKey" defaultValue:@"Value1"] 85 | items:@[@"Item 1",@"Item 2",@"Item 3",@"Item 4"] 86 | value:@[@"value1",@"value2",@"value3",@"value4"] 87 | popViewOnSelect:YES 88 | postNotification:nil 89 | changedBlock:^(NSString *value) { 90 | NSLog(@"Did Select Value: %@",value); 91 | }]; 92 | [section1 addCell:listCell]; 93 | ``` 94 | 95 | 96 | ***FRPSliderCell*** 97 | 98 | ```obj-c 99 | FRPSliderCell *sliderCell = [FRPSliderCell cellWithTitle:@"Slider Cell" 100 | setting:[FRPSettings settingsWithKey:@"SliderKey" defaultValue:[NSNumber numberWithFloat:150]] 101 | min:0.0 102 | max:255.0 103 | postNotification:nil 104 | changeBlock:^(UISlider *slider) { 105 | NSLog(@"Slider Value changed: %f",[(UISlider *)slider value]); 106 | }]; 107 | [section1 addCell:sliderCell]; 108 | ``` 109 | 110 | 111 | ***FRPSegmentCell*** 112 | 113 | ```obj-c 114 | FRPSegmentCell *segmentCell = [FRPSegmentCell cellWithTitle:@"Segment Cell" 115 | setting:[FRPSettings settingsWithKey:@"SegmentValue" defaultValue:@"6"] 116 | values:@[@"2",@"5",@"6",@"All"] 117 | displayedValues:@[@"Two",@"Five",@"Six",@"All"] 118 | postNotification:nil 119 | changeBlock:^(NSString *item) { 120 | NSLog(@"Selected Item: %@",item); 121 | }]; 122 | [section2 addCell:segmentCell]; 123 | ``` 124 | 125 | 126 | ***FRPViewCell*** 127 | 128 | ```obj-c 129 | FRPViewCell *viewCell = [FRPViewCell cellWithHeight:60 130 | initBlock:^(UITableViewCell *cell) { 131 | cell.backgroundColor = [UIColor colorWithRed:245/255.0f green:245/255.0f blue:245/255.0f alpha:1.0f]; 132 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; 133 | label.text = @"Customized Cell View"; 134 | label.textColor = greenColor; 135 | label.textAlignment = NSTextAlignmentCenter; 136 | label.tag = 123; 137 | [cell.contentView addSubview:label]; 138 | } 139 | layoutBlock:^(UITableViewCell *cell) { 140 | UILabel *label = (UILabel *)[cell.contentView viewWithTag:123]; 141 | label.frame = CGRectMake(0, 0, cell.contentView.frame.size.width, 60); 142 | }]; 143 | ``` 144 | 145 | ***FRPValueCell*** 146 | 147 | ```obj-c 148 | [section2 addCell:[FRPValueCell cellWithTitle:@"Title" detail:@"Detail Text"]]; 149 | ``` 150 | 151 | 152 | **Creating a section view** 153 | 154 | ***FRPViewSection*** 155 | 156 | ```obj-c 157 | FRPViewSection *headerSection = [FRPViewSection sectionWithHeight:70 158 | initBlock:^(UITableViewCell *cell) { 159 | /* block called once during cell initialization */ 160 | } 161 | layoutBlock:^(UITableViewCell *cell) { 162 | /* block called during cell layoutSubviews */ 163 | }]; 164 | ``` 165 | 166 | 167 | **Creating The Table** 168 | 169 | ```obj-c 170 | FRPreferences *table = [FRPreferences tableWithSections:@[headerSection,section1,section2] 171 | title:@"FRPreferences" 172 | tintColor:greenColor]; 173 | ``` 174 | 175 | **Data Saving** 176 | 177 | FRPreferences saves values to NSUserDefaults, but you can also provide a path for a plist and the values will be saved to both NSUserDefaults & plist. 178 | 179 | ```obj-c 180 | table.plistPath = @"some/path/to/file.plist"; 181 | ``` 182 | 183 | **Why not add a button to the navigation bar?** 184 | 185 | ```obj-c 186 | UIBarButtonItem *heart = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"heart.png"] style:UIBarButtonItemStylePlain target:self action:@selector(shareTapped:)]; 187 | table.navigationItem.rightBarButtonItem = heart; 188 | ``` 189 | 190 | **Displaying the table** 191 | 192 | ```obj-c 193 | [self.navigationController pushViewController:table animated:YES]; 194 | ``` 195 | 196 | 197 | **We could also add a sub-table using FRPLinkCell** 198 | 199 | ```obj-c 200 | [section1 addCell:[FRPLinkCell cellWithTitle:@"New Settings Window" selectedBlock:^(id sender) { 201 | FRPSection *subSection1 = [FRPSection sectionWithTitle:@"Section 1 Title" footer:@"Some footer for section 1"]; 202 | [subSection1 addCell:[FRPSwitchCell cellWithTitle:@"Switch 1" setting:[FRPSettings settingsWithKey:@"Switch1" defaultValue:@NO] postNotification:nil changeBlock:^(id sender) { }]]; 203 | 204 | FRPSection *subSection2 = [FRPSection sectionWithTitle:@"Section 2 Title" footer:@"Some footer for section 1"]; 205 | [subSection2 addCell:[FRPSwitchCell cellWithTitle:@"Switch 2" setting:[FRPSettings settingsWithKey:@"Switch2" defaultValue:@NO] postNotification:nil changeBlock:^(id sender) { }]]; 206 | 207 | FRPreferences *subTable = [FRPreferences tableWithSections:@[subSection1,subSection2] title:@"Sub Table" tintColor:greenColor]; 208 | [self.navigationController pushViewController:subTable animated:YES]; 209 | }]]; 210 | ``` 211 | 212 | ## License 213 | FRPreferences is under the GPL license. -------------------------------------------------------------------------------- /Screenshot/screenshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FouadRaheb/FRPreferences/d33c8cf6c03d53643c2e8a7526bf015c4bed3a5d/Screenshot/screenshots.png --------------------------------------------------------------------------------