Commit ceb35185 authored by xwenliang's avatar xwenliang

update PickerTest

parent 80cc9a3e
......@@ -45,7 +45,7 @@
#### Step 1 - install
```
```javascript
npm install react-native-picker --save
```
......@@ -190,4 +190,4 @@ $ pod install
]
```
### For pure javascript version -> [v3.0.5](https://github.com/beefe/react-native-picker/tree/pure-javascript-version)
### For pure javascript version -> [v3.0.5](https://github.com/beefe/react-native-picker/tree/pure-javascript-version)
{
"presets": ["react-native"]
}
[ignore]
; We fork some components by platform
.*/*[.]android.js
# We fork some components by platform.
.*/*.web.js
.*/*.android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
# Ugh
.*/node_modules/babel.*
.*/node_modules/babylon.*
.*/node_modules/invariant.*
# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/ErrorUtils.js
# Flow has a built-in definition for the 'react' module which we prefer to use
# over the currently-untyped source
.*/node_modules/react/react.js
.*/node_modules/react/lib/React.js
.*/node_modules/react/lib/ReactDOM.js
.*/__mocks__/.*
.*/__tests__/.*
.*/commoner/test/source/widget/share.js
# Ignore commoner tests
.*/node_modules/commoner/test/.*
# See https://github.com/facebook/flow/issues/442
.*/react-tools/node_modules/commoner/lib/reader.js
# Ignore jest
.*/node_modules/jest-cli/.*
# Ignore Website
.*/website/.*
# Ignore generators
.*/local-cli/generator.*
# Ignore BUCK generated folders
.*\.buckd/
.*/node_modules/is-my-json-valid/test/.*\.json
.*/node_modules/iconv-lite/encodings/tables/.*\.json
.*/node_modules/y18n/test/.*\.json
.*/node_modules/spdx-license-ids/spdx-license-ids.json
.*/node_modules/spdx-exceptions/index.json
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
.*/node_modules/resolve/lib/core.json
.*/node_modules/jsonparse/samplejson/.*\.json
.*/node_modules/json5/test/.*\.json
.*/node_modules/ua-parser-js/test/.*\.json
.*/node_modules/builtin-modules/builtin-modules.json
.*/node_modules/binary-extensions/binary-extensions.json
.*/node_modules/url-regex/tlds.json
.*/node_modules/joi/.*\.json
.*/node_modules/isemail/.*\.json
.*/node_modules/tr46/.*\.json
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; Ignore polyfills
.*/Libraries/polyfills/.*
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
node_modules/react-native/flow/
[options]
module.system=haste
emoji=true
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
module.system=haste
munge_underscores=true
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
unsafe.enable_getters_and_setters=true
[version]
0.24.0
^0.57.0
......@@ -22,19 +22,32 @@ DerivedData
*.xcuserstate
project.xcworkspace
# Android/IJ
# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
*.keystore
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
/**
* Bootstrap of PickerTest
*/
import React, {Component} from 'react';
import {
View,
Text,
TextInput,
TouchableOpacity,
Dimensions
} from 'react-native';
import Picker from 'react-native-picker';
import area from './area.json';
export default class PickerTest extends Component {
constructor(props, context) {
super(props, context);
}
_createDateData() {
let date = [];
for(let i=1970;i<2020;i++){
let month = [];
for(let j = 1;j<13;j++){
let day = [];
if(j === 2){
for(let k=1;k<29;k++){
day.push(k+'');
}
//Leap day for years that are divisible by 4, such as 2000, 2004
if(i%4 === 0){
day.push(29+'');
}
}
else if(j in {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1}){
for(let k=1;k<32;k++){
day.push(k+'');
}
}
else{
for(let k=1;k<31;k++){
day.push(k+'');
}
}
let _month = {};
_month[j+''] = day;
month.push(_month);
}
let _date = {};
_date[i+''] = month;
date.push(_date);
}
return date;
}
_createAreaData() {
let data = [];
let len = area.length;
for(let i=0;i<len;i++){
let city = [];
for(let j=0,cityLen=area[i]['city'].length;j<cityLen;j++){
let _city = {};
_city[area[i]['city'][j]['name']] = area[i]['city'][j]['area'];
city.push(_city);
}
let _data = {};
_data[area[i]['name']] = city;
data.push(_data);
}
return data;
}
_showDatePicker() {
Picker.init({
pickerData: this._createDateData(),
pickerToolBarFontSize: 16,
pickerFontSize: 16,
pickerFontColor: [255, 0 ,0, 1],
onPickerConfirm: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
},
onPickerCancel: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
},
onPickerSelect: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
}
});
Picker.show();
}
_showAreaPicker() {
Picker.init({
pickerData: this._createAreaData(),
selectedValue: ['河北', '唐山', '古冶区'],
onPickerConfirm: pickedValue => {
console.log('area', pickedValue);
},
onPickerCancel: pickedValue => {
console.log('area', pickedValue);
},
onPickerSelect: pickedValue => {
//Picker.select(['山东', '青岛', '黄岛区'])
console.log('area', pickedValue);
}
});
Picker.show();
}
_showTimePicker() {
let years = [],
months = [],
days = [],
hours = [],
minutes = [];
for(let i=1;i<51;i++){
years.push(i+1980);
}
for(let i=1;i<13;i++){
months.push(i);
hours.push(i);
}
for(let i=1;i<32;i++){
days.push(i);
}
for(let i=1;i<61;i++){
minutes.push(i);
}
let pickerData = [years, months, days, ['am', 'pm'], hours, minutes];
let date = new Date();
let selectedValue = [
date.getFullYear(),
date.getMonth()+1,
date.getDate(),
date.getHours() > 11 ? 'pm' : 'am',
date.getHours() === 12 ? 12 : date.getHours()%12,
date.getMinutes()
];
Picker.init({
pickerData,
selectedValue,
pickerTitleText: 'Select Date and Time',
wheelFlex: [2, 1, 1, 2, 1, 1],
onPickerConfirm: pickedValue => {
console.log('area', pickedValue);
},
onPickerCancel: pickedValue => {
console.log('area', pickedValue);
},
onPickerSelect: pickedValue => {
let targetValue = [...pickedValue];
if(parseInt(targetValue[1]) === 2){
if(targetValue[0]%4 === 0 && targetValue[2] > 29){
targetValue[2] = 29;
}
else if(targetValue[0]%4 !== 0 && targetValue[2] > 28){
targetValue[2] = 28;
}
}
else if(targetValue[1] in {4:1, 6:1, 9:1, 11:1} && targetValue[2] > 30){
targetValue[2] = 30;
}
// forbidden some value such as some 2.29, 4.31, 6.31...
if(JSON.stringify(targetValue) !== JSON.stringify(pickedValue)){
// android will return String all the time,but we put Number into picker at first
// so we need to convert them to Number again
targetValue.map((v, k) => {
if(k !== 3){
targetValue[k] = parseInt(v);
}
});
Picker.select(targetValue);
pickedValue = targetValue;
}
}
});
Picker.show();
}
_toggle() {
Picker.toggle();
}
_isPickerShow(){
Picker.isPickerShow(status => {
alert(status);
});
}
render() {
return (
<View style={{height: Dimensions.get('window').height}}>
<TouchableOpacity style={{marginTop: 40, marginLeft: 20}} onPress={this._showDatePicker.bind(this)}>
<Text>DatePicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._showTimePicker.bind(this)}>
<Text>TimePicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._showAreaPicker.bind(this)}>
<Text>AreaPicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._toggle.bind(this)}>
<Text>toggle</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._isPickerShow.bind(this)}>
<Text>isPickerShow</Text>
</TouchableOpacity>
<TextInput
placeholder="test picker with input"
style={{
height: 40,
borderColor: 'gray',
borderWidth: 1,
marginLeft: 20,
marginRight: 20,
marginTop: 10,
padding: 5
}}
/>
</View>
);
}
};
\ No newline at end of file
import 'react-native';
import React from 'react';
import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<App />
);
});
import re
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
......@@ -11,8 +9,9 @@ import re
#
lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
......@@ -20,7 +19,7 @@ for jarfile in glob(['libs/*.jar']):
)
for aarfile in glob(['libs/*.aar']):
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
......@@ -28,39 +27,39 @@ for aarfile in glob(['libs/*.aar']):
)
android_library(
name = 'all-libs',
exported_deps = lib_deps
name = "all-libs",
exported_deps = lib_deps,
)
android_library(
name = 'app-code',
srcs = glob([
'src/main/java/**/*.java',
]),
deps = [
':all-libs',
':build_config',
':res',
],
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)
android_build_config(
name = 'build_config',
package = 'com.pickertest',
name = "build_config",
package = "com.pickertest",
)
android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.pickertest',
name = "res",
package = "com.pickertest",
res = "src/main/res",
)
android_binary(
name = 'app',
package_type = 'debug',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//android/keystores:debug',
deps = [
':app-code',
],
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
......@@ -33,6 +33,13 @@ import com.android.build.OutputFile
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
......@@ -58,13 +65,17 @@ import com.android.build.OutputFile
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"]
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
......@@ -135,6 +146,6 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
from configurations.compile
into 'libs'
}
......@@ -50,6 +50,10 @@
-dontwarn com.facebook.react.**
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
-dontwarn android.text.StaticLayout
# okhttp
-keepattributes Signature
......
......@@ -19,7 +19,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......
package com.pickertest;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.beefe.picker.PickerViewPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
......@@ -17,7 +16,7 @@ public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
......@@ -28,10 +27,21 @@ public class MainApplication extends Application implements ReactApplication {
new PickerViewPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
<resources>
<string name="app_name">PickerTest</string>
</resources>
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
keystore(
name = 'debug',
store = 'debug.keystore',
properties = 'debug.keystore.properties',
visibility = [
'PUBLIC',
],
name = "debug",
properties = "debug.keystore.properties",
store = "debug.keystore",
visibility = [
"PUBLIC",
],
)
rootProject.name = 'PickerTest'
include ':app'
include ':react-native-picker'
project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
include ':app'
{
"name": "PickerTest",
"displayName": "PickerTest"
}
\ No newline at end of file
/**
* react-native-picker example for android
*/
import './index.js';
\ No newline at end of file
/**
* react-native-picker example for ios
*/
import './index.js';
\ No newline at end of file
/**
* Bootstrap of PickerTest
*/
import React, {Component} from 'react';
import {
AppRegistry,
View,
Text,
TextInput,
TouchableOpacity,
Dimensions
} from 'react-native';
import Picker from 'react-native-picker';
import area from './area.json';
class PickerTest extends Component {
constructor(props, context) {
super(props, context);
}
_createDateData() {
let date = [];
for(let i=1950;i<2050;i++){
let month = [];
for(let j = 1;j<13;j++){
let day = [];
if(j === 2){
for(let k=1;k<29;k++){
day.push(k+'');
}
//Leap day for years that are divisible by 4, such as 2000, 2004
if(i%4 === 0){
day.push(29+'');
}
}
else if(j in {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1}){
for(let k=1;k<32;k++){
day.push(k+'');
}
}
else{
for(let k=1;k<31;k++){
day.push(k+'');
}
}
let _month = {};
_month[j+''] = day;
month.push(_month);
}
let _date = {};
_date[i+''] = month;
date.push(_date);
}
return date;
}
_createAreaData() {
let data = [];
let len = area.length;
for(let i=0;i<len;i++){
let city = [];
for(let j=0,cityLen=area[i]['city'].length;j<cityLen;j++){
let _city = {};
_city[area[i]['city'][j]['name']] = area[i]['city'][j]['area'];
city.push(_city);
}
let _data = {};
_data[area[i]['name']] = city;
data.push(_data);
}
return data;
}
_showDatePicker() {
Picker.init({
pickerData: this._createDateData(),
pickerToolBarFontSize: 16,
pickerFontSize: 16,
pickerFontColor: [255, 0 ,0, 1],
onPickerConfirm: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
},
onPickerCancel: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
},
onPickerSelect: (pickedValue, pickedIndex) => {
console.log('date', pickedValue, pickedIndex);
}
});
Picker.show();
}
_showAreaPicker() {
Picker.init({
pickerData: this._createAreaData(),
selectedValue: ['河北', '唐山', '古冶区'],
onPickerConfirm: pickedValue => {
console.log('area', pickedValue);
},
onPickerCancel: pickedValue => {
console.log('area', pickedValue);
},
onPickerSelect: pickedValue => {
//Picker.select(['山东', '青岛', '黄岛区'])
console.log('area', pickedValue);
}
});
Picker.show();
}
_showTimePicker() {
let years = [],
months = [],
days = [],
hours = [],
minutes = [];
for(let i=1;i<51;i++){
years.push(i+1980);
}
for(let i=1;i<13;i++){
months.push(i);
hours.push(i);
}
for(let i=1;i<32;i++){
days.push(i);
}
for(let i=1;i<61;i++){
minutes.push(i);
}
let pickerData = [years, months, days, ['am', 'pm'], hours, minutes];
let date = new Date();
let selectedValue = [
[date.getFullYear()],
[date.getMonth()+1],
[date.getDate()],
[date.getHours() > 11 ? 'pm' : 'am'],
[date.getHours() === 12 ? 12 : date.getHours()%12],
[date.getMinutes()]
];
Picker.init({
pickerData,
selectedValue,
pickerTitleText: 'Select Date and Time',
wheelFlex: [2, 1, 1, 2, 1, 1],
onPickerConfirm: pickedValue => {
console.log('area', pickedValue);
},
onPickerCancel: pickedValue => {
console.log('area', pickedValue);
},
onPickerSelect: pickedValue => {
let targetValue = [...pickedValue];
if(parseInt(targetValue[1]) === 2){
if(targetValue[0]%4 === 0 && targetValue[2] > 29){
targetValue[2] = 29;
}
else if(targetValue[0]%4 !== 0 && targetValue[2] > 28){
targetValue[2] = 28;
}
}
else if(targetValue[1] in {4:1, 6:1, 9:1, 11:1} && targetValue[2] > 30){
targetValue[2] = 30;
}
// forbidden some value such as some 2.29, 4.31, 6.31...
if(JSON.stringify(targetValue) !== JSON.stringify(pickedValue)){
// android will return String all the time,but we put Number into picker at first
// so we need to convert them to Number again
targetValue.map((v, k) => {
if(k !== 3){
targetValue[k] = parseInt(v);
}
});
Picker.select(targetValue);
pickedValue = targetValue;
}
}
});
Picker.show();
}
_toggle() {
Picker.toggle();
}
_isPickerShow(){
Picker.isPickerShow(status => {
alert(status);
});
}
render() {
return (
<View style={{height: Dimensions.get('window').height}}>
<TouchableOpacity style={{marginTop: 40, marginLeft: 20}} onPress={this._showDatePicker.bind(this)}>
<Text>DatePicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._showTimePicker.bind(this)}>
<Text>TimePicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._showAreaPicker.bind(this)}>
<Text>AreaPicker</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._toggle.bind(this)}>
<Text>toggle</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginTop: 10, marginLeft: 20}} onPress={this._isPickerShow.bind(this)}>
<Text>isPickerShow</Text>
</TouchableOpacity>
<TextInput
placeholder="test picker with input"
style={{
height: 40,
borderColor: 'gray',
borderWidth: 1,
marginLeft: 20,
marginRight: 20,
marginTop: 10,
padding: 5
}}
/>
</View>
);
}
};
import { AppRegistry } from 'react-native';
import PickerTest from './PickerTest';
AppRegistry.registerComponent('PickerTest', () => PickerTest);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D2A28121D9B038B00D4039D"
BuildableName = "libReact.a"
BlueprintName = "React-tvOS"
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOS.app"
BlueprintName = "PickerTest-tvOS"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E48F1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOSTests.xctest"
BlueprintName = "PickerTest-tvOSTests"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E48F1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOSTests.xctest"
BlueprintName = "PickerTest-tvOSTests"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOS.app"
BlueprintName = "PickerTest-tvOS"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOS.app"
BlueprintName = "PickerTest-tvOS"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "PickerTest-tvOS.app"
BlueprintName = "PickerTest-tvOS"
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -3,9 +3,23 @@
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
BuildableName = "libReact.a"
BlueprintName = "React"
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
......@@ -37,10 +51,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
......@@ -62,15 +76,18 @@
ReferencedContainer = "container:PickerTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
......@@ -86,10 +103,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
......
......@@ -9,8 +9,8 @@
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
......@@ -18,7 +18,7 @@
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"PickerTest"
......
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
......@@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>PickerTest</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
......@@ -45,7 +47,7 @@
<dict>
<key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
......
......@@ -10,8 +10,8 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RCTLog.h"
#import "RCTRootView.h"
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
......@@ -37,7 +37,7 @@
- (void)testRendersWelcomeScreen
{
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
......
......@@ -3,11 +3,21 @@
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node_modules/react-native/packager/packager.sh"
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.3.1",
"react-native": "^0.32.0",
"react": "16.0.0",
"react-native": "^0.51.0",
"react-native-picker": "github:beefe/react-native-picker"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
}
}
......@@ -4,36 +4,38 @@ import {
NativeAppEventEmitter
} from 'react-native';
let ios = Platform.OS === 'ios';
let android = Platform.OS === 'android';
let Picker = NativeModules.BEEPickerManager;
const ios = Platform.OS === 'ios';
const android = Platform.OS === 'android';
const Picker = NativeModules.BEEPickerManager;
const options = {
isLoop: false,
pickerConfirmBtnText: 'confirm',
pickerCancelBtnText: 'cancel',
pickerTitleText: 'pls select',
pickerConfirmBtnColor: [1, 186, 245, 1],
pickerCancelBtnColor: [1, 186, 245, 1],
pickerTitleColor: [20, 20, 20, 1],
pickerToolBarBg: [232, 232, 232, 1],
pickerBg: [196, 199, 206, 1],
wheelFlex: [1, 1, 1],
pickerData: [],
selectedValue: [],
onPickerConfirm(){},
onPickerCancel(){},
onPickerSelect(){},
pickerToolBarFontSize: 16,
pickerFontSize: 16,
pickerFontColor: [31, 31 ,31, 1]
};
export default {
init(options){
let opt = {
isLoop: false,
pickerConfirmBtnText: 'confirm',
pickerCancelBtnText: 'cancel',
pickerTitleText: 'pls select',
pickerConfirmBtnColor: [1, 186, 245, 1],
pickerCancelBtnColor: [1, 186, 245, 1],
pickerTitleColor: [20, 20, 20, 1],
pickerToolBarBg: [232, 232, 232, 1],
pickerBg: [196, 199, 206, 1],
wheelFlex: [1, 1, 1],
pickerData: [],
selectedValue: [],
onPickerConfirm(){},
onPickerCancel(){},
onPickerSelect(){},
//4.0.12 add
pickerToolBarFontSize: 16,
pickerFontSize: 16,
pickerFontColor: [31, 31 ,31, 1],
...options
init(params){
const opt = {
...options,
...params
};
let fnConf = {
const fnConf = {
confirm: opt.onPickerConfirm,
cancel: opt.onPickerCancel,
select: opt.onPickerSelect
......
{
"name": "react-native-picker",
"version": "4.3.0",
"version": "4.3.1",
"description": "A Native Picker with high performance.",
"main": "index.js",
"types": "index.d.ts",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment