From b3894d0e4440fd69190e38a09c0c7705f7d9a3c7 Mon Sep 17 00:00:00 2001 From: nulrich Date: Tue, 27 Sep 2016 23:23:50 +0200 Subject: [PATCH] Fix #46 Use RCTFont instead of RCTConvert https://github.com/facebook/react-native/commit/c5a44b7ca37511823b24e3a4e9bfda8c715a5e64 --- RCTAutoComplete.ios.js | 13 +---- RCTAutoComplete.m | 11 ++-- RCTAutoComplete.xcodeproj/project.pbxproj | 66 +++++++++++------------ README.md | 40 +++++++------- package.json | 2 +- 5 files changed, 60 insertions(+), 72 deletions(-) diff --git a/RCTAutoComplete.ios.js b/RCTAutoComplete.ios.js index 0a5e0a1..6301e49 100644 --- a/RCTAutoComplete.ios.js +++ b/RCTAutoComplete.ios.js @@ -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); @@ -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', ]), diff --git a/RCTAutoComplete.m b/RCTAutoComplete.m index fe3df28..e446492 100644 --- a/RCTAutoComplete.m +++ b/RCTAutoComplete.m @@ -3,6 +3,7 @@ #import "RCTEventDispatcher.h" #import "UIView+React.h" #import "AutoCompleteView.h" +#import "RCTFont.h" @implementation RCTAutoComplete @@ -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) diff --git a/RCTAutoComplete.xcodeproj/project.pbxproj b/RCTAutoComplete.xcodeproj/project.pbxproj index a19c2d1..bbfc013 100644 --- a/RCTAutoComplete.xcodeproj/project.pbxproj +++ b/RCTAutoComplete.xcodeproj/project.pbxproj @@ -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 */ @@ -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 = ""; }; 13BE3DED1AC21097009241FE /* RCTAutoComplete.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAutoComplete.m; sourceTree = ""; }; - 371961E11B50741900F79BB7 /* AutoCompleteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoCompleteView.h; sourceTree = ""; }; - 371961E21B50741900F79BB7 /* AutoCompleteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoCompleteView.m; sourceTree = ""; }; - 371961E41B50745B00F79BB7 /* RCTAutoComplete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAutoComplete.h; sourceTree = ""; }; - 371961E71B50754700F79BB7 /* MLPAutoCompleteTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextField.h; sourceTree = ""; }; - 371961E81B50754700F79BB7 /* MLPAutoCompleteTextField.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MLPAutoCompleteTextField.m; sourceTree = ""; }; - 371961E91B50754700F79BB7 /* MLPAutoCompleteTextFieldDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextFieldDataSource.h; sourceTree = ""; }; - 371961EA1B50754700F79BB7 /* MLPAutoCompleteTextFieldDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompleteTextFieldDelegate.h; sourceTree = ""; }; - 371961EB1B50754700F79BB7 /* MLPAutoCompletionObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLPAutoCompletionObject.h; sourceTree = ""; }; - 371961EC1B50754700F79BB7 /* NSString+Levenshtein.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+Levenshtein.h"; sourceTree = ""; }; - 371961ED1B50754700F79BB7 /* NSString+Levenshtein.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+Levenshtein.m"; sourceTree = ""; }; + 3798A8D51D9B09D500348235 /* AutoCompleteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoCompleteView.h; sourceTree = ""; }; + 3798A8D61D9B09D500348235 /* AutoCompleteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoCompleteView.m; sourceTree = ""; }; + 3798A8EE1D9B0B0900348235 /* MLPAutoCompleteTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextField.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextField.h; sourceTree = ""; }; + 3798A8EF1D9B0B0900348235 /* MLPAutoCompleteTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MLPAutoCompleteTextField.m; path = MLPAutoCompleteTextField/MLPAutoCompleteTextField.m; sourceTree = ""; }; + 3798A8F01D9B0B0900348235 /* MLPAutoCompleteTextFieldDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextFieldDataSource.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDataSource.h; sourceTree = ""; }; + 3798A8F11D9B0B0900348235 /* MLPAutoCompleteTextFieldDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompleteTextFieldDelegate.h; path = MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDelegate.h; sourceTree = ""; }; + 3798A8F21D9B0B0900348235 /* MLPAutoCompletionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MLPAutoCompletionObject.h; path = MLPAutoCompleteTextField/MLPAutoCompletionObject.h; sourceTree = ""; }; + 3798A8F31D9B0B0900348235 /* NSString+Levenshtein.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+Levenshtein.h"; path = "MLPAutoCompleteTextField/NSString+Levenshtein.h"; sourceTree = ""; }; + 3798A8F41D9B0B0900348235 /* NSString+Levenshtein.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+Levenshtein.m"; path = "MLPAutoCompleteTextField/NSString+Levenshtein.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,28 +59,28 @@ name = Products; sourceTree = ""; }; - 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 = ""; }; 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 = ""; @@ -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; @@ -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; @@ -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; @@ -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)"; @@ -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"; diff --git a/README.md b/README.md index 77cf833..149e87a 100644 --- a/README.md +++ b/README.md @@ -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 ( Search for a country this.onTyping(text)} + onTyping={this.onTyping} onSelect={(e) => AlertIOS.alert('You choosed', e)} onBlur={() => AlertIOS.alert('Blur')} onFocus={() => AlertIOS.alert('Focus')} @@ -92,10 +90,8 @@ class RCTAutoCompleteApp extends Component { /> ); - - } -} - + } +}); var styles = StyleSheet.create({ autocomplete: { diff --git a/package.json b/package.json index 5b39a3b..bcb24a2 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,6 @@ "autocomplete" ], "peerDependencies": { - "react-native": ">=0.6" + "react-native": ">=0.33.0" } }