diff --git a/Bohr.podspec b/Bohr.podspec index 5374618..580fff4 100755 --- a/Bohr.podspec +++ b/Bohr.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Bohr" - s.version = "3.0.0-rc.1" + s.version = "3.0.0-rc.2" s.summary = "Settings screen composing framework" s.homepage = "https://github.com/DavdRoman/Bohr" s.author = { "David Román" => "d@vidroman.me" } diff --git a/Bohr.xcodeproj/project.pbxproj b/Bohr.xcodeproj/project.pbxproj index b75dd5c..4d80a9d 100644 --- a/Bohr.xcodeproj/project.pbxproj +++ b/Bohr.xcodeproj/project.pbxproj @@ -325,7 +325,7 @@ 75C7ADC91B1AB2F80050C8AA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0640; + LastUpgradeCheck = 0700; TargetAttributes = { 75C7ADD21B1AB3010050C8AA = { CreatedOnToolsVersion = 6.3.2; @@ -435,6 +435,7 @@ 75C7ADCD1B1AB2F80050C8AA /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ENABLE_TESTABILITY = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; }; @@ -490,6 +491,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "me.davidroman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -533,6 +535,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "me.davidroman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -589,6 +592,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "me.davidroman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -640,6 +644,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "me.davidroman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; diff --git a/Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme b/Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme index 3f59c01..c078a2f 100644 --- a/Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme +++ b/Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> + + 0) { + [self.tableView beginUpdates]; + [self.tableView reloadSections:affectedIndexes withRowAnimation:UITableViewRowAnimationFade]; + [self.tableView endUpdates]; + } + [UIView performWithoutAnimation:^{ CGPoint previousContentOffset = self.tableView.contentOffset; [self.tableView beginUpdates]; diff --git a/Bohr/BOTableViewSection.h b/Bohr/BOTableViewSection.h index 1cbdec3..e2bf66b 100644 --- a/Bohr/BOTableViewSection.h +++ b/Bohr/BOTableViewSection.h @@ -30,7 +30,7 @@ /// The footer title color of the section. @property (nonatomic) UIFont *footerTitleFont MZ_APPEARANCE_SELECTOR; -/// The cells for the section. +/// The visible cells in the section. @property (nonatomic, readonly) NSArray *cells; /** Initializes a new BOTableViewSection object. diff --git a/Bohr/BOTableViewSection.m b/Bohr/BOTableViewSection.m index 69ef6b9..201bb5f 100644 --- a/Bohr/BOTableViewSection.m +++ b/Bohr/BOTableViewSection.m @@ -10,6 +10,7 @@ @interface BOTableViewSection () +@property (nonatomic) NSArray *rawCells; @property (nonatomic) NSArray *cells; @end @@ -22,9 +23,9 @@ + (instancetype)appearance { - (instancetype)init { if (self = [super init]) { - self.cells = [NSArray new]; + self.rawCells = [NSArray new]; // Workaround to UITableViewHeaderFooterView's default 0-sized font driving iOS 9 nuts (yeah, WTF Apple). - self.footerTitleFont = [UIFont fontWithName:@"Helvetica" size:13]; + self.footerTitleFont = [UIFont systemFontOfSize:13]; // I mean, really, if you... // NSLog(@"%@", [UITableViewHeaderFooterView new].textLabel.font); // you get "font-size: 0.00pt". @@ -50,7 +51,17 @@ + (instancetype)sectionWithHeaderTitle:(NSString *)headerTitle handler:(void (^) } - (void)addCell:(BOTableViewCell *)cell { - self.cells = [self.cells arrayByAddingObject:cell]; + self.rawCells = [self.rawCells arrayByAddingObject:cell]; +} + +- (NSArray *)cells { + return [self.rawCells filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(BOTableViewCell *cell, NSDictionary *bindings) { + if (cell.visibilityKey.length > 0) { + return cell.visibilityBlock([[NSUserDefaults standardUserDefaults] objectForKey:cell.visibilityKey]); + } + + return YES; + }]]; } @end diff --git a/Bohr/Info.plist b/Bohr/Info.plist index feea5cd..e0f4bf7 100644 --- a/Bohr/Info.plist +++ b/Bohr/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.davidroman.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/BohrDemo/Info.plist b/BohrDemo/Info.plist index ba66b52..bf804c9 100644 --- a/BohrDemo/Info.plist +++ b/BohrDemo/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.davidroman.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/BohrDemo/TableViewController.m b/BohrDemo/TableViewController.m index e870f0f..c93e851 100644 --- a/BohrDemo/TableViewController.m +++ b/BohrDemo/TableViewController.m @@ -18,7 +18,11 @@ - (void)setup { [section addCell:[BOSwitchTableViewCell cellWithTitle:@"Switch 1" key:@"bool_1" handler:nil]]; - [section addCell:[BOSwitchTableViewCell cellWithTitle:@"Switch 2" key:@"bool_2" handler:^(BOSwitchTableViewCell *cell) { + [section addCell:[BOSwitchTableViewCell cellWithTitle:@"Switch 2 (dependant on switch 1)" key:@"bool_2" handler:^(BOSwitchTableViewCell *cell) { + cell.visibilityKey = @"bool_1"; + cell.visibilityBlock = ^BOOL(id settingValue) { + return [settingValue boolValue]; + }; cell.onFooterTitle = @"Switch setting 2 is on"; cell.offFooterTitle = @"Switch setting 2 is off"; }]];