Skip to content

Commit

Permalink
v2.3.0 #180
Browse files Browse the repository at this point in the history
  • Loading branch information
iRoachie committed Jul 22, 2018
2 parents 8f18477 + 63561cc commit 7407729
Show file tree
Hide file tree
Showing 13 changed files with 1,357 additions and 5,421 deletions.
1 change: 1 addition & 0 deletions .prettierignore
@@ -0,0 +1 @@
package.json
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -346,6 +346,8 @@ The following style props are supported:
* `contentInset`
* `contentOffset`
* `scrollIndicatorInsets`
* `cellLayoutMargins`
* `cellSeparatorInset`

Colors:

Expand Down
15 changes: 8 additions & 7 deletions RNTableView.podspec
@@ -1,14 +1,15 @@
Pod::Spec.new do |s|
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
s.name = "RNTableView"
s.version = "2.2.0"
s.version = package["version"]
s.authors = "Pavel Aksonov"
s.summary = "Native iOS UITableView for React Native with JSON support and more"
s.license = "BSD 2-Clause"
s.homepage = "https://github.com/aksonov/react-native-tableview"
s.summary = package["description"]
s.license = package["license"]
s.homepage = package["homepage"]
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/aksonov/react-native-tableview.git",
:tag => "2.2.0" }
s.source = { :git => package["repository"]["url"] }
s.source_files = 'RNTableView/*.{h,m}'
s.preserve_paths = "**/*.js"
s.dependency 'React'
Expand Down
5 changes: 4 additions & 1 deletion RNTableView/RNTableView.h
Expand Up @@ -36,13 +36,16 @@
@property(nonatomic) float headerHeight;
@property(nonatomic) BOOL customCells;
@property(nonatomic) BOOL editing;
@property(nonatomic) BOOL emptyInsets;
@property(nonatomic) BOOL moveWithinSectionOnly;
@property(nonatomic, assign) UIEdgeInsets contentInset;
@property(nonatomic, assign) CGPoint contentOffset;
@property(nonatomic, assign) UIEdgeInsets scrollIndicatorInsets;
@property(nonatomic, assign) BOOL showsHorizontalScrollIndicator;
@property(nonatomic, assign) BOOL showsVerticalScrollIndicator;
@property(nonatomic, assign) UIEdgeInsets cellSeparatorInset;
@property(nonatomic, assign) BOOL hasCellSeparatorInset;
@property(nonatomic, assign) UIEdgeInsets cellLayoutMargins;
@property(nonatomic, assign) BOOL hasCellLayoutMargins;
@property(nonatomic, assign) BOOL canRefresh;
@property(nonatomic, assign) BOOL refreshing;

Expand Down
35 changes: 16 additions & 19 deletions RNTableView/RNTableView.m
Expand Up @@ -53,6 +53,12 @@ - (void)setScrollEnabled:(BOOL)scrollEnabled {
[self.tableView setScrollEnabled:scrollEnabled];
}

- (void)setAlwaysBounceVertical:(BOOL)alwaysBounceVertical {
_alwaysBounceVertical = alwaysBounceVertical;

[self.tableView setAlwaysBounceVertical:alwaysBounceVertical];
}

