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

Commit eb49174

Browse files
committed
3.0.0-alpha.5
1 parent c33c1d6 commit eb49174

File tree

5 files changed

+39
-25
lines changed

5 files changed

+39
-25
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.4"
3+
s.version = "3.0.0-alpha.5"
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
D5D00B721B8FE63E00ADCAB2 /* BOTableViewCell+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5D00B711B8FE63E00ADCAB2 /* BOTableViewCell+Private.h */; };
5050
D5D499F21B9749AB0015C617 /* BOTextTableViewCell+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = D5D499F01B9749AB0015C617 /* BOTextTableViewCell+Subclass.h */; settings = {ATTRIBUTES = (Private, ); }; };
5151
D5EBE5F11B963C250096AD4C /* BONumberTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = D5EBE5EF1B963C250096AD4C /* BONumberTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
52-
D5EBE5F21B963C250096AD4C /* BONumberTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D5EBE5F01B963C250096AD4C /* BONumberTableViewCell.m */; settings = {ASSET_TAGS = (); }; };
52+
D5EBE5F21B963C250096AD4C /* BONumberTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D5EBE5F01B963C250096AD4C /* BONumberTableViewCell.m */; };
5353
D5F1D8A91B3A1EF1004DA018 /* BOTableViewController+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5F1D8A81B3A1EF1004DA018 /* BOTableViewController+Private.h */; };
5454
D5F1D8AB1B3A210E004DA018 /* BOSetting+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5F1D8AA1B3A210E004DA018 /* BOSetting+Private.h */; };
5555
/* End PBXBuildFile section */

Bohr/BOTableViewCell+Private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
@interface BOTableViewCell ()
1212

13+
@property (nonatomic) CGFloat height;
14+
1315
- (void)_updateAppearance;
1416

1517
@end

Bohr/BOTableViewCell.m

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#import "BOSetting+Private.h"
1313
#import "BOTableViewController+Private.h"
1414

15+
@interface BOTableViewCell ()
16+
17+
@property (nonatomic) NSLayoutConstraint *expansionViewTopConstraint;
18+
19+
@end
20+
1521
@implementation BOTableViewCell
1622

1723
- (instancetype)initWithTitle:(NSString *)title key:(NSString *)key handler:(void (^)(id cell))handler {
@@ -32,17 +38,26 @@ - (instancetype)initWithTitle:(NSString *)title key:(NSString *)key handler:(voi
3238
return self;
3339
}
3440

35-
- (void)didMoveToSuperview {
36-
if (self.expansionView && !self.expansionView.superview) {
37-
[self addSubview:self.expansionView];
41+
- (void)setExpansionView:(UIView *)expansionView {
42+
if (self.expansionView != expansionView) {
43+
[self.expansionView removeFromSuperview];
44+
_expansionView = expansionView;
45+
[self.contentView addSubview:self.expansionView];
3846

39-
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeTopMargin multiplier:1 constant:0];
47+
self.expansionViewTopConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeTop multiplier:1 constant:0];
4048
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
4149
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.expansionView.superview attribute:NSLayoutAttributeRight multiplier:1 constant:0];
4250
NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self.expansionView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:[self expansionHeight]];
4351

4452
self.expansionView.translatesAutoresizingMaskIntoConstraints = NO;
45-
[self.expansionView.superview addConstraints:@[topConstraint, leftConstraint, rightConstraint, heightConstraint]];
53+
[self.expansionView.superview addConstraints:@[self.expansionViewTopConstraint, leftConstraint, rightConstraint, heightConstraint]];
54+
}
55+
}
56+
57+
- (void)setHeight:(CGFloat)height {
58+
if (_height != height) {
59+
_height = height;
60+
self.expansionViewTopConstraint.constant = height;
4661
}
4762
}
4863

