Skip to content

Commit

Permalink
Merge pull request #47 from nulrich/#46
Browse files Browse the repository at this point in the history
Fix #46 Use RCTFont instead of RCTConvert
  • Loading branch information
Nicolas Ulrich authored Oct 1, 2016
2 parents d502b3a + b3894d0 commit c007b33
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 72 deletions.
13 changes: 2 additions & 11 deletions RCTAutoComplete.ios.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var React = require('react');
var PropTypes = React.PropTypes;

import {requireNativeComponent} from 'react-native';
var { requireNativeComponent } = require('react-native');

var NativeAutoComplete = requireNativeComponent('RCTAutoComplete', null);

Expand Down Expand Up @@ -101,16 +100,8 @@ autoCapitalize: PropTypes.oneOf([
* @platorm android
*/
textAlign: PropTypes.oneOf([
// Cross-platform
'center',
// ios only
'auto',
'center',
'justify',
'left',
'right',
// android only
'start',
'center',
'end',
]),

Expand Down
11 changes: 6 additions & 5 deletions RCTAutoComplete.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "RCTEventDispatcher.h"
#import "UIView+React.h"
#import "AutoCompleteView.h"
#import "RCTFont.h"

@implementation RCTAutoComplete

Expand Down Expand Up @@ -47,21 +48,21 @@ @implementation RCTAutoComplete
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
RCT_REMAP_VIEW_PROPERTY(textAlign, textAlignment, NSTextAlignment)
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, AutoCompleteView)
RCT_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, AutoCompleteView)
{
view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
}
RCT_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, __unused AutoCompleteView)
{
view.font = [RCTConvert UIFont:view.font withWeight:json]; // defaults to normal
view.font = [RCTFont updateFont:view.font withWeight:json]; // defaults to normal
}
RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, __unused AutoCompleteView)
{
view.font = [RCTConvert UIFont:view.font withStyle:json]; // defaults to normal
view.font = [RCTFont updateFont:view.font withStyle:json]; // defaults to normal
}
RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, AutoCompleteView)
{
view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName];
view.font = [RCTFont updateFont:view.font withFamily:json ?: defaultView.font.familyName];
}
RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)

Expand Down
66 changes: 33 additions & 33 deletions RCTAutoComplete.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

/* Begin PBXBuildFile section */
13BE3DEE1AC21097009241FE /* RCTAutoComplete.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* RCTAutoComplete.m */; };
371961E31B50741900F79BB7 /* AutoCompleteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 371961E21B50741900F79BB7 /* AutoCompleteView.m */; };
371961EE1B50755300F79BB7 /* MLPAutoCompleteTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 371961E81B50754700F79BB7 /* MLPAutoCompleteTextField.m */; };
371961EF1B50755300F79BB7 /* NSString+Levenshtein.m in Sources */ = {isa = PBXBuildFile; fileRef = 371961ED1B50754700F79BB7 /* NSString+Levenshtein.m */; };
3798A8D81D9B09D500348235 /* AutoCompleteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3798A8D61D9B09D500348235 /* AutoCompleteView.m */; };
3798A8F51D9B0B0900348235 /* MLPAutoCompleteTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 3798A8EF1D9B0B0900348235 /* MLPAutoCompleteTextField.m */; };
3798A8F61D9B0B0900348235 /* NSString+Levenshtein.m in Sources */ = {isa = PBXBuildFile; fileRef = 3798A8F41D9B0B0900348235 /* NSString+Levenshtein.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -27,17 +27,17 @@

/* Begin PBXFileReference section */
134814201AA4EA6300B7C361 /* libRCTAutoComplete.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAutoComplete.a; sourceTree = BUILT_PRODUCTS_DIR; };
13BE3DEC1AC21097009241FE /* RCTAutoComplete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAutoComplete.h; sourceTree = "<group>"; };
13BE3DED1AC21097009241FE /* RCTAutoComplete.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAutoComplete.m; sourceTree = "<group>"; };
371961E11B50741900F79BB7 /* AutoCompleteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoCompleteView.h; sourceTree = "<group>"; };
371961E21B50741900F79BB7 /* AutoCompleteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoCompleteView.m; sourceTree = "<group>"; };
371961E41B50745B00F79BB7 /* RCTAutoComplete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAutoComplete.h; sourceTree = "<group>"; };
371961E71B50754700F79BB7 /* MLPAutoCompleteTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextField.h; sourceTree = "<group>"; };
371961E81B50754700F79BB7 /* MLPAutoCompleteTextField.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MLPAutoCompleteTextField.m; sourceTree = "<group>"; };
371961E91B50754700F79BB7 /* MLPAutoCompleteTextFieldDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextFieldDataSource.h; sourceTree = "<group>"; };
371961EA1B50754700F79BB7 /* MLPAutoCompleteTextFieldDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextFieldDelegate.h; sourceTree = "<group>"; };
371961EB1B50754700F79BB7 /* MLPAutoCompletionObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompletionObject.h; sourceTree = "<group>"; };
371961EC1B50754700F79BB7 /* NSString+Levenshtein.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+Levenshtein.h"; sourceTree = "<group>"; };
371961ED1B50754700F79BB7 /* NSString+Levenshtein.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+Levenshtein.m"; sourceTree = "<group>"; };
3798A8D51D9B09D500348235 /* AutoCompleteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoCompleteView.h; sourceTree = "<group>"; };
3798A8D61D9B09D500348235 /* AutoCompleteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoCompleteView.m; sourceTree = "<group>"; };
3798A8EE1D9B0B0900348235 /* MLPAutoCompleteTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextField.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextField.h; sourceTree = "<group>"; };
3798A8EF1D9B0B0900348235 /* MLPAutoCompleteTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MLPAutoCompleteTextField.m; path = MLPAutoCompleteTextField/MLPAutoCompleteTextField.m; sourceTree = "<group>"; };
3798A8F01D9B0B0900348235 /* MLPAutoCompleteTextFieldDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextFieldDataSource.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDataSource.h; sourceTree = "<group>"; };
3798A8F11D9B0B0900348235 /* MLPAutoCompleteTextFieldDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextFieldDelegate.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDelegate.h; sourceTree = "<group>"; };
3798A8F21D9B0B0900348235 /* MLPAutoCompletionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompletionObject.h; path = MLPAutoCompleteTextField/MLPAutoCompletionObject.h; sourceTree = "<group>"; };
3798A8F31D9B0B0900348235 /* NSString+Levenshtein.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+Levenshtein.h"; path = "MLPAutoCompleteTextField/NSString+Levenshtein.h"; sourceTree = "<group>"; };
3798A8F41D9B0B0900348235 /* NSString+Levenshtein.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+Levenshtein.m"; path = "MLPAutoCompleteTextField/NSString+Levenshtein.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -59,28 +59,28 @@
name = Products;
sourceTree = "<group>";
};
371961E61B50754700F79BB7 /* MLPAutoCompleteTextField */ = {
3798A8E41D9B0ACB00348235 /* MLPAutoCompleteTextField */ = {
isa = PBXGroup;
children = (
371961E71B50754700F79BB7 /* MLPAutoCompleteTextField.h */,
371961E81B50754700F79BB7 /* MLPAutoCompleteTextField.m */,
371961EA1B50754700F79BB7 /* MLPAutoCompleteTextFieldDelegate.h */,
371961E91B50754700F79BB7 /* MLPAutoCompleteTextFieldDataSource.h */,
371961EB1B50754700F79BB7 /* MLPAutoCompletionObject.h */,
371961EC1B50754700F79BB7 /* NSString+Levenshtein.h */,
371961ED1B50754700F79BB7 /* NSString+Levenshtein.m */,
3798A8EE1D9B0B0900348235 /* MLPAutoCompleteTextField.h */,
3798A8EF1D9B0B0900348235 /* MLPAutoCompleteTextField.m */,
3798A8F01D9B0B0900348235 /* MLPAutoCompleteTextFieldDataSource.h */,
3798A8F11D9B0B0900348235 /* MLPAutoCompleteTextFieldDelegate.h */,
3798A8F21D9B0B0900348235 /* MLPAutoCompletionObject.h */,
3798A8F31D9B0B0900348235 /* NSString+Levenshtein.h */,
3798A8F41D9B0B0900348235 /* NSString+Levenshtein.m */,
);
path = MLPAutoCompleteTextField;
name = MLPAutoCompleteTextField;
sourceTree = "<group>";
};
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
371961E61B50754700F79BB7 /* MLPAutoCompleteTextField */,
371961E11B50741900F79BB7 /* AutoCompleteView.h */,
371961E21B50741900F79BB7 /* AutoCompleteView.m */,
3798A8E41D9B0ACB00348235 /* MLPAutoCompleteTextField */,
3798A8D51D9B09D500348235 /* AutoCompleteView.h */,
3798A8D61D9B09D500348235 /* AutoCompleteView.m */,
13BE3DEC1AC21097009241FE /* RCTAutoComplete.h */,
13BE3DED1AC21097009241FE /* RCTAutoComplete.m */,
371961E41B50745B00F79BB7 /* RCTAutoComplete.h */,
134814211AA4EA7D00B7C361 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -141,9 +141,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
371961EE1B50755300F79BB7 /* MLPAutoCompleteTextField.m in Sources */,
371961EF1B50755300F79BB7 /* NSString+Levenshtein.m in Sources */,
371961E31B50741900F79BB7 /* AutoCompleteView.m in Sources */,
3798A8F51D9B0B0900348235 /* MLPAutoCompleteTextField.m in Sources */,
3798A8F61D9B0B0900348235 /* NSString+Levenshtein.m in Sources */,
3798A8D81D9B09D500348235 /* AutoCompleteView.m in Sources */,
13BE3DEE1AC21097009241FE /* RCTAutoComplete.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -184,7 +184,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -218,7 +218,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -231,7 +231,7 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/../../node_modules/react-native/React/**",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
Expand All @@ -247,7 +247,7 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../node_modules/react-native/React/**",
"$(SRCROOT)/../../React/**",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
Expand Down
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,47 @@
For example download [Country list](https://gist.githubusercontent.com/Keeguon/2310008/raw/865a58f59b9db2157413e7d3d949914dbf5a237d/countries.json)

```js

'use strict';

var AutoComplete = require('react-native-autocomplete');
var Countries = require('./countries.json');

import React, { Component } from 'react';
import {
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
TextInput,
View,
AlertIOS
} from 'react-native';
} = React;

var RCTAutoCompleteApp = React.createClass({

class RCTAutoCompleteApp extends Component {
getInitialState: function() {
return {data: []};
},

constructor(props) {
super(props);
this.state = {
data: Countries
};
}
onTyping: function (text) {

onTyping(text){
var countries = Countries.filter(function (country) {
return country.name.toLowerCase().startsWith(text.toLowerCase())
}).map(function (country) {
return country.name;
});

this.setState({data: countries});
}

this.setState({
data: countries
});
},

render() {
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Search for a country
</Text>
<AutoComplete
onTyping={(text) => this.onTyping(text)}
onTyping={this.onTyping}
onSelect={(e) => AlertIOS.alert('You choosed', e)}
onBlur={() => AlertIOS.alert('Blur')}
onFocus={() => AlertIOS.alert('Focus')}
Expand Down Expand Up @@ -92,10 +90,8 @@ class RCTAutoCompleteApp extends Component {
/>
</View>
);

}
}

}
});

var styles = StyleSheet.create({
autocomplete: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"autocomplete"
],
"peerDependencies": {
"react-native": ">=0.6"
"react-native": ">=0.33.0"
}
}

0 comments on commit c007b33

Please sign in to comment.