-(void)setSectionIndexTitlesEnabled:(BOOL)sectionIndexTitlesEnabled
{
_sectionIndexTitlesEnabled = sectionIndexTitlesEnabled;
Expand Down Expand Up @@ -222,6 +228,7 @@ - (void)createTableView {
[_tableView registerClass:[RNReactModuleCell class] forCellReuseIdentifier:_reactModuleCellReuseIndentifier];
[self addSubview:_tableView];
}

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(nonnull UIView *)view forSection:(NSInteger)section {
UITableViewHeaderFooterView *footer = (UITableViewHeaderFooterView *)view;

Expand Down Expand Up @@ -263,10 +270,10 @@ -(void)scrollToIndex: (NSInteger)index section:(NSInteger)section animated:(BOOL
}
}


-(void)setHeaderHeight:(float)headerHeight {
_headerHeight = headerHeight;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (_sections[section][@"headerHeight"]){
return [_sections[section][@"headerHeight"] floatValue] ? [_sections[section][@"headerHeight"] floatValue] : 0.000001;
Expand Down Expand Up @@ -303,21 +310,12 @@ - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.emptyInsets){
// Remove separator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}

// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}

// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if (self.hasCellLayoutMargins && [cell respondsToSelector:@selector(setLayoutMargins:)] && [cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
[cell setLayoutMargins:self.cellLayoutMargins];
}
if (self.hasCellSeparatorInset && [cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:self.cellSeparatorInset];
}
if (self.font){
cell.detailTextLabel.font = self.font;
Expand Down Expand Up @@ -384,7 +382,6 @@ - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell
self.onEndDisplayingCell(@{@"target":self.reactTag, @"row":@(indexPath.row), @"section": @(indexPath.section)});
}


- (void)setSections:(NSArray *)sections
{
_sections = [NSMutableArray arrayWithCapacity:[sections count]];
Expand Down Expand Up @@ -491,8 +488,8 @@ -(UITableViewCell* )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
if ([item[@"transparent"] intValue]) {
cell.backgroundColor = [UIColor clearColor];
}
if (item[@"selectionStyle"]) {
cell.selectionStyle = [item[@"selectionStyle"] intValue];
if (item[@"selectionStyle"] != nil) {
cell.selectionStyle = [RCTConvert int:item[@"selectionStyle"]];
}
return cell;
}
Expand Down
11 changes: 10 additions & 1 deletion RNTableView/RNTableViewManager.m
Expand Up @@ -41,7 +41,6 @@ - (NSArray *)customDirectEventTypes
RCT_EXPORT_VIEW_PROPERTY(editing, BOOL)
RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
RCT_EXPORT_VIEW_PROPERTY(autoFocusAnimate, BOOL)
RCT_EXPORT_VIEW_PROPERTY(emptyInsets, BOOL)
RCT_EXPORT_VIEW_PROPERTY(filter, NSString)
RCT_EXPORT_VIEW_PROPERTY(selectedValue, id)
RCT_EXPORT_VIEW_PROPERTY(filterArgs, NSArray)
Expand Down Expand Up @@ -133,6 +132,16 @@ - (NSArray *)customDirectEventTypes
[view setShowsVerticalScrollIndicator:[RCTConvert BOOL:json]];
}

RCT_CUSTOM_VIEW_PROPERTY(cellSeparatorInset, UIEdgeInsets, RNTableView) {
view.hasCellSeparatorInset = YES;
view.cellSeparatorInset = [RCTConvert UIEdgeInsets:json];
}

RCT_CUSTOM_VIEW_PROPERTY(cellLayoutMargins, UIEdgeInsets, RNTableView) {
view.hasCellLayoutMargins = YES;
view.cellLayoutMargins = [RCTConvert UIEdgeInsets:json];
}

- (NSDictionary *)constantsToExport {
return @{
@"Constants": @{
Expand Down
2 changes: 2 additions & 0 deletions example/.gitignore
Expand Up @@ -51,3 +51,5 @@ buck-out/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

yarn.lock
5 changes: 2 additions & 3 deletions example/package.json
Expand Up @@ -4,14 +4,13 @@
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"postinstall": "rm -rf node_modules/react-native-tableview/node_modules node_modules/react-native-tableview/example"
"test": "jest"
},
"dependencies": {
"prop-types": "^15.6.0",
"react": "16.0.0",
"react-native": "0.50.4",
"react-native-tableview": "file:..",
"react-native-tableview": "latest",
"react-navigation": "^2.0.4"
},
"devDependencies": {
Expand Down

0 comments on commit 7407729

Please sign in to comment.