@@ -61,7 +76,7 @@ - (void)layoutSubviews {
6176
[super layoutSubviews];
6277

6378
if ([self expansionHeight] > 0) {
64-
CGFloat yOffset = (self.layoutMargins.top-self.frame.size.height)/2;
79+
CGFloat yOffset = (self.height-self.frame.size.height)/2;
6580

6681
self.textLabel.center = CGPointMake(self.textLabel.center.x, self.textLabel.center.y+yOffset);
6782
self.detailTextLabel.center = CGPointMake(self.detailTextLabel.center.x, self.detailTextLabel.center.y+yOffset);

Bohr/BOTableViewController.m

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
100100
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
101101
BOTableViewSection *section = self.sections[indexPath.section];
102102
BOTableViewCell *cell = section.cells[indexPath.row];
103-
CGFloat cellHeight = MAX(self.tableView.estimatedRowHeight, [self heightForCell:cell]);
104103

105-
cell.layoutMargins = UIEdgeInsetsMake(cellHeight, cell.layoutMargins.left, cell.layoutMargins.bottom, cell.layoutMargins.right);
104+
CGFloat cellHeight = MAX(self.tableView.estimatedRowHeight, [self heightForCell:cell]);
105+
cell.height = cellHeight;
106106

107107
if ([self.expansionIndexPath isEqual:indexPath]) {
108108
cellHeight += [cell expansionHeight];
@@ -114,15 +114,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
114114
- (CGFloat)heightForCell:(UITableViewCell *)cell {
115115

116116
UITableViewCell *cleanCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
117-
cleanCell.layoutMargins = cell.layoutMargins;
118-
cleanCell.frame = cell.frame;
117+
cleanCell.frame = CGRectMake(0, 0, cell.frame.size.width, 0);
119118
cleanCell.textLabel.numberOfLines = 0;
120119
cleanCell.textLabel.text = cell.textLabel.text;
121-
cleanCell.detailTextLabel.text = cell.detailTextLabel.text;
122120
cleanCell.accessoryView = cell.accessoryView;
123121
cleanCell.accessoryType = cell.accessoryType;
124122

125-
CGFloat height = [cleanCell systemLayoutSizeFittingSize:CGSizeMake(cleanCell.frame.size.width, UITableViewAutomaticDimension)].height;
123+
CGFloat height = [cleanCell systemLayoutSizeFittingSize:cleanCell.frame.size].height;
126124

127125
return height;
128126
}
@@ -133,13 +131,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
133131
cell.indexPath = indexPath;
134132

135133
if (cell.setting && !cell.setting.valueDidChangeBlock) {
136-
[UIView performWithoutAnimation:^{
137-
__unsafe_unretained typeof(self) weakSelf = self;
138-
__unsafe_unretained typeof(cell) weakCell = cell;
139-
cell.setting.valueDidChangeBlock = ^{
134+
__unsafe_unretained typeof(self) weakSelf = self;
135+
__unsafe_unretained typeof(cell) weakCell = cell;
136+
cell.setting.valueDidChangeBlock = ^{
137+
dispatch_async(dispatch_get_main_queue(), ^{
140138
[weakCell settingValueDidChange];
141139
[weakSelf reloadTableView];
142-
};
140+
});
141+
};
142+
143+
[UIView performWithoutAnimation:^{
144+
[cell settingValueDidChange];
143145
}];
144146
}
145147

@@ -199,6 +201,7 @@ - (NSArray *)footerViews {
199201
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
200202
UITableViewHeaderFooterView *footerView = self.footerViews[section];
201203
footerView.textLabel.text = [self tableView:tableView titleForFooterInSection:section];
204+
// Super hacky code for iOS 9 support.
202205
footerView.textLabel.numberOfLines = 0;
203206
CGPoint previousOrigin = footerView.textLabel.frame.origin;
204207
[footerView sizeToFit];
@@ -241,12 +244,6 @@ - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UITableViewHea
241244
if (section.footerTitleFont) footerView.textLabel.font = section.footerTitleFont;
242245
}
243246

244-
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
245-
[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
246-
[self.tableView reloadData];
247-
}];
248-
}
249-
250247
#pragma mark Subclassing
251248

252249
- (void)setup {}

0 commit comments

Comments
 (0)