Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-picker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-picker
Commits
473d96a6
Commit
473d96a6
authored
Dec 30, 2015
by
zooble
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from LzxHahaha/master
Debug以及增加两个属性
parents
a5986f88
39c9044d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
5 deletions
+43
-5
index.js
index.js
+43
-5
No files found.
index.js
View file @
473d96a6
...
...
@@ -22,21 +22,27 @@ export default class PickerAny extends React.Component {
static
propTypes
=
{
pickerBtnText
:
PropTypes
.
string
,
pickerCancelBtnText
:
PropTypes
.
string
,
pickerBtnStyle
:
PropTypes
.
any
,
pickerTitle
:
PropTypes
.
string
,
pickerTitleStyle
:
PropTypes
.
any
,
pickerToolBarStyle
:
PropTypes
.
any
,
pickerItemStyle
:
PropTypes
.
any
,
pickerHeight
:
PropTypes
.
number
,
showDuration
:
PropTypes
.
number
,
pickerData
:
PropTypes
.
any
.
isRequired
,
selectedValue
:
PropTypes
.
any
.
isRequired
,
onPickerDone
:
PropTypes
.
func
onPickerDone
:
PropTypes
.
func
,
onPickerCancel
:
PropTypes
.
func
}
static
defaultProps
=
{
pickerBtnText
:
'
完成
'
,
pickerCancelBtnText
:
'
取消
'
,
pickerHeight
:
250
,
showDuration
:
300
,
onPickerDone
:
()
=>
{}
onPickerDone
:
()
=>
{},
onPickerCancel
:
()
=>
{}
}
constructor
(
props
,
context
){
...
...
@@ -56,7 +62,10 @@ export default class PickerAny extends React.Component {
//the pickedValue must looks like [wheelone's, wheeltwo's, ...]
//this.state.selectedValue may be the result of the first pickerWheel
let
pickerBtnText
=
props
.
pickerBtnText
;
let
pickerCancelBtnText
=
props
.
pickerCancelBtnText
;
let
pickerBtnStyle
=
props
.
pickerBtnStyle
;
let
pickerTitle
=
props
.
pickerTitle
;
let
pickerTitleStyle
=
props
.
pickerTitleStyle
;
let
pickerToolBarStyle
=
props
.
pickerToolBarStyle
;
let
pickerItemStyle
=
props
.
pickerItemStyle
;
let
pickerHeight
=
props
.
pickerHeight
;
...
...
@@ -64,10 +73,12 @@ export default class PickerAny extends React.Component {
let
pickerData
=
props
.
pickerData
;
let
selectedValue
=
props
.
selectedValue
;
let
onPickerDone
=
props
.
onPickerDone
;
let
onPickerCancel
=
props
.
onPickerCancel
;
let
pickerStyle
=
pickerData
.
constructor
===
Array
?
'
parallel
'
:
'
cascade
'
;
let
firstWheelData
;
let
firstPickedData
;
let
secondPickedData
;
let
secondWheelData
;
let
secondPickedDataIndex
;
let
thirdWheelData
;
...
...
@@ -96,7 +107,10 @@ export default class PickerAny extends React.Component {
this
.
pickerStyle
=
pickerStyle
;
return
{
pickerBtnText
,
pickerCancelBtnText
,
pickerBtnStyle
,
pickerTitle
,
pickerTitleStyle
,
pickerToolBarStyle
,
pickerItemStyle
,
pickerHeight
,
...
...
@@ -104,6 +118,7 @@ export default class PickerAny extends React.Component {
pickerData
,
selectedValue
,
onPickerDone
,
onPickerCancel
,
//list of first wheel data
firstWheelData
,
//first wheel selected value
...
...
@@ -176,6 +191,11 @@ export default class PickerAny extends React.Component {
this
.
pickerWheel
.
moveDown
();
}
_pickerCancel
()
{
this
.
_toggle
();
this
.
state
.
onPickerCancel
();
}
_pickerFinish
(){
this
.
_toggle
();
this
.
state
.
onPickerDone
(
this
.
pickedValue
);
...
...
@@ -298,7 +318,7 @@ export default class PickerAny extends React.Component {
selectedValue
=
{
me
.
state
.
firstPickedData
}
onValueChange
=
{
value
=>
{
let
secondWheelData
=
Object
.
keys
(
pickerData
[
value
]);
cascadeData
=
me
.
_getCascadeData
(
pickerData
,
me
.
pickedValue
,
value
,
secondWheelData
[
0
]);
let
cascadeData
=
me
.
_getCascadeData
(
pickerData
,
me
.
pickedValue
,
value
,
secondWheelData
[
0
]);
//when onPicked, this.pickedValue will pass to the parent
//when firstWheel changed, second and third will also change
if
(
cascadeData
.
thirdWheelData
){
...
...
@@ -412,14 +432,20 @@ export default class PickerAny extends React.Component {
<Text style={styles.pickerMoveBtn} onPress={this._nextPressHandle.bind(this)}>下一个</Text>
</View>
);*/
let
pickerBtn
=
null
;
//
let pickerBtn = null;
return
(
<
Animated
.
View
style
=
{[
styles
.
picker
,
{
height
:
this
.
state
.
pickerHeight
,
bottom
:
this
.
state
.
slideAnim
}]}
>
<
View
style
=
{[
styles
.
pickerToolbar
,
this
.
state
.
pickerToolBarStyle
]}
>
{
pickerBtn
}
<
View
style
=
{
styles
.
pickerCancelBtn
}
>
<
Text
style
=
{[
styles
.
pickerFinishBtnText
,
this
.
state
.
pickerBtnStyle
]}
onPress
=
{
this
.
_pickerCancel
.
bind
(
this
)}
>
{
this
.
state
.
pickerCancelBtnText
}
<
/Text
>
<
/View
>
<
Text
style
=
{[
styles
.
pickerTitle
,
this
.
state
.
pickerTitleStyle
]}
numberOfLines
=
{
1
}
>
{
this
.
state
.
pickerTitle
}
<
/Text
>
<
View
style
=
{
styles
.
pickerFinishBtn
}
>
<
Text
style
=
{[
styles
.
pickerFinishBtnText
,
this
.
state
.
pickerBtnStyle
]}
onPress
=
{
this
.
_pickerFinish
.
bind
(
this
)}
>
{
this
.
state
.
pickerBtnText
}
<
/Text
>
...
...
@@ -469,6 +495,18 @@ let styles = StyleSheet.create({
fontSize
:
16
,
marginLeft
:
20
},
pickerCancelBtn
:
{
flex
:
1
,
flexDirection
:
'
row
'
,
justifyContent
:
'
flex-start
'
,
alignItems
:
'
center
'
,
marginLeft
:
20
},
pickerTitle
:
{
flex
:
5
,
color
:
'
black
'
,
textAlign
:
'
center
'
},
pickerFinishBtn
:
{
flex
:
1
,
flexDirection
:
'
row
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment