From 2fa93457cf9b97f3b6e4704f15d82a811ec0aa94 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Sat, 14 Oct 2017 15:51:23 +0200 Subject: [PATCH 1/9] Updated to prop-types for React 16 --- app/pickerHandle/handle.js | 3 ++- app/pickerLogic/basicPicker.js | 3 ++- app/pickerLogic/basicRoll.js | 3 ++- app/pickerLogic/cascadePicker.js | 3 ++- app/pickerLogic/cascadeRoll.js | 3 ++- app/pickerTrigger/outer.js | 4 ++-- package.json | 1 + 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/pickerHandle/handle.js b/app/pickerHandle/handle.js index aa43d7a..5ad7e1e 100644 --- a/app/pickerHandle/handle.js +++ b/app/pickerHandle/handle.js @@ -1,7 +1,7 @@ /** * 依赖引用 */ -import React, {Component,PropTypes} from 'react'; +import React, {Component} from 'react'; import { View, Text, @@ -16,6 +16,7 @@ import { Modal, Image, } from 'react-native'; +import PropTypes from 'prop-types'; import styles from './handleStyle'; diff --git a/app/pickerLogic/basicPicker.js b/app/pickerLogic/basicPicker.js index 837ffeb..cd1f47a 100644 --- a/app/pickerLogic/basicPicker.js +++ b/app/pickerLogic/basicPicker.js @@ -1,7 +1,7 @@ /** * 依赖引用 */ -import React, {Component,PropTypes} from 'react'; +import React, {Component} from 'react'; import { View, Text, @@ -13,6 +13,7 @@ import { Modal, Image, } from 'react-native'; +import PropTypes from 'prop-types'; import Pickroll from './basicRoll'; import {styles} from './pickerStyle'; import InputOuter from '../pickerTrigger/outer'; diff --git a/app/pickerLogic/basicRoll.js b/app/pickerLogic/basicRoll.js index f82eefb..a211dd1 100644 --- a/app/pickerLogic/basicRoll.js +++ b/app/pickerLogic/basicRoll.js @@ -1,13 +1,14 @@ /** * 依赖引入 */ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { View, Text, Animated, ScrollView } from 'react-native'; +import PropTypes from 'prop-types'; import {rollStyles} from './pickerStyle'; /** diff --git a/app/pickerLogic/cascadePicker.js b/app/pickerLogic/cascadePicker.js index 94c2d3f..6ef3ea7 100644 --- a/app/pickerLogic/cascadePicker.js +++ b/app/pickerLogic/cascadePicker.js @@ -1,7 +1,7 @@ /** * 依赖引用 */ -import React, { Component, PropTypes} from 'react'; +import React, { Component} from 'react'; import { View, Text, @@ -14,6 +14,7 @@ import { ActivityIndicator, Image } from 'react-native'; +import PropTypes from 'prop-types'; import Pickroll from './cascadeRoll'; import {styles} from './pickerStyle'; import InputOuter from '../pickerTrigger/outer'; diff --git a/app/pickerLogic/cascadeRoll.js b/app/pickerLogic/cascadeRoll.js index a871a34..13d5123 100644 --- a/app/pickerLogic/cascadeRoll.js +++ b/app/pickerLogic/cascadeRoll.js @@ -1,13 +1,14 @@ /** * 依赖引入 */ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import { View, Text, Animated, ScrollView } from 'react-native'; +import PropTypes from 'prop-types'; import {rollStyles} from './pickerStyle'; /** diff --git a/app/pickerTrigger/outer.js b/app/pickerTrigger/outer.js index 7d7f0d5..5d15e4f 100644 --- a/app/pickerTrigger/outer.js +++ b/app/pickerTrigger/outer.js @@ -1,7 +1,7 @@ /** * 依赖引用 */ -import React, {Component,PropTypes} from 'react'; +import React, {Component} from 'react'; import { View, Text, @@ -16,6 +16,7 @@ import { Modal, Image, } from 'react-native'; +import PropTypes from 'prop-types'; import styles from './outerStyle'; import Icon from 'react-native-vector-icons/Entypo'; @@ -54,7 +55,6 @@ class InputOuter extends Component { {this.props.onPress();}}> {this.props.placeholder} diff --git a/package.json b/package.json index a3b3a77..8c70082 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "coverage": "cat ./coverage/lcov.info | coveralls" }, "dependencies": { + "prop-types": "^15.6.0", "react-native-vector-icons": "^4.0.0" }, "peerDependencies": { From 669962c3a6ef237a522b0c56fe9802c3fb89debe Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Sat, 14 Oct 2017 18:53:11 +0200 Subject: [PATCH 2/9] Made some improvements needed for the artsound app --- app/pickerHandle/handle.js | 12 ++++++------ app/pickerLogic/basicPicker.js | 9 ++++++--- app/pickerTrigger/outer.js | 16 +++++++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/pickerHandle/handle.js b/app/pickerHandle/handle.js index 5ad7e1e..8665451 100644 --- a/app/pickerHandle/handle.js +++ b/app/pickerHandle/handle.js @@ -57,15 +57,15 @@ class Handle extends Component { render(){ return ( - {this.props.confirmChose();}}> - {this.props.confirmBtnText} - + {this.props.cancelChose(false, 'cancel'); + }}> {this.props.pickerName} - {this.props.cancelChose(false, 'cancel'); - }}> + {this.props.confirmChose();}}> + {this.props.confirmBtnText} + @@ -275,7 +278,7 @@ BasicPicker.defaultProps = { visible: false, enable: true, inputValue: 'please chose', - confirmBtnText: '确定', - cancelBtnText: '取消' + confirmBtnText: 'Done', + cancelBtnText: 'Cancel' }; export default BasicPicker; diff --git a/app/pickerTrigger/outer.js b/app/pickerTrigger/outer.js index 5d15e4f..6a97b57 100644 --- a/app/pickerTrigger/outer.js +++ b/app/pickerTrigger/outer.js @@ -18,7 +18,6 @@ import { } from 'react-native'; import PropTypes from 'prop-types'; import styles from './outerStyle'; -import Icon from 'react-native-vector-icons/Entypo'; /** @@ -32,7 +31,8 @@ class InputOuter extends Component { */ static propTypes = { //传递的数据 - data: PropTypes.array + data: PropTypes.array, + iconSource: PropTypes.oneOfType([PropTypes.number, PropTypes.object]), }; /** @@ -53,14 +53,20 @@ class InputOuter extends Component { render(){ return ( {this.props.onPress();}}> - + {this.props.placeholder} - - {/* */} + {this.props.iconSource ? + + : + null + } ); From 64378688d18f674a3f6523d6d2d382209213a7c2 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Sat, 14 Oct 2017 19:09:03 +0200 Subject: [PATCH 3/9] Changed the cancel and confirm button of position --- app/pickerHandle/handle.js | 14 +++++++------- app/pickerHandle/handleStyle.js | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/pickerHandle/handle.js b/app/pickerHandle/handle.js index 8665451..edc363e 100644 --- a/app/pickerHandle/handle.js +++ b/app/pickerHandle/handle.js @@ -59,18 +59,18 @@ class Handle extends Component { {this.props.cancelChose(false, 'cancel'); }}> - - {this.props.pickerName} - - {this.props.confirmChose();}}> - {this.props.confirmBtnText} - {this.props.cancelBtnText} + + {this.props.pickerName} + + {this.props.confirmChose();}}> + {this.props.confirmBtnText} + ); }} diff --git a/app/pickerHandle/handleStyle.js b/app/pickerHandle/handleStyle.js index e8c20c8..1557d18 100644 --- a/app/pickerHandle/handleStyle.js +++ b/app/pickerHandle/handleStyle.js @@ -16,7 +16,7 @@ let styles = StyleSheet.create({ justifyContent: 'center' }, confirmBtnStyle:{ - textAlign:'left', + textAlign:'right', paddingLeft:20, paddingRight:20, fontSize: 18 @@ -35,7 +35,7 @@ let styles = StyleSheet.create({ alignItems: 'center' }, cancelBtnStyle: { - textAlign:'right', + textAlign:'left', paddingLeft:20, paddingRight:20, fontSize: 18 From e9ca5e6082786a822e143a36d7d5740542e21f07 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Sat, 14 Oct 2017 19:25:55 +0200 Subject: [PATCH 4/9] Changed modal animation like datePicker --- app/pickerLogic/basicPicker.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/app/pickerLogic/basicPicker.js b/app/pickerLogic/basicPicker.js index 8a2e325..0ed1193 100644 --- a/app/pickerLogic/basicPicker.js +++ b/app/pickerLogic/basicPicker.js @@ -158,18 +158,28 @@ class BasicPicker extends Component { * @private */ _setModalVisible(visible,type) { - if (visible){ - this.setState({visible: visible}); - Animated.timing( + const {height, duration} = this.props; + + // slide animation + if (visible) { + this.setState({modalVisible: visible}); + return Animated.timing( this.state.animatedHeight, - {toValue: height - modalHeight, - delay: 300} + { + toValue: height, + duration: duration + } ).start(); } else { - Animated.timing( + return Animated.timing( this.state.animatedHeight, - {toValue: height} - ).start(() => this._changeAnimateStatus(type)); + { + toValue: 0, + duration: duration + } + ).start(() => { + this.setState({modalVisible: visible}); + }); } } @@ -203,7 +213,7 @@ class BasicPicker extends Component { return ( {this._setModalVisible(false);}} From f622d14a8c0dbe6e83442eefdf23b8c7078d131a Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Sat, 14 Oct 2017 20:30:14 +0200 Subject: [PATCH 5/9] Revert "Changed modal animation like datePicker" This reverts commit e9ca5e6082786a822e143a36d7d5740542e21f07. --- app/pickerLogic/basicPicker.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/app/pickerLogic/basicPicker.js b/app/pickerLogic/basicPicker.js index 0ed1193..8a2e325 100644 --- a/app/pickerLogic/basicPicker.js +++ b/app/pickerLogic/basicPicker.js @@ -158,28 +158,18 @@ class BasicPicker extends Component { * @private */ _setModalVisible(visible,type) { - const {height, duration} = this.props; - - // slide animation - if (visible) { - this.setState({modalVisible: visible}); - return Animated.timing( + if (visible){ + this.setState({visible: visible}); + Animated.timing( this.state.animatedHeight, - { - toValue: height, - duration: duration - } + {toValue: height - modalHeight, + delay: 300} ).start(); } else { - return Animated.timing( + Animated.timing( this.state.animatedHeight, - { - toValue: 0, - duration: duration - } - ).start(() => { - this.setState({modalVisible: visible}); - }); + {toValue: height} + ).start(() => this._changeAnimateStatus(type)); } } @@ -213,7 +203,7 @@ class BasicPicker extends Component { return ( {this._setModalVisible(false);}} From 46b588548a462286673ef471523a1409c9538a29 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Wed, 18 Oct 2017 11:29:41 +0200 Subject: [PATCH 6/9] Added support for I18n --- app/pickerLogic/basicPicker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/pickerLogic/basicPicker.js b/app/pickerLogic/basicPicker.js index 8a2e325..2091888 100644 --- a/app/pickerLogic/basicPicker.js +++ b/app/pickerLogic/basicPicker.js @@ -128,7 +128,8 @@ class BasicPicker extends Component { */ _confirmChose(){ this.props.data.map((item,index) =>{ - this.str = this.str + this.props.data[index][this.select.selectedValue[index]].name; + const keys = Object.keys(this.props.data[index]); + this.str = this.str + keys[keys.indexOf(this.select.selectedValue[0])]; }); this. _setModalVisible(false,'confirm'); return this.str; @@ -248,7 +249,8 @@ class BasicPicker extends Component { ))) } From 6dd8ade8d4a01a6c8657f7254e3d5b0ec803f228 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Fri, 20 Oct 2017 11:59:33 +0200 Subject: [PATCH 7/9] Fix for I18n on android --- app/pickerLogic/basicRoll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pickerLogic/basicRoll.js b/app/pickerLogic/basicRoll.js index a211dd1..4422b63 100644 --- a/app/pickerLogic/basicRoll.js +++ b/app/pickerLogic/basicRoll.js @@ -188,7 +188,7 @@ class Pickroll extends Component { this.items = []; Object.keys(this.props.data).map((child,index) =>{ child === this.props.selectedValue && (this.selectedIndex = index); - this.items.push({value: child, label: this.props.data[child].name}); + this.items.push({value: child, label: typeof this.props.data[child].name === 'function' ? this.props.data[child].name() : this.props.data[child].name}); }); this.moveDy = 0; this.fingerLeft = false; From 514ce1df0e45ca6a179facd32cb5589e862e7d43 Mon Sep 17 00:00:00 2001 From: Makhout Nabil Date: Tue, 24 Oct 2017 14:45:51 +0200 Subject: [PATCH 8/9] android fix --- app/pickerTrigger/outerStyle.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/pickerTrigger/outerStyle.js b/app/pickerTrigger/outerStyle.js index 6f56200..c6bb06f 100644 --- a/app/pickerTrigger/outerStyle.js +++ b/app/pickerTrigger/outerStyle.js @@ -21,7 +21,6 @@ let styles = StyleSheet.create({ justifyContent: 'center', height: 40, backgroundColor: '#fff', - borderRadius: 3 }, textInput:{ flex: 1, From c5dff9c2b2d2dc2f6a6650d5d0f5bee05223d2e6 Mon Sep 17 00:00:00 2001 From: Jo Somers Date: Wed, 25 Oct 2017 13:03:00 +0200 Subject: [PATCH 9/9] ViewPropTypes --- app/pickerLogic/basicPicker.js | 7 ++++--- app/pickerLogic/basicRoll.js | 5 +++-- app/pickerLogic/cascadePicker.js | 7 ++++--- app/pickerLogic/cascadeRoll.js | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/pickerLogic/basicPicker.js b/app/pickerLogic/basicPicker.js index 2091888..0292d87 100644 --- a/app/pickerLogic/basicPicker.js +++ b/app/pickerLogic/basicPicker.js @@ -4,6 +4,7 @@ import React, {Component} from 'react'; import { View, + ViewPropTypes, Text, Dimensions, Animated, @@ -50,13 +51,13 @@ class BasicPicker extends Component { //确认按钮样式 confirmBtnStyle: Text.propTypes.style, //输入框样式 - inputStyle: View.propTypes.style, + inputStyle: ViewPropTypes.style, //滚轮头部样式 - navStyle: View.propTypes.style, + navStyle: ViewPropTypes.style, //输入框内部字体样式 textStyle: Text.propTypes.style, //右边下拉按钮的样式 - iconStyle: View.propTypes.style, + iconStyle: ViewPropTypes.style, //picker的名称 pickerName: PropTypes.string, //输入框内部文字初始值 diff --git a/app/pickerLogic/basicRoll.js b/app/pickerLogic/basicRoll.js index 4422b63..6e96b9e 100644 --- a/app/pickerLogic/basicRoll.js +++ b/app/pickerLogic/basicRoll.js @@ -4,6 +4,7 @@ import React, { Component } from 'react'; import { View, + ViewPropTypes, Text, Animated, ScrollView @@ -30,7 +31,7 @@ class Pickroll extends Component { //选择的值的位置 selectIndex: PropTypes.number, //整个picker的样式 - pickerStyle: View.propTypes.style, + pickerStyle: ViewPropTypes.style, //单轮每个格子的样式 itemAndroidStyle: Text.propTypes.style }; @@ -47,7 +48,7 @@ class Pickroll extends Component { /** * 状态初始化 * @param props {object} 继承的属性 - * @returns {{selectedIndex: number, items: Array, pickerStyle:View.propTypes.style, itemStyle:View.propTypes.style, onValueChange: func}} + * @returns {{selectedIndex: number, items: Array, pickerStyle: ViewPropTypes.style, itemStyle: View.propTypes.style, onValueChange: func}} * @private */ diff --git a/app/pickerLogic/cascadePicker.js b/app/pickerLogic/cascadePicker.js index 6ef3ea7..615ac47 100644 --- a/app/pickerLogic/cascadePicker.js +++ b/app/pickerLogic/cascadePicker.js @@ -4,6 +4,7 @@ import React, { Component} from 'react'; import { View, + ViewPropTypes, Text, Dimensions, Animated, @@ -51,13 +52,13 @@ class CascadePicker extends Component { //确认按钮样式 confirmBtnStyle: Text.propTypes.style, //输入框样式 - inputStyle: View.propTypes.style, + inputStyle: ViewPropTypes.style, //滚轮头部样式 - navStyle: View.propTypes.style, + navStyle: ViewPropTypes.style, //输入框内部字体样式 textStyle: Text.propTypes.style, //右边下拉按钮的样式 - iconStyle: View.propTypes.style, + iconStyle: ViewPropTypes.style, //picker的名称 pickerName: PropTypes.string, //输入框内部文字初始值 diff --git a/app/pickerLogic/cascadeRoll.js b/app/pickerLogic/cascadeRoll.js index 13d5123..9d47058 100644 --- a/app/pickerLogic/cascadeRoll.js +++ b/app/pickerLogic/cascadeRoll.js @@ -4,6 +4,7 @@ import React, { Component } from 'react'; import { View, + ViewPropTypes, Text, Animated, ScrollView @@ -30,7 +31,7 @@ class Pickroll extends Component { //选择的值的位置 selectIndex: PropTypes.number, //整个picker的样式 - pickerStyle: View.propTypes.style, + pickerStyle: ViewPropTypes, //单轮每个格子的样式 itemAndroidStyle: Text.propTypes.style };