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
cf30fbc6
Commit
cf30fbc6
authored
Dec 20, 2016
by
xwenliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix when keyboard show and hide then picker disappear on ios #102
parent
3a9d4388
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
91 deletions
+86
-91
example/PickerTest/index.android.js
example/PickerTest/index.android.js
+1
-8
example/PickerTest/index.ios.js
example/PickerTest/index.ios.js
+1
-8
example/PickerTest/index.js
example/PickerTest/index.js
+80
-71
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
+3
-3
package.json
package.json
+1
-1
No files found.
example/PickerTest/index.android.js
View file @
cf30fbc6
/**
/**
* react-native-picker example for android
* react-native-picker example for android
*/
*/
import
'
./index.js
'
;
import
{
\ No newline at end of file
AppRegistry
}
from
'
react-native
'
;
import
PickerTest
from
'
./index.js
'
;
AppRegistry
.
registerComponent
(
'
PickerTest
'
,
()
=>
PickerTest
);
\ No newline at end of file
example/PickerTest/index.ios.js
View file @
cf30fbc6
/**
/**
* react-native-picker example for ios
* react-native-picker example for ios
*/
*/
import
'
./index.js
'
;
import
{
\ No newline at end of file
AppRegistry
}
from
'
react-native
'
;
import
PickerTest
from
'
./index.js
'
;
AppRegistry
.
registerComponent
(
'
PickerTest
'
,
()
=>
PickerTest
);
example/PickerTest/index.js
View file @
cf30fbc6
...
@@ -4,83 +4,80 @@
...
@@ -4,83 +4,80 @@
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
{
import
{
AppRegistry
,
View
,
View
,
Text
,
Text
,
TextInput
,
TouchableOpacity
,
TouchableOpacity
,
Dimensions
Dimensions
}
from
'
react-native
'
;
}
from
'
react-native
'
;
import
Picker
from
'
react-native-picker
'
;
import
Picker
from
'
react-native-picker
'
;
import
area
from
'
./area.json
'
;
function
createDateData
(){
class
PickerTest
extends
Component
{
let
date
=
[];
for
(
let
i
=
1950
;
i
<
2050
;
i
++
){
constructor
(
props
,
context
)
{
let
month
=
[];
super
(
props
,
context
);
for
(
let
j
=
1
;
j
<
13
;
j
++
){
}
let
day
=
[];
if
(
j
===
2
){
_createDateData
()
{
for
(
let
k
=
1
;
k
<
29
;
k
++
){
let
date
=
[];
day
.
push
(
k
+
'
日
'
);
for
(
let
i
=
1950
;
i
<
2050
;
i
++
){
}
let
month
=
[];
//Leap day for years that are divisible by 4, such as 2000, 2004
for
(
let
j
=
1
;
j
<
13
;
j
++
){
if
(
i
%
4
===
0
){
let
day
=
[];
day
.
push
(
29
+
'
日
'
);
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
}){
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
++
){
for
(
let
k
=
1
;
k
<
32
;
k
++
){
day
.
push
(
k
+
'
日
'
);
day
.
push
(
k
+
'
日
'
);
}
}
}
}
else
{
else
{
for
(
let
k
=
1
;
k
<
31
;
k
++
)
{
for
(
let
k
=
1
;
k
<
31
;
k
++
){
day
.
push
(
k
+
'
日
'
);
day
.
push
(
k
+
'
日
'
);
}
}
}
let
_month
=
{};
_month
[
j
+
'
月
'
]
=
day
;
month
.
push
(
_month
);
}
}
let
_
month
=
{};
let
_
date
=
{};
_
month
[
j
+
'
月
'
]
=
day
;
_
date
[
i
+
'
年
'
]
=
month
;
month
.
push
(
_month
);
date
.
push
(
_date
);
}
}
let
_date
=
{};
return
date
;
_date
[
i
+
'
年
'
]
=
month
;
date
.
push
(
_date
);
}
}
return
date
;
};
function
createAreaData
(
callback
){
fetch
(
'
https://raw.githubusercontent.com/beefe/react-native-picker/master/example/PickerTest/area.json
'
).
then
(
res
=>
{
res
.
json
().
then
(
area
=>
{
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
=
{};
_createAreaData
()
{
_data
[
area
[
i
][
'
name
'
]]
=
city
;
let
data
=
[];
data
.
push
(
_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
);
}
}
callback
(
data
);
});
},
err
=>
{
console
.
log
(
err
);
});
};
export
default
class
PickerTest
extends
Component
{
constructor
(
props
,
context
)
{
let
_data
=
{};
super
(
props
,
context
);
_data
[
area
[
i
][
'
name
'
]]
=
city
;
data
.
push
(
_data
);
}
return
data
;
}
}
_showDatePicker
()
{
_showDatePicker
()
{
Picker
.
init
({
Picker
.
init
({
pickerData
:
createDateData
(),
pickerData
:
this
.
_
createDateData
(),
selectedValue
:
[
'
2015年
'
,
'
12月
'
,
'
12日
'
],
selectedValue
:
[
'
2015年
'
,
'
12月
'
,
'
12日
'
],
onPickerConfirm
:
pickedValue
=>
{
onPickerConfirm
:
pickedValue
=>
{
console
.
log
(
'
date
'
,
pickedValue
);
console
.
log
(
'
date
'
,
pickedValue
);
...
@@ -96,22 +93,20 @@ export default class PickerTest extends Component {
...
@@ -96,22 +93,20 @@ export default class PickerTest extends Component {
}
}
_showAreaPicker
()
{
_showAreaPicker
()
{
createAreaData
(
data
=>
{
Picker
.
init
({
Picker
.
init
({
pickerData
:
this
.
_createAreaData
(),
pickerData
:
data
,
selectedValue
:
[
'
河北
'
,
'
唐山
'
,
'
古冶区
'
],
selectedValue
:
[
'
河北
'
,
'
唐山
'
,
'
古冶区
'
],
onPickerConfirm
:
pickedValue
=>
{
onPickerConfirm
:
pickedValue
=>
{
console
.
log
(
'
area
'
,
pickedValue
);
console
.
log
(
'
area
'
,
pickedValue
);
},
},
onPickerCancel
:
pickedValue
=>
{
onPickerCancel
:
pickedValue
=>
{
console
.
log
(
'
area
'
,
pickedValue
);
console
.
log
(
'
area
'
,
pickedValue
);
},
},
onPickerSelect
:
pickedValue
=>
{
onPickerSelect
:
pickedValue
=>
{
console
.
log
(
'
area
'
,
pickedValue
);
console
.
log
(
'
area
'
,
pickedValue
);
}
}
});
Picker
.
show
();
});
});
Picker
.
show
();
}
}
_toggle
()
{
_toggle
()
{
...
@@ -139,7 +134,21 @@ export default class PickerTest extends Component {
...
@@ -139,7 +134,21 @@ export default class PickerTest extends Component {
<
TouchableOpacity
style
=
{{
marginTop
:
10
,
marginLeft
:
20
}}
onPress
=
{
this
.
_isPickerShow
.
bind
(
this
)}
>
<
TouchableOpacity
style
=
{{
marginTop
:
10
,
marginLeft
:
20
}}
onPress
=
{
this
.
_isPickerShow
.
bind
(
this
)}
>
<
Text
>
isPickerShow
<
/Text
>
<
Text
>
isPickerShow
<
/Text
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TextInput
placeholder
=
"
test picker with input
"
style
=
{{
height
:
40
,
borderColor
:
'
gray
'
,
borderWidth
:
1
,
marginLeft
:
20
,
marginRight
:
20
,
marginTop
:
10
,
padding
:
5
}}
/
>
<
/View
>
<
/View
>
);
);
}
}
};
};
AppRegistry
.
registerComponent
(
'
PickerTest
'
,
()
=>
PickerTest
);
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
View file @
cf30fbc6
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
@property
(
nonatomic
,
strong
)
BzwPicker
*
pick
;
@property
(
nonatomic
,
strong
)
BzwPicker
*
pick
;
@property
(
nonatomic
,
assign
)
float
height
;
@property
(
nonatomic
,
assign
)
float
height
;
@property
(
nonatomic
,
strong
)
UIWindow
*
window
;
@property
(
nonatomic
,
weak
)
UIWindow
*
window
;
@end
@end
...
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE();
...
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD
(
_init
:
(
NSDictionary
*
)
indic
){
RCT_EXPORT_METHOD
(
_init
:
(
NSDictionary
*
)
indic
){
self
.
window
=
[[
UIApplication
sharedApplication
].
windows
lastObject
];
self
.
window
=
[[
UIApplication
sharedApplication
].
windows
lastObject
];
NSString
*
pickerConfirmBtnText
=
indic
[
@"pickerConfirmBtnText"
];
NSString
*
pickerConfirmBtnText
=
indic
[
@"pickerConfirmBtnText"
];
NSString
*
pickerCancelBtnText
=
indic
[
@"pickerCancelBtnText"
];
NSString
*
pickerCancelBtnText
=
indic
[
@"pickerCancelBtnText"
];
...
@@ -56,7 +56,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
...
@@ -56,7 +56,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
}];
}];
if
([[
UIDevice
currentDevice
].
systemVersion
doubleValue
]
>=
9
.
0
)
{
if
([[
UIDevice
currentDevice
].
systemVersion
doubleValue
]
>=
9
.
0
)
{
self
.
height
=
250
;
self
.
height
=
250
;
}
else
{
}
else
{
self
.
height
=
220
;
self
.
height
=
220
;
...
...
package.json
View file @
cf30fbc6
{
{
"name"
:
"react-native-picker"
,
"name"
:
"react-native-picker"
,
"version"
:
"4.0.1
0
"
,
"version"
:
"4.0.1
1
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
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