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

Commit 28b11c1

Browse files
committed
3.0.0-alpha.2 release
1 parent a30fc70 commit 28b11c1

14 files changed

+268
-164
lines changed

Bohr.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Bohr"
3-
s.version = "3.0.0-alpha.1"
3+
s.version = "3.0.0-alpha.2"
44
s.summary = "Settings screen composing framework"
55
s.homepage = "https://github.com/DavdRoman/Bohr"
66
s.author = { "David Román" => "[email protected]" }

Bohr.xcodeproj/project.pbxproj

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
75E19B451B2BC76100C03FF6 /* BOChoiceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 754E56A31B20D2FE00075B6E /* BOChoiceTableViewCell.m */; };
3535
75E19B461B2BCCFE00C03FF6 /* BOTextTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E02FE11B21F72C009698D3 /* BOTextTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
3636
75E19B471B2BCCFE00C03FF6 /* BOTextTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 75E02FE21B21F72C009698D3 /* BOTextTableViewCell.m */; };
37+
D594623C1B90E17D0028F4BD /* BODateTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = D594623A1B90E17D0028F4BD /* BODateTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
38+
D594623D1B90E17D0028F4BD /* BODateTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D594623B1B90E17D0028F4BD /* BODateTableViewCell.m */; };
39+
D59462401B90EA5F0028F4BD /* UILabel+DatePickerCustomization.h in Headers */ = {isa = PBXBuildFile; fileRef = D594623E1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.h */; };
40+
D59462411B90EA5F0028F4BD /* UILabel+DatePickerCustomization.m in Sources */ = {isa = PBXBuildFile; fileRef = D594623F1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.m */; };
3741
D5CF66461B8DFAC800FC5F13 /* BOTableViewSection.h in Headers */ = {isa = PBXBuildFile; fileRef = D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */; settings = {ATTRIBUTES = (Public, ); }; };
3842
D5CF66471B8DFAC800FC5F13 /* BOTableViewSection.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */; };
3943
D5CF664C1B8DFF4700FC5F13 /* MZAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -103,6 +107,10 @@
103107
75C7AE261B1AB42A0050C8AA /* BOTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTableViewCell.m; sourceTree = "<group>"; };
104108
75E02FE11B21F72C009698D3 /* BOTextTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOTextTableViewCell.h; sourceTree = "<group>"; };
105109
75E02FE21B21F72C009698D3 /* BOTextTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTextTableViewCell.m; sourceTree = "<group>"; };
110+
D594623A1B90E17D0028F4BD /* BODateTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BODateTableViewCell.h; sourceTree = "<group>"; };
111+
D594623B1B90E17D0028F4BD /* BODateTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BODateTableViewCell.m; sourceTree = "<group>"; };
112+
D594623E1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+DatePickerCustomization.h"; sourceTree = "<group>"; };
113+
D594623F1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+DatePickerCustomization.m"; sourceTree = "<group>"; };
106114
D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOTableViewSection.h; sourceTree = "<group>"; };
107115
D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTableViewSection.m; sourceTree = "<group>"; };
108116
D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZAppearance.h; sourceTree = "<group>"; };
@@ -191,6 +199,10 @@
191199
D5F1D8A81B3A1EF1004DA018 /* BOTableViewController+Private.h */,
192200
D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */,
193201
D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */,
202+
D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */,
203+
D5CF66491B8DFF4700FC5F13 /* MZAppearance.m */,
204+
D5CF664A1B8DFF4700FC5F13 /* NSInvocation+Copy.h */,
205+
D5CF664B1B8DFF4700FC5F13 /* NSInvocation+Copy.m */,
194206
75C7AE251B1AB42A0050C8AA /* BOTableViewCell.h */,
195207
75C7AE261B1AB42A0050C8AA /* BOTableViewCell.m */,
196208
D5D00B711B8FE63E00ADCAB2 /* BOTableViewCell+Private.h */,
@@ -199,6 +211,10 @@
199211
754E568C1B1FC16700075B6E /* BOSwitchTableViewCell.m */,
200212
75E02FE11B21F72C009698D3 /* BOTextTableViewCell.h */,
201213
75E02FE21B21F72C009698D3 /* BOTextTableViewCell.m */,
214+
D594623A1B90E17D0028F4BD /* BODateTableViewCell.h */,
215+
D594623B1B90E17D0028F4BD /* BODateTableViewCell.m */,
216+
D594623E1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.h */,
217+
D594623F1B90EA5F0028F4BD /* UILabel+DatePickerCustomization.m */,
202218
754E56931B2083DE00075B6E /* BOTimeTableViewCell.h */,
203219
754E56941B2083DE00075B6E /* BOTimeTableViewCell.m */,
204220
754E56A21B20D2FE00075B6E /* BOChoiceTableViewCell.h */,
@@ -210,10 +226,6 @@
210226
754E56871B1DFDB400075B6E /* BOSetting.h */,
211227
754E56881B1DFDB400075B6E /* BOSetting.m */,
212228
D5F1D8AA1B3A210E004DA018 /* BOSetting+Private.h */,
213-
D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */,
214-
D5CF66491B8DFF4700FC5F13 /* MZAppearance.m */,
215-
D5CF664A1B8DFF4700FC5F13 /* NSInvocation+Copy.h */,
216-
D5CF664B1B8DFF4700FC5F13 /* NSInvocation+Copy.m */,
217229
75C7AE011B1AB3280050C8AA /* Supporting Files */,
218230
);
219231
path = Bohr;
@@ -235,6 +247,7 @@
235247
buildActionMask = 2147483647;
236248
files = (
237249
D5F1D8AB1B3A210E004DA018 /* BOSetting+Private.h in Headers */,
250+
D59462401B90EA5F0028F4BD /* UILabel+DatePickerCustomization.h in Headers */,
238251
754E56501B1B461700075B6E /* BOTableViewCell+Subclass.h in Headers */,
239252
75E19B461B2BCCFE00C03FF6 /* BOTextTableViewCell.h in Headers */,
240253
75C7AE041B1AB3280050C8AA /* Bohr.h in Headers */,
@@ -251,6 +264,7 @@
251264
759E1B001B2BC31700AD8F38 /* BOTimeTableViewCell.h in Headers */,
252265
75B6CE1E1B375DCA00DADCBD /* BOButtonTableViewCell.h in Headers */,
253266
D5F1D8A91B3A1EF1004DA018 /* BOTableViewController+Private.h in Headers */,
267+
D594623C1B90E17D0028F4BD /* BODateTableViewCell.h in Headers */,
254268
);
255269
runOnlyForDeploymentPostprocessing = 0;
256270
};
@@ -373,7 +387,9 @@
373387
75B6CE1F1B375DCA00DADCBD /* BOButtonTableViewCell.m in Sources */,
374388
D5CF66471B8DFAC800FC5F13 /* BOTableViewSection.m in Sources */,
375389
754E568E1B1FC16700075B6E /* BOSwitchTableViewCell.m in Sources */,
390+
D594623D1B90E17D0028F4BD /* BODateTableViewCell.m in Sources */,
376391
759E1B011B2BC31700AD8F38 /* BOTimeTableViewCell.m in Sources */,
392+
D59462411B90EA5F0028F4BD /* UILabel+DatePickerCustomization.m in Sources */,
377393
D5CF664D1B8DFF4700FC5F13 /* MZAppearance.m in Sources */,
378394
75B6CE1D1B3756D800DADCBD /* BOOptionTableViewCell.m in Sources */,
379395
75E19B471B2BCCFE00C03FF6 /* BOTextTableViewCell.m in Sources */,

Bohr/BODateTableViewCell.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// BODateTableViewCell.h
3+
// Bohr
4+
//
5+
// Created by David Román Aguirre on 28/08/15.
6+
//
7+
//
8+
9+
#import "BOTableViewCell.h"
10+
11+
@interface BODateTableViewCell : BOTableViewCell
12+
13+
@property (nonatomic, assign) NSString *dateFormat;
14+
@property (nonatomic) UIDatePicker *datePicker;
15+
16+
@end

Bohr/BODateTableViewCell.m

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// BODateTableViewCell.m
3+
// Bohr
4+
//
5+
// Created by David Román Aguirre on 28/08/15.
6+
//
7+
//
8+
9+
#import "BODateTableViewCell.h"
10+
11+
#import "BOTableViewCell+Subclass.h"
12+
#import "UILabel+DatePickerCustomization.h"
13+
14+
@interface BODateTableViewCell ()
15+
16+
@property (nonatomic) NSDateFormatter *dateFormatter;
17+
18+
@end
19+
20+
@implementation BODateTableViewCell
21+
22+
- (void)setup {
23+
self.datePicker = [UIDatePicker new];
24+
self.datePicker.backgroundColor = [UIColor clearColor];
25+
self.datePicker.datePickerMode = UIDatePickerModeDate;
26+
[self.datePicker addTarget:self action:@selector(datePickerValueDidChange) forControlEvents:UIControlEventValueChanged];
27+
self.expansionView = self.datePicker;
28+
29+
self.dateFormatter = [NSDateFormatter new];
30+
self.dateFormatter.dateFormat = [self defaultDateFormat];
31+
}
32+
33+
- (CGFloat)expansionHeight {
34+
// Uncomment if the picker view doesn't show on iOS 9.
35+
// return 216;
36+
return [super expansionHeight];
37+
}
38+
39+
- (void)setDateFormat:(NSString *)dateFormat {
40+
dateFormat = self.dateFormat.length == 0 ? [self defaultDateFormat] : dateFormat;
41+
self.dateFormatter.dateFormat = dateFormat;
42+
}
43+
44+
- (NSString *)dateFormat {
45+
return self.dateFormatter.dateFormat;
46+
}
47+
48+
- (NSString *)defaultDateFormat {
49+
return [NSDateFormatter dateFormatFromTemplate:@"dd/MM/YYYY" options:kNilOptions locale:[NSLocale currentLocale]];
50+
}
51+
52+
- (void)settingValueDidChange {
53+
self.detailTextLabel.text = [self.dateFormatter stringFromDate:self.setting.value];
54+
self.datePicker.date = self.setting.value;
55+
}
56+
57+
- (void)datePickerValueDidChange {
58+
self.setting.value = self.datePicker.date;
59+
}
60+
61+
@end

Bohr/BOTableViewCell+Subclass.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
/// The setting object which the cell represents.
2020
@property (nonatomic) BOSetting *setting;
2121

22+
/// An optional view shown when the cell is pressed.
23+
@property (nonatomic) UIView *expansionView;
24+
2225
/// The setup method for the cell, where you may set up all the views and constraints necessary for the cell to work.
2326
- (void)setup;
2427

2528
/// The method in charge of updating the appearance of the main cell view components, through properties as mainColor, mainFont, secondaryColor, secondaryFont.
2629
- (void)updateAppearance;
2730

28-
/// You may return the height for the cell to be expanded when tapped.
31+
/// The optional height for the cell to be expanded when pressed.
2932
- (CGFloat)expansionHeight;
3033

3134
/// You may return the footer text for the cell to be set on its section.

Bohr/BOTableViewCell.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ - (instancetype)initWithTitle:(NSString *)title key:(NSString *)key handler:(voi
3131
return self;
3232
}
3333

34+
- (void)didMoveToSuperview {
35+
if (self.superview && self.expansionView) {
36+
[self.contentView addSubview:self.expansionView];
37+
38+
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeTopMargin multiplier:1 constant:0];
39+
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
40+
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeRight multiplier:1 constant:0];
41+
NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:[self expansionHeight]];
42+
43+
self.expansionView.translatesAutoresizingMaskIntoConstraints = NO;
44+
[self.expansionView.superview addConstraints:@[topConstraint, leftConstraint, rightConstraint, heightConstraint]];
45+
}
46+
}
47+
3448
- (void)setDestinationViewController:(UIViewController *)destinationViewController {
3549
if (_destinationViewController != destinationViewController) {
3650
_destinationViewController = destinationViewController;
@@ -45,7 +59,7 @@ + (instancetype)cellWithTitle:(NSString *)title key:(NSString *)key handler:(voi
4559
- (void)layoutSubviews {
4660
[super layoutSubviews];
4761

48-
if (self.expansionHeight > 0) {
62+
if ([self expansionView]) {
4963
CGFloat yOffset = (self.layoutMargins.top-self.frame.size.height)/2;
5064

5165
self.textLabel.center = CGPointMake(self.textLabel.center.x, self.textLabel.center.y+yOffset);
@@ -73,7 +87,7 @@ - (void)_updateAppearance {
7387
- (void)setup {}
7488
- (void)setupConstraints {}
7589
- (void)updateAppearance {}
76-
- (CGFloat)expansionHeight {return 0;}
90+
- (CGFloat)expansionHeight {return self.expansionView.intrinsicContentSize.height;}
7791
- (NSString *)footerTitle {return nil;}
7892
- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {}
7993
- (void)settingValueDidChange {}

Bohr/BOTableViewController.m

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,37 @@ @interface BOTableViewController ()
2222

2323
@implementation BOTableViewController
2424

25-
- (instancetype)init {
26-
return [self initWithStyle:UITableViewStyleGrouped];
25+
- (void)commonInit {
26+
self.sections = [NSArray new];
27+
28+
self.tableView.estimatedRowHeight = 55;
29+
self.tableView.rowHeight = UITableViewAutomaticDimension;
30+
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
31+
self.tableView.tableFooterView = [UIView new];
32+
33+
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.tableView action:@selector(endEditing:)];
34+
tapGestureRecognizer.cancelsTouchesInView = NO;
35+
[self.tableView addGestureRecognizer:tapGestureRecognizer];
36+
37+
[self setup];
2738
}
2839

2940
- (instancetype)initWithStyle:(UITableViewStyle)style {
3041
if (self = [super initWithStyle:style]) {
31-
self.sections = [NSArray new];
32-
33-
self.tableView.estimatedRowHeight = 55;
34-
self.tableView.rowHeight = UITableViewAutomaticDimension;
35-
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
36-
self.tableView.tableFooterView = [UIView new];
37-
38-
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.tableView action:@selector(endEditing:)];
39-
tapGestureRecognizer.cancelsTouchesInView = NO;
40-
[self.tableView addGestureRecognizer:tapGestureRecognizer];
41-
42-
[self setup];
42+
[self commonInit];
4343
}
4444

4545
return self;
4646
}
4747

48+
- (instancetype)init {
49+
return [self initWithStyle:UITableViewStyleGrouped];
50+
}
51+
52+
- (void)awakeFromNib {
53+
[self commonInit];
54+
}
55+
4856
- (void)addSection:(BOTableViewSection *)section {
4957
self.sections = [self.sections arrayByAddingObject:section];
5058
}
@@ -92,7 +100,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
92100
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
93101
BOTableViewSection *section = self.sections[indexPath.section];
94102
BOTableViewCell *cell = section.cells[indexPath.row];
95-
CGFloat cellHeight = [cell systemLayoutSizeFittingSize:CGSizeMake(cell.contentView.frame.size.width, 0)].height;
103+
CGFloat cellHeight = [cell systemLayoutSizeFittingSize:CGSizeMake(cell.contentView.frame.size.width, UITableViewAutomaticDimension)].height;
96104

97105
if (cellHeight < self.tableView.estimatedRowHeight) {
98106
cellHeight = self.tableView.estimatedRowHeight;
@@ -113,6 +121,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
113121
BOTableViewSection *section = self.sections[indexPath.section];
114122
BOTableViewCell *cell = section.cells[indexPath.row];
115123
cell.indexPath = indexPath;
124+
[cell prepareForReuse];
116125

117126
if (cell.setting && !cell.setting.valueDidChangeBlock) {
118127
[UIView performWithoutAnimation:^{
@@ -143,7 +152,7 @@ - (void)tableView:(UITableView *)tableView willDisplayCell:(BOTableViewCell *)ce
143152
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
144153
BOTableViewCell *cell = (BOTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
145154

146-
if (cell.expansionHeight > 0) {
155+
if ([cell expansionHeight] > 0) {
147156
self.expansionIndexPath = ![indexPath isEqual:self.expansionIndexPath] ? indexPath : nil;
148157

149158
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];

Bohr/BOTimeTableViewCell.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
// Copyright (c) 2015 David Roman. All rights reserved.
77
//
88

9-
#import "BOTableViewCell.h"
9+
#import "BODateTableViewCell.h"
1010

11-
@interface BOTimeTableViewCell : BOTableViewCell <UIPickerViewDataSource, UIPickerViewDelegate>
12-
13-
/// The minute interval showed on the time picker view.
14-
@property (nonatomic) NSInteger minuteInterval;
11+
@interface BOTimeTableViewCell : BODateTableViewCell
1512

1613
@end

0 commit comments

Comments
 (0)