Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
2.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed Jun 26, 2015
1 parent 04bf619 commit 6c2bc36
Show file tree
Hide file tree
Showing 46 changed files with 844 additions and 551 deletions.
Binary file modified Assets/1.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Bohr.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Bohr"
s.version = "1.0.1"
s.version = "2.0.0"
s.summary = "Settings screen composing framework"
s.homepage = "https://github.com/DavdRoman/Bohr"
s.author = { "David Roman" => "d@vidroman.me" }
Expand Down
112 changes: 56 additions & 56 deletions Bohr.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Bohr/BOButtonTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

@interface BOButtonTableViewCell : BOTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title didTriggerBlock:(void (^)(void))didTriggerBlock;
@property (nonatomic) id target;
@property (nonatomic) SEL action;

- (void)setTarget:(id)target action:(SEL)action;

@end
24 changes: 11 additions & 13 deletions Bohr/BOButtonTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@

#import "BOTableViewCell+Subclass.h"

@interface BOButtonTableViewCell ()

@property (nonatomic, copy) void(^didTriggerBlock)(void);

@end

@implementation BOButtonTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title didTriggerBlock:(void (^)(void))didTriggerBlock {
BOButtonTableViewCell *cell = [super cellWithTitle:title setting:nil];
cell.didTriggerBlock = didTriggerBlock;
return cell;
}

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
self.textLabel.textAlignment = NSTextAlignmentCenter;
}

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];
if (self.didTriggerBlock) self.didTriggerBlock();

if ([self.target respondsToSelector:self.action]) {
[self.target performSelector:self.action];
}
}

- (void)setTarget:(id)target action:(SEL)action {
self.target = target;
self.action = action;
}

@end
4 changes: 3 additions & 1 deletion Bohr/BOChoiceTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@interface BOChoiceTableViewCell : BOTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title setting:(BOSetting *)setting options:(NSArray *)options;
@property (nonatomic, strong) NSArray *options;

@property (nonatomic, strong) IBInspectable NSArray *footerTitles;

@end
36 changes: 18 additions & 18 deletions Bohr/BOChoiceTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@

#import "BOTableViewCell+Subclass.h"

@interface BOChoiceTableViewCell ()

@property (nonatomic, strong) NSArray *options;

@end

@implementation BOChoiceTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title setting:(BOSetting *)setting options:(NSArray *)options {
BOChoiceTableViewCell *cell = [super cellWithTitle:title setting:setting];
cell.options = options;
return cell;
}

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}

- (NSString *)footerTitle {
NSInteger currentOption = [self.setting.value integerValue];

if (currentOption < self.footerTitles.count) {
return self.footerTitles[currentOption];
}

return nil;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];

NSInteger currentOption = [self.setting.value integerValue];

if (currentOption < self.options.count-1) {
self.setting.value = @(currentOption+1);
} else {
self.setting.value = @0;
if (self.accessoryType != UITableViewCellAccessoryDisclosureIndicator) {
NSInteger currentOption = [self.setting.value integerValue];

if (currentOption < self.options.count-1) {
self.setting.value = @(currentOption+1);
} else {
self.setting.value = @0;
}
}
}

Expand Down
15 changes: 0 additions & 15 deletions Bohr/BODisclosureTableViewCell.h

This file was deleted.

37 changes: 0 additions & 37 deletions Bohr/BODisclosureTableViewCell.m

This file was deleted.

15 changes: 15 additions & 0 deletions Bohr/BOOptionTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BOOptionTableViewCell.h
// Bohr
//
// Created by David Román Aguirre on 21/6/15.
//
//

#import "BOTableViewCell.h"

@interface BOOptionTableViewCell : BOTableViewCell

@property (nonatomic, strong) IBInspectable NSString *footerTitle;

@end
36 changes: 36 additions & 0 deletions Bohr/BOOptionTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// BOOptionTableViewCell.m
// Bohr
//
// Created by David Román Aguirre on 21/6/15.
//
//

#import "BOOptionTableViewCell.h"

#import "BOTableViewCell+Subclass.h"

@implementation BOOptionTableViewCell

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];

NSInteger optionIndex = [viewController.tableView indexPathForCell:self].row;
self.setting.value = @(optionIndex);
}

- (void)settingValueDidChange {
NSInteger optionIndex = [self.setting.value integerValue];

if (optionIndex == self.indexPath.row) {
self.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
self.accessoryType = UITableViewCellAccessoryNone;
}
}

@end
Empty file modified Bohr/BOSetting+Private.h
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Bohr/BOSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
@property (nonatomic, readonly) NSString *key;
@property (nonatomic, assign) id value;

+ (instancetype)settingWithDefaultValue:(id)defaultValue forKey:(NSString *)key;
+ (instancetype)settingWithKey:(NSString *)key;

@end
7 changes: 3 additions & 4 deletions Bohr/BOSetting.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

@implementation BOSetting

+ (instancetype)settingWithDefaultValue:(id)defaultValue forKey:(NSString *)key {
return [[self alloc] initWithDefaultValue:defaultValue forKey:key];
+ (instancetype)settingWithKey:(NSString *)key {
return [[self alloc] initWithKey:key];
}

- (instancetype)initWithDefaultValue:(id)defaultValue forKey:(NSString *)key {
- (instancetype)initWithKey:(NSString *)key {
if (self = [super init]) {
_key = key;
[[NSUserDefaults standardUserDefaults] registerDefaults:@{self.key: defaultValue}];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:self.key options:NSKeyValueObservingOptionNew context:nil];
}

Expand Down
3 changes: 3 additions & 0 deletions Bohr/BOSwitchTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@

@property (nonatomic, strong) UISwitch *toggleSwitch;

@property (nonatomic, strong) IBInspectable NSString *onFooterTitle;
@property (nonatomic, strong) IBInspectable NSString *offFooterTitle;

@end
8 changes: 7 additions & 1 deletion Bohr/BOSwitchTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ - (void)updateAppearance {
self.toggleSwitch.onTintColor = self.secondaryColor;
}

- (NSString *)footerTitle {
BOOL settingValue = [self.setting.value boolValue];

return settingValue ? self.onFooterTitle : self.offFooterTitle;
}

- (void)toggleSwitchValueDidChange {
self.setting.value = @(self.toggleSwitch.on);
}

- (void)settingValueDidChange {
[self.toggleSwitch setOn:[self.setting.value boolValue] animated:self.superview];
[self.toggleSwitch setOn:[self.setting.value boolValue] animated:[UIView areAnimationsEnabled]];
}

@end
6 changes: 5 additions & 1 deletion Bohr/BOTableViewCell+Subclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
#import "BOTableViewCell.h"

#import "BOTableViewController.h"
#import "BOSetting.h"

@interface BOTableViewCell ()

@property (nonatomic) CGFloat expansionHeight;
@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, strong) BOSetting *setting;

- (void)setup;
- (void)updateAppearance;
- (CGFloat)expansionHeight;
- (NSString *)footerTitle;
- (void)wasSelectedFromViewController:(BOTableViewController *)viewController;
- (void)settingValueDidChange;

Expand Down
16 changes: 6 additions & 10 deletions Bohr/BOTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@

#import <UIKit/UIKit.h>

#import "BOSetting.h"

@interface BOTableViewCell : UITableViewCell

@property (nonatomic, strong) BOSetting *setting;

@property (nonatomic, strong) UIColor *mainColor UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) UIFont *mainFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) IBInspectable NSString *key;

@property (nonatomic, strong) UIColor *secondaryColor UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) UIFont *secondaryFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) IBInspectable UIColor *mainColor;
@property (nonatomic, strong) UIFont *mainFont; // Apple pls rdar://19973159

@property (nonatomic, strong) UIColor *selectedColor UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) IBInspectable UIColor *secondaryColor;
@property (nonatomic, strong) UIFont *secondaryFont;

+ (instancetype)cellWithTitle:(NSString *)title setting:(BOSetting *)setting;
@property (nonatomic, strong) IBInspectable UIColor *selectedColor;

@end
Loading

0 comments on commit 6c2bc36

Please sign in to comment.