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
f807257e
Commit
f807257e
authored
Oct 19, 2016
by
xwenliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new feature wheelFlex and fix #79
parent
cf10cc34
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
340 additions
and
79 deletions
+340
-79
README.md
README.md
+1
-0
android/src/main/java/com/beefe/picker/PickerViewModule.java
android/src/main/java/com/beefe/picker/PickerViewModule.java
+143
-51
android/src/main/java/com/beefe/picker/view/PickerViewAlone.java
.../src/main/java/com/beefe/picker/view/PickerViewAlone.java
+22
-8
android/src/main/java/com/beefe/picker/view/PickerViewLinkage.java
...rc/main/java/com/beefe/picker/view/PickerViewLinkage.java
+64
-11
ios/RCTBEEPickerManager/BzwPicker.h
ios/RCTBEEPickerManager/BzwPicker.h
+3
-1
ios/RCTBEEPickerManager/BzwPicker.m
ios/RCTBEEPickerManager/BzwPicker.m
+104
-6
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
+2
-1
package.json
package.json
+1
-1
No files found.
README.md
View file @
f807257e
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
|pickerTitleColor | |array |[20, 20, 20, 1]) |
|pickerTitleColor | |array |[20, 20, 20, 1]) |
|pickerToolBarBg | |array |[232, 232, 232, 1] |
|pickerToolBarBg | |array |[232, 232, 232, 1] |
|pickerBg | |array |[196, 199, 206, 1] |
|pickerBg | |array |[196, 199, 206, 1] |
|wheelFlex | |array |[2, 1, 1] |
|pickerData | |array | |
|pickerData | |array | |
|selectedValue | |array | |
|selectedValue | |array | |
|onPickerConfirm | |function| |
|onPickerConfirm | |function| |
...
...
android/src/main/java/com/beefe/picker/PickerViewModule.java
View file @
f807257e
...
@@ -29,14 +29,20 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
...
@@ -29,14 +29,20 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
static
android
.
R
.
attr
.
textSize
;
/**
/**
* Author: heng <a href="https://github.com/shexiaoheng"/>
* Author: heng <a href="https://github.com/shexiaoheng"/>
*
*
<p>
* Created by heng on 16/9/5.
* Created by heng on 16/9/5.
*
*
<p>
* Edited by heng on 16/9/22.
* Edited by heng on 16/9/22.
* 1. PopupWindow height : full screen -> assignation
* 1. PopupWindow height : full screen -> assignation
* 2. Added pickerToolBarHeight support
* 2. Added pickerToolBarHeight support
*
* Edited by heng on 2016/10/19.
* 1. Added weights support
* 2. Fixed return data bug
*/
*/
public
class
PickerViewModule
extends
ReactContextBaseJavaModule
{
public
class
PickerViewModule
extends
ReactContextBaseJavaModule
{
...
@@ -45,14 +51,22 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -45,14 +51,22 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
private
static
final
String
PICKER_DATA
=
"pickerData"
;
private
static
final
String
PICKER_DATA
=
"pickerData"
;
private
static
final
String
SELECTED_VALUE
=
"selectedValue"
;
private
static
final
String
SELECTED_VALUE
=
"selectedValue"
;
private
static
final
String
IS_LOOP
=
"isLoop"
;
private
static
final
String
IS_LOOP
=
"isLoop"
;
private
static
final
String
WEIGHTS
=
"wheelFlex"
;
private
static
final
String
PICKER_BG_COLOR
=
"pickerBg"
;
private
static
final
String
PICKER_BG_COLOR
=
"pickerBg"
;
private
static
final
String
TEXT_BAR_COLOR
=
"pickerToolBarBg"
;
private
static
final
String
TEXT_BAR_COLOR
=
"pickerToolBarBg"
;
private
static
final
String
TEXT_BAR_HEIGHT
=
"pickerToolBarHeight"
;
private
static
final
String
TEXT_BAR_HEIGHT
=
"pickerToolBarHeight"
;
private
static
final
String
CONFIRM_TEXT
=
"pickerConfirmBtnText"
;
private
static
final
String
CONFIRM_TEXT
=
"pickerConfirmBtnText"
;
private
static
final
String
CONFIRM_TEXT_COLOR
=
"pickerConfirmBtnColor"
;
private
static
final
String
CONFIRM_TEXT_COLOR
=
"pickerConfirmBtnColor"
;
private
static
final
String
CANCEL_TEXT
=
"pickerCancelBtnText"
;
private
static
final
String
CANCEL_TEXT
=
"pickerCancelBtnText"
;
private
static
final
String
CANCEL_TEXT_COLOR
=
"pickerCancelBtnColor"
;
private
static
final
String
CANCEL_TEXT_COLOR
=
"pickerCancelBtnColor"
;
private
static
final
String
TITLE_TEXT
=
"pickerTitleText"
;
private
static
final
String
TITLE_TEXT
=
"pickerTitleText"
;
private
static
final
String
TITLE_TEXT_COLOR
=
"pickerTitleColor"
;
private
static
final
String
TITLE_TEXT_COLOR
=
"pickerTitleColor"
;
...
@@ -72,23 +86,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -72,23 +86,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
private
String
cancelText
;
private
String
cancelText
;
private
String
titleText
;
private
String
titleText
;
private
double
[]
weights
;
private
int
[]
pickerColor
=
new
int
[
4
];
private
int
[]
pickerColor
=
new
int
[
4
];
private
int
[]
barBgColor
=
new
int
[
4
];
private
int
[]
barBgColor
=
new
int
[
4
];
private
int
[]
confirmTextColor
=
new
int
[
4
];
private
int
[]
confirmTextColor
=
new
int
[
4
];
private
int
[]
cancelTextColor
=
new
int
[
4
];
private
int
[]
cancelTextColor
=
new
int
[
4
];
private
int
[]
titleTextColor
=
new
int
[
4
];
private
int
[]
titleTextColor
=
new
int
[
4
];
private
ArrayList
<
String
>
curSelectedList
=
new
ArrayList
<>();
private
ArrayList
<
String
>
returnData
;
private
RelativeLayout
barLayout
;
private
TextView
cancelTV
;
private
TextView
titleTV
;
private
TextView
confirmTV
;
private
PickerViewLinkage
pickerViewLinkage
;
private
PickerViewAlone
pickerViewAlone
;
private
int
pickerViewHeight
;
private
int
curStatus
;
private
int
barViewHeight
;
public
PickerViewModule
(
ReactApplicationContext
reactContext
)
{
public
PickerViewModule
(
ReactApplicationContext
reactContext
)
{
super
(
reactContext
);
super
(
reactContext
);
...
@@ -104,13 +112,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -104,13 +112,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
Activity
activity
=
getCurrentActivity
();
Activity
activity
=
getCurrentActivity
();
if
(
activity
!=
null
&&
options
.
hasKey
(
PICKER_DATA
))
{
if
(
activity
!=
null
&&
options
.
hasKey
(
PICKER_DATA
))
{
view
=
activity
.
getLayoutInflater
().
inflate
(
R
.
layout
.
popup_picker_view
,
null
);
view
=
activity
.
getLayoutInflater
().
inflate
(
R
.
layout
.
popup_picker_view
,
null
);
barLayout
=
(
RelativeLayout
)
view
.
findViewById
(
R
.
id
.
barLayout
);
RelativeLayout
barLayout
=
(
RelativeLayout
)
view
.
findViewById
(
R
.
id
.
barLayout
);
cancelTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
cancel
);
TextView
cancelTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
cancel
);
titleTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
title
);
TextView
titleTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
title
);
confirmTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
confirm
);
TextView
confirmTV
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
confirm
);
pickerViewLinkage
=
(
PickerViewLinkage
)
view
.
findViewById
(
R
.
id
.
pickerViewLinkage
);
final
PickerViewLinkage
pickerViewLinkage
=
(
PickerViewLinkage
)
view
.
findViewById
(
R
.
id
.
pickerViewLinkage
);
pickerViewAlone
=
(
PickerViewAlone
)
view
.
findViewById
(
R
.
id
.
pickerViewAlone
);
final
PickerViewAlone
pickerViewAlone
=
(
PickerViewAlone
)
view
.
findViewById
(
R
.
id
.
pickerViewAlone
);
int
barViewHeight
;
if
(
options
.
hasKey
(
TEXT_BAR_HEIGHT
))
{
if
(
options
.
hasKey
(
TEXT_BAR_HEIGHT
))
{
try
{
try
{
barViewHeight
=
options
.
getInt
(
TEXT_BAR_HEIGHT
);
barViewHeight
=
options
.
getInt
(
TEXT_BAR_HEIGHT
);
...
@@ -128,10 +137,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -128,10 +137,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
if
(
options
.
hasKey
(
TEXT_BAR_COLOR
))
{
if
(
options
.
hasKey
(
TEXT_BAR_COLOR
))
{
ReadableArray
array
=
options
.
getArray
(
TEXT_BAR_COLOR
);
ReadableArray
array
=
options
.
getArray
(
TEXT_BAR_COLOR
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
if
(
i
==
3
)
{
switch
(
i
)
{
barBgColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
case
0
:
}
else
{
case
1
:
case
2
:
barBgColor
[
i
]
=
array
.
getInt
(
i
);
barBgColor
[
i
]
=
array
.
getInt
(
i
);
break
;
case
3
:
barBgColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
break
;
default
:
break
;
}
}
}
}
barLayout
.
setBackgroundColor
(
Color
.
argb
(
barBgColor
[
3
],
barBgColor
[
0
],
barBgColor
[
1
],
barBgColor
[
2
]));
barLayout
.
setBackgroundColor
(
Color
.
argb
(
barBgColor
[
3
],
barBgColor
[
0
],
barBgColor
[
1
],
barBgColor
[
2
]));
...
@@ -146,10 +162,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -146,10 +162,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
if
(
options
.
hasKey
(
CONFIRM_TEXT_COLOR
))
{
if
(
options
.
hasKey
(
CONFIRM_TEXT_COLOR
))
{
ReadableArray
array
=
options
.
getArray
(
CONFIRM_TEXT_COLOR
);
ReadableArray
array
=
options
.
getArray
(
CONFIRM_TEXT_COLOR
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
if
(
i
==
3
)
{
switch
(
i
)
{
confirmTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
case
0
:
}
else
{
case
1
:
case
2
:
confirmTextColor
[
i
]
=
array
.
getInt
(
i
);
confirmTextColor
[
i
]
=
array
.
getInt
(
i
);
break
;
case
3
:
confirmTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
break
;
default
:
break
;
}
}
}
}
confirmTV
.
setTextColor
(
Color
.
argb
(
confirmTextColor
[
3
],
confirmTextColor
[
0
],
confirmTextColor
[
1
],
confirmTextColor
[
2
]));
confirmTV
.
setTextColor
(
Color
.
argb
(
confirmTextColor
[
3
],
confirmTextColor
[
0
],
confirmTextColor
[
1
],
confirmTextColor
[
2
]));
...
@@ -157,6 +180,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -157,6 +180,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
confirmTV
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
confirmTV
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
switch
(
curStatus
){
case
0
:
returnData
=
pickerViewAlone
.
getSelectedData
();
break
;
case
1
:
returnData
=
pickerViewLinkage
.
getSelectedData
();
break
;
}
commonEvent
(
EVENT_KEY_CONFIRM
);
commonEvent
(
EVENT_KEY_CONFIRM
);
hide
();
hide
();
}
}
...
@@ -170,10 +201,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -170,10 +201,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
if
(
options
.
hasKey
(
TITLE_TEXT_COLOR
))
{
if
(
options
.
hasKey
(
TITLE_TEXT_COLOR
))
{
ReadableArray
array
=
options
.
getArray
(
TITLE_TEXT_COLOR
);
ReadableArray
array
=
options
.
getArray
(
TITLE_TEXT_COLOR
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
if
(
i
==
3
)
{
switch
(
i
)
{
titleTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
case
0
:
}
else
{
case
1
:
case
2
:
titleTextColor
[
i
]
=
array
.
getInt
(
i
);
titleTextColor
[
i
]
=
array
.
getInt
(
i
);
break
;
case
3
:
titleTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
break
;
default
:
break
;
}
}
}
}
titleTV
.
setTextColor
(
Color
.
argb
(
titleTextColor
[
3
],
titleTextColor
[
0
],
titleTextColor
[
1
],
titleTextColor
[
2
]));
titleTV
.
setTextColor
(
Color
.
argb
(
titleTextColor
[
3
],
titleTextColor
[
0
],
titleTextColor
[
1
],
titleTextColor
[
2
]));
...
@@ -186,10 +224,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -186,10 +224,17 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
if
(
options
.
hasKey
(
CANCEL_TEXT_COLOR
))
{
if
(
options
.
hasKey
(
CANCEL_TEXT_COLOR
))
{
ReadableArray
array
=
options
.
getArray
(
CANCEL_TEXT_COLOR
);
ReadableArray
array
=
options
.
getArray
(
CANCEL_TEXT_COLOR
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
if
(
i
==
3
)
{
switch
(
i
)
{
cancelTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
case
0
:
}
else
{
case
1
:
case
2
:
cancelTextColor
[
i
]
=
array
.
getInt
(
i
);
cancelTextColor
[
i
]
=
array
.
getInt
(
i
);
break
;
case
3
:
cancelTextColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
break
;
default
:
break
;
}
}
}
}
cancelTV
.
setTextColor
(
Color
.
argb
(
cancelTextColor
[
3
],
cancelTextColor
[
0
],
cancelTextColor
[
1
],
cancelTextColor
[
2
]));
cancelTV
.
setTextColor
(
Color
.
argb
(
cancelTextColor
[
3
],
cancelTextColor
[
0
],
cancelTextColor
[
1
],
cancelTextColor
[
2
]));
...
@@ -197,6 +242,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -197,6 +242,14 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
cancelTV
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
cancelTV
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
switch
(
curStatus
){
case
0
:
returnData
=
pickerViewAlone
.
getSelectedData
();
break
;
case
1
:
returnData
=
pickerViewLinkage
.
getSelectedData
();
break
;
}
commonEvent
(
EVENT_KEY_CANCEL
);
commonEvent
(
EVENT_KEY_CANCEL
);
hide
();
hide
();
}
}
...
@@ -206,6 +259,32 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -206,6 +259,32 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
isLoop
=
options
.
getBoolean
(
IS_LOOP
);
isLoop
=
options
.
getBoolean
(
IS_LOOP
);
}
}
if
(
options
.
hasKey
(
WEIGHTS
))
{
ReadableArray
array
=
options
.
getArray
(
WEIGHTS
);
weights
=
new
double
[
array
.
size
()];
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
switch
(
array
.
getType
(
i
).
name
())
{
case
"Number"
:
try
{
weights
[
i
]
=
array
.
getInt
(
i
);
}
catch
(
Exception
e
)
{
weights
[
i
]
=
array
.
getDouble
(
i
);
}
break
;
case
"String"
:
try
{
weights
[
i
]
=
Double
.
parseDouble
(
array
.
getString
(
i
));
}
catch
(
Exception
e
)
{
weights
[
i
]
=
1.0
;
}
break
;
default
:
weights
[
i
]
=
1.0
;
break
;
}
}
}
String
[]
selectValue
=
{};
String
[]
selectValue
=
{};
if
(
options
.
hasKey
(
SELECTED_VALUE
))
{
if
(
options
.
hasKey
(
SELECTED_VALUE
))
{
ReadableArray
array
=
options
.
getArray
(
SELECTED_VALUE
);
ReadableArray
array
=
options
.
getArray
(
SELECTED_VALUE
);
...
@@ -234,22 +313,31 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -234,22 +313,31 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
ReadableArray
array
=
options
.
getArray
(
PICKER_BG_COLOR
);
ReadableArray
array
=
options
.
getArray
(
PICKER_BG_COLOR
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
if
(
i
==
3
)
{
switch
(
i
)
{
pickerColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
case
0
:
}
else
{
case
1
:
case
2
:
pickerColor
[
i
]
=
array
.
getInt
(
i
);
pickerColor
[
i
]
=
array
.
getInt
(
i
);
break
;
case
3
:
pickerColor
[
i
]
=
(
int
)
(
array
.
getDouble
(
i
)
*
255
);
break
;
default
:
break
;
}
}
}
}
}
}
ReadableArray
pickerData
=
options
.
getArray
(
PICKER_DATA
);
ReadableArray
pickerData
=
options
.
getArray
(
PICKER_DATA
);
int
pickerViewHeight
;
String
name
=
pickerData
.
getType
(
0
).
name
();
String
name
=
pickerData
.
getType
(
0
).
name
();
switch
(
name
)
{
switch
(
name
)
{
case
"Map"
:
case
"Map"
:
curStatus
=
1
;
pickerViewLinkage
.
setVisibility
(
View
.
VISIBLE
);
pickerViewLinkage
.
setVisibility
(
View
.
VISIBLE
);
pickerViewAlone
.
setVisibility
(
View
.
GONE
);
pickerViewAlone
.
setVisibility
(
View
.
GONE
);
pickerViewLinkage
.
setPickerData
(
pickerData
,
curSelectedList
);
pickerViewLinkage
.
setPickerData
(
pickerData
,
weights
);
pickerViewLinkage
.
setIsLoop
(
isLoop
);
pickerViewLinkage
.
setIsLoop
(
isLoop
);
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
pickerViewLinkage
.
setBackgroundColor
(
Color
.
argb
(
pickerColor
[
3
],
pickerColor
[
0
],
pickerColor
[
1
],
pickerColor
[
2
]));
pickerViewLinkage
.
setBackgroundColor
(
Color
.
argb
(
pickerColor
[
3
],
pickerColor
[
0
],
pickerColor
[
1
],
pickerColor
[
2
]));
...
@@ -257,18 +345,19 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -257,18 +345,19 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
pickerViewLinkage
.
setOnSelectListener
(
new
OnSelectedListener
()
{
pickerViewLinkage
.
setOnSelectListener
(
new
OnSelectedListener
()
{
@Override
@Override
public
void
onSelected
(
ArrayList
<
String
>
selectedList
)
{
public
void
onSelected
(
ArrayList
<
String
>
selectedList
)
{
curSelectedList
=
selectedList
;
returnData
=
selectedList
;
commonEvent
(
EVENT_KEY_SELECTED
);
commonEvent
(
EVENT_KEY_SELECTED
);
}
}
});
});
pickerViewLinkage
.
setSelectValue
(
selectValue
,
curSelectedList
);
pickerViewLinkage
.
setSelectValue
(
selectValue
);
pickerViewHeight
=
pickerViewLinkage
.
getViewHeight
();
pickerViewHeight
=
pickerViewLinkage
.
getViewHeight
();
break
;
break
;
default
:
default
:
curStatus
=
0
;
pickerViewAlone
.
setVisibility
(
View
.
VISIBLE
);
pickerViewAlone
.
setVisibility
(
View
.
VISIBLE
);
pickerViewLinkage
.
setVisibility
(
View
.
GONE
);
pickerViewLinkage
.
setVisibility
(
View
.
GONE
);
pickerViewAlone
.
setPickerData
(
pickerData
,
curSelectedList
);
pickerViewAlone
.
setPickerData
(
pickerData
,
weights
);
pickerViewAlone
.
setIsLoop
(
isLoop
);
pickerViewAlone
.
setIsLoop
(
isLoop
);
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
if
(
options
.
hasKey
(
PICKER_BG_COLOR
))
{
pickerViewAlone
.
setBackgroundColor
(
Color
.
argb
(
pickerColor
[
3
],
pickerColor
[
0
],
pickerColor
[
1
],
pickerColor
[
2
]));
pickerViewAlone
.
setBackgroundColor
(
Color
.
argb
(
pickerColor
[
3
],
pickerColor
[
0
],
pickerColor
[
1
],
pickerColor
[
2
]));
...
@@ -277,25 +366,28 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -277,25 +366,28 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
pickerViewAlone
.
setOnSelectedListener
(
new
OnSelectedListener
()
{
pickerViewAlone
.
setOnSelectedListener
(
new
OnSelectedListener
()
{
@Override
@Override
public
void
onSelected
(
ArrayList
<
String
>
selectedList
)
{
public
void
onSelected
(
ArrayList
<
String
>
selectedList
)
{
curSelectedList
=
selectedList
;
returnData
=
selectedList
;
commonEvent
(
EVENT_KEY_SELECTED
);
commonEvent
(
EVENT_KEY_SELECTED
);
}
}
});
});
pickerViewAlone
.
setSelectValue
(
selectValue
,
curSelectedList
);
pickerViewAlone
.
setSelectValue
(
selectValue
);
pickerViewHeight
=
pickerViewAlone
.
getViewHeight
();
pickerViewHeight
=
pickerViewAlone
.
getViewHeight
();
break
;
break
;
}
}
if
(
popupWindow
==
null
)
{
if
(
popupWindow
==
null
)
{
int
height
=
barViewHeight
+
pickerViewHeight
;
int
height
=
barViewHeight
+
pickerViewHeight
;
popupWindow
=
new
PopupWindow
(
WindowManager
.
LayoutParams
.
MATCH_PARENT
,
height
);
popupWindow
=
new
PopupWindow
(
WindowManager
.
LayoutParams
.
MATCH_PARENT
,
height
);
popupWindow
.
setBackgroundDrawable
(
new
ColorDrawable
());
popupWindow
.
setBackgroundDrawable
(
new
ColorDrawable
());
popupWindow
.
setAnimationStyle
(
R
.
style
.
PopAnim
);
popupWindow
.
setAnimationStyle
(
R
.
style
.
PopAnim
);
}
popupWindow
.
setContentView
(
view
);
popupWindow
.
setContentView
(
view
);
popupWindow
.
showAtLocation
(
view
,
Gravity
.
BOTTOM
,
0
,
0
);
popupWindow
.
showAtLocation
(
view
,
Gravity
.
BOTTOM
,
0
,
0
);
}
else
{
popupWindow
.
dismiss
();
popupWindow
.
setContentView
(
view
);
popupWindow
.
showAtLocation
(
view
,
Gravity
.
BOTTOM
,
0
,
0
);
}
}
}
}
}
...
@@ -341,7 +433,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
...
@@ -341,7 +433,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
private
void
commonEvent
(
String
eventKey
)
{
private
void
commonEvent
(
String
eventKey
)
{
WritableMap
map
=
Arguments
.
createMap
();
WritableMap
map
=
Arguments
.
createMap
();
WritableArray
array
=
Arguments
.
createArray
();
WritableArray
array
=
Arguments
.
createArray
();
for
(
String
item
:
curSelectedList
)
{
for
(
String
item
:
returnData
)
{
array
.
pushString
(
item
);
array
.
pushString
(
item
);
}
}
map
.
putArray
(
eventKey
,
array
);
map
.
putArray
(
eventKey
,
array
);
...
...
android/src/main/java/com/beefe/picker/view/PickerViewAlone.java
View file @
f807257e
...
@@ -14,7 +14,7 @@ import java.util.Arrays;
...
@@ -14,7 +14,7 @@ import java.util.Arrays;
/**
/**
* Created by heng on 16/9/6.
* Created by heng on 16/9/6.
*
*
<p>
* Edited by heng on 16/10/09:
* Edited by heng on 16/10/09:
* 修复滚动后返回值错误的bug
* 修复滚动后返回值错误的bug
*/
*/
...
@@ -25,6 +25,8 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -25,6 +25,8 @@ public class PickerViewAlone extends LinearLayout {
private
OnSelectedListener
onSelectedListener
;
private
OnSelectedListener
onSelectedListener
;
private
ArrayList
<
String
>
curSelectedList
;
public
PickerViewAlone
(
Context
context
)
{
public
PickerViewAlone
(
Context
context
)
{
super
(
context
);
super
(
context
);
init
(
context
);
init
(
context
);
...
@@ -44,10 +46,11 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -44,10 +46,11 @@ public class PickerViewAlone extends LinearLayout {
this
.
onSelectedListener
=
listener
;
this
.
onSelectedListener
=
listener
;
}
}
public
void
setPickerData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
)
{
public
void
setPickerData
(
ReadableArray
array
,
double
[]
weights
)
{
curSelectedList
=
new
ArrayList
<>();
switch
(
array
.
getType
(
0
).
name
())
{
switch
(
array
.
getType
(
0
).
name
())
{
case
"Array"
:
case
"Array"
:
setMultipleData
(
array
,
curSelectedList
);
setMultipleData
(
array
,
curSelectedList
,
weights
);
break
;
break
;
default
:
default
:
setAloneData
(
array
,
curSelectedList
);
setAloneData
(
array
,
curSelectedList
);
...
@@ -55,6 +58,10 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -55,6 +58,10 @@ public class PickerViewAlone extends LinearLayout {
}
}
}
}
public
ArrayList
<
String
>
getSelectedData
(){
return
this
.
curSelectedList
;
}
private
void
setAloneData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
)
{
private
void
setAloneData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
)
{
ArrayList
<
String
>
values
=
arrayToList
(
array
);
ArrayList
<
String
>
values
=
arrayToList
(
array
);
final
LoopView
loopView
=
new
LoopView
(
getContext
());
final
LoopView
loopView
=
new
LoopView
(
getContext
());
...
@@ -81,7 +88,7 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -81,7 +88,7 @@ public class PickerViewAlone extends LinearLayout {
pickerViewAloneLayout
.
addView
(
loopView
);
pickerViewAloneLayout
.
addView
(
loopView
);
}
}
private
void
setMultipleData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
)
{
private
void
setMultipleData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
,
double
[]
weights
)
{
final
String
[]
selectedItems
=
new
String
[
array
.
size
()];
final
String
[]
selectedItems
=
new
String
[
array
.
size
()];
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
switch
(
array
.
getType
(
i
).
name
())
{
switch
(
array
.
getType
(
i
).
name
())
{
...
@@ -89,9 +96,16 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -89,9 +96,16 @@ public class PickerViewAlone extends LinearLayout {
ReadableArray
childArray
=
array
.
getArray
(
i
);
ReadableArray
childArray
=
array
.
getArray
(
i
);
ArrayList
<
String
>
values
=
arrayToList
(
childArray
);
ArrayList
<
String
>
values
=
arrayToList
(
childArray
);
final
LoopView
loopView
=
new
LoopView
(
getContext
());
final
LoopView
loopView
=
new
LoopView
(
getContext
());
LayoutParams
params
=
new
LayoutParams
(
LayoutParams
params
=
new
LayoutParams
(
0
,
LayoutParams
.
MATCH_PARENT
);
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
MATCH_PARENT
);
if
(
weights
!=
null
)
{
if
(
i
<
weights
.
length
)
{
params
.
weight
=
(
float
)
weights
[
i
];
}
else
{
params
.
weight
=
1.0f
;
params
.
weight
=
1.0f
;
}
}
else
{
params
.
weight
=
1.0f
;
}
loopView
.
setLayoutParams
(
params
);
loopView
.
setLayoutParams
(
params
);
loopView
.
setItems
(
values
);
loopView
.
setItems
(
values
);
loopView
.
setTag
(
i
);
loopView
.
setTag
(
i
);
...
@@ -130,7 +144,7 @@ public class PickerViewAlone extends LinearLayout {
...
@@ -130,7 +144,7 @@ public class PickerViewAlone extends LinearLayout {
}
}
}
}
public
void
setSelectValue
(
String
[]
selectValue
,
final
ArrayList
<
String
>
curSelectedList
)
{
public
void
setSelectValue
(
String
[]
selectValue
)
{
int
viewCount
=
pickerViewAloneLayout
.
getChildCount
();
int
viewCount
=
pickerViewAloneLayout
.
getChildCount
();
int
valueCount
=
selectValue
.
length
;
int
valueCount
=
selectValue
.
length
;
if
(
valueCount
<=
viewCount
)
{
if
(
valueCount
<=
viewCount
)
{
...
...
android/src/main/java/com/beefe/picker/view/PickerViewLinkage.java
View file @
f807257e
...
@@ -77,6 +77,8 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -77,6 +77,8 @@ public class PickerViewLinkage extends LinearLayout {
private
int
selectOneIndex
;
private
int
selectOneIndex
;
private
int
selectTwoIndex
;
private
int
selectTwoIndex
;
private
ArrayList
<
String
>
curSelectedList
;
private
void
checkItems
(
LoopView
loopView
,
ArrayList
<
String
>
list
)
{
private
void
checkItems
(
LoopView
loopView
,
ArrayList
<
String
>
list
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
loopView
.
setItems
(
list
);
loopView
.
setItems
(
list
);
...
@@ -84,11 +86,57 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -84,11 +86,57 @@ public class PickerViewLinkage extends LinearLayout {
}
}
}
}
private
void
setWeights
(
double
[]
weights
)
{
LayoutParams
paramsOne
=
new
LayoutParams
(
0
,
LayoutParams
.
MATCH_PARENT
);
LayoutParams
paramsTwo
=
new
LayoutParams
(
0
,
LayoutParams
.
MATCH_PARENT
);
LayoutParams
paramsThree
=
new
LayoutParams
(
0
,
LayoutParams
.
MATCH_PARENT
);
switch
(
curRow
)
{
case
2
:
switch
(
weights
.
length
)
{
case
1
:
paramsOne
.
weight
=
(
float
)
weights
[
0
];
paramsTwo
.
weight
=
1.0f
;
break
;
default
:
paramsOne
.
weight
=
(
float
)
weights
[
0
];
paramsTwo
.
weight
=
(
float
)
weights
[
1
];
break
;
}
loopViewOne
.
setLayoutParams
(
paramsOne
);
loopViewTwo
.
setLayoutParams
(
paramsTwo
);
break
;
case
3
:
switch
(
weights
.
length
)
{
case
1
:
paramsOne
.
weight
=
(
float
)
weights
[
0
];
paramsTwo
.
weight
=
1.0f
;
paramsThree
.
weight
=
1.0f
;
break
;
case
2
:
paramsOne
.
weight
=
(
float
)
weights
[
0
];
paramsTwo
.
weight
=
(
float
)
weights
[
1
];
paramsThree
.
weight
=
1.0f
;
break
;
default
:
paramsOne
.
weight
=
(
float
)
weights
[
0
];
paramsTwo
.
weight
=
(
float
)
weights
[
1
];
paramsThree
.
weight
=
(
float
)
weights
[
2
];
break
;
}
loopViewOne
.
setLayoutParams
(
paramsOne
);
loopViewTwo
.
setLayoutParams
(
paramsTwo
);
loopViewThree
.
setLayoutParams
(
paramsThree
);
break
;
}
}
/**
/**
* ReadableArray getMap will remove the item.
* ReadableArray getMap will remove the item.
* <a href="https://github.com/facebook/react-native/issues/8557"></a>
* <a href="https://github.com/facebook/react-native/issues/8557"></a>
* */
*/
public
void
setPickerData
(
ReadableArray
array
,
final
ArrayList
<
String
>
curSelectedList
)
{
public
void
setPickerData
(
ReadableArray
array
,
double
[]
weights
)
{
curSelectedList
=
new
ArrayList
<>();
oneList
.
clear
();
oneList
.
clear
();
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
ReadableMap
map
=
array
.
getMap
(
i
);
ReadableMap
map
=
array
.
getMap
(
i
);
...
@@ -235,6 +283,9 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -235,6 +283,9 @@ public class PickerViewLinkage extends LinearLayout {
}
}
});
});
}
}
if
(
weights
!=
null
)
{
setWeights
(
weights
);
}
}
}
private
ArrayList
<
String
>
arrayToList
(
ReadableArray
array
)
{
private
ArrayList
<
String
>
arrayToList
(
ReadableArray
array
)
{
...
@@ -265,7 +316,7 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -265,7 +316,7 @@ public class PickerViewLinkage extends LinearLayout {
}
}
}
}
public
void
setSelectValue
(
String
[]
selectValue
,
final
ArrayList
<
String
>
curSelectedList
)
{
public
void
setSelectValue
(
String
[]
selectValue
)
{
if
(
curRow
<=
selectValue
.
length
)
{
if
(
curRow
<=
selectValue
.
length
)
{
String
[]
values
=
Arrays
.
copyOf
(
selectValue
,
curRow
);
String
[]
values
=
Arrays
.
copyOf
(
selectValue
,
curRow
);
selectValues
(
values
,
curSelectedList
);
selectValues
(
values
,
curSelectedList
);
...
@@ -275,7 +326,6 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -275,7 +326,6 @@ public class PickerViewLinkage extends LinearLayout {
selectOneLoop
(
selectValue
,
curSelectedList
);
selectOneLoop
(
selectValue
,
curSelectedList
);
switch
(
curRow
)
{
switch
(
curRow
)
{
case
3
:
case
3
:
twoList
.
clear
();
twoList
.
clear
();
getTwoListData
();
getTwoListData
();
loopViewTwo
.
setItems
(
twoList
);
loopViewTwo
.
setItems
(
twoList
);
...
@@ -305,7 +355,7 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -305,7 +355,7 @@ public class PickerViewLinkage extends LinearLayout {
twoList
.
clear
();
twoList
.
clear
();
getTwoListData
();
getTwoListData
();
selectTwoLoop
(
selectValue
,
curSelectedList
);
selectTwoLoop
(
selectValue
,
curSelectedList
);
threeList
.
clear
();
threeList
.
clear
();
...
@@ -419,9 +469,8 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -419,9 +469,8 @@ public class PickerViewLinkage extends LinearLayout {
/**
/**
* 获取第三个滚轮的值
* 获取第三个滚轮的值
* */
*/
private
void
getThreeListData
(){
private
void
getThreeListData
()
{
//{ NativeMap: {"b":[{"b1":[11,22,33,44]},{"b2":[55,66,77,88]},{"b3":[99,1010,1111,1212]}]} }
ReadableMap
childMap
=
data
.
get
(
selectOneIndex
).
getArray
(
oneList
.
get
(
selectOneIndex
)).
getMap
(
selectTwoIndex
);
ReadableMap
childMap
=
data
.
get
(
selectOneIndex
).
getArray
(
oneList
.
get
(
selectOneIndex
)).
getMap
(
selectTwoIndex
);
String
key
=
childMap
.
keySetIterator
().
nextKey
();
String
key
=
childMap
.
keySetIterator
().
nextKey
();
ReadableArray
sunArray
=
childMap
.
getArray
(
key
);
ReadableArray
sunArray
=
childMap
.
getArray
(
key
);
...
@@ -446,10 +495,14 @@ public class PickerViewLinkage extends LinearLayout {
...
@@ -446,10 +495,14 @@ public class PickerViewLinkage extends LinearLayout {
}
}
}
}
public
int
getViewHeight
()
{
public
int
getViewHeight
()
{
return
loopViewOne
.
getViewHeight
();
return
loopViewOne
.
getViewHeight
();
}
}
public
ArrayList
<
String
>
getSelectedData
(){
return
this
.
curSelectedList
;
}
public
void
setOnSelectListener
(
OnSelectedListener
listener
)
{
public
void
setOnSelectListener
(
OnSelectedListener
listener
)
{
this
.
onSelectedListener
=
listener
;
this
.
onSelectedListener
=
listener
;
}
}
...
...
ios/RCTBEEPickerManager/BzwPicker.h
View file @
f807257e
...
@@ -59,6 +59,8 @@ typedef void(^backBolock)(NSDictionary * );
...
@@ -59,6 +59,8 @@ typedef void(^backBolock)(NSDictionary * );
@property
(
strong
,
nonatomic
)
NSArray
*
selectValueArry
;
@property
(
strong
,
nonatomic
)
NSArray
*
selectValueArry
;
@property
(
strong
,
nonatomic
)
NSArray
*
weightArry
;
//创建一个下角标记录是第几行 来一进来判断第一行被选中 当进来的是关联两行的逻辑的时候 或者三行关联的时候取第二行做记录
//创建一个下角标记录是第几行 来一进来判断第一行被选中 当进来的是关联两行的逻辑的时候 或者三行关联的时候取第二行做记录
@property
(
assign
,
nonatomic
)
NSInteger
num
;
@property
(
assign
,
nonatomic
)
NSInteger
num
;
...
@@ -69,7 +71,7 @@ typedef void(^backBolock)(NSDictionary * );
...
@@ -69,7 +71,7 @@ typedef void(^backBolock)(NSDictionary * );
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
dic
:(
NSDictionary
*
)
dic
leftStr
:(
NSString
*
)
leftStr
centerStr
:(
NSString
*
)
centerStr
rightStr
:(
NSString
*
)
rightStr
topbgColor
:(
NSArray
*
)
topbgColor
bottombgColor
:(
NSArray
*
)
bottombgColor
leftbtnbgColor
:(
NSArray
*
)
leftbtnbgColor
rightbtnbgColor
:(
NSArray
*
)
rightbtnbgColor
centerbtnColor
:(
NSArray
*
)
centerbtnColor
selectValueArry
:(
NSArray
*
)
selectValueArry
;
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
dic
:(
NSDictionary
*
)
dic
leftStr
:(
NSString
*
)
leftStr
centerStr
:(
NSString
*
)
centerStr
rightStr
:(
NSString
*
)
rightStr
topbgColor
:(
NSArray
*
)
topbgColor
bottombgColor
:(
NSArray
*
)
bottombgColor
leftbtnbgColor
:(
NSArray
*
)
leftbtnbgColor
rightbtnbgColor
:(
NSArray
*
)
rightbtnbgColor
centerbtnColor
:(
NSArray
*
)
centerbtnColor
selectValueArry
:(
NSArray
*
)
selectValueArry
weightArry
:(
NSArray
*
)
weightArry
;
@end
@end
ios/RCTBEEPickerManager/BzwPicker.m
View file @
f807257e
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
@implementation
BzwPicker
@implementation
BzwPicker
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
dic
:(
NSDictionary
*
)
dic
leftStr
:(
NSString
*
)
leftStr
centerStr
:(
NSString
*
)
centerStr
rightStr
:(
NSString
*
)
rightStr
topbgColor
:(
NSArray
*
)
topbgColor
bottombgColor
:(
NSArray
*
)
bottombgColor
leftbtnbgColor
:(
NSArray
*
)
leftbtnbgColor
rightbtnbgColor
:(
NSArray
*
)
rightbtnbgColor
centerbtnColor
:(
NSArray
*
)
centerbtnColor
selectValueArry
:(
NSArray
*
)
selectValueArry
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
dic
:(
NSDictionary
*
)
dic
leftStr
:(
NSString
*
)
leftStr
centerStr
:(
NSString
*
)
centerStr
rightStr
:(
NSString
*
)
rightStr
topbgColor
:(
NSArray
*
)
topbgColor
bottombgColor
:(
NSArray
*
)
bottombgColor
leftbtnbgColor
:(
NSArray
*
)
leftbtnbgColor
rightbtnbgColor
:(
NSArray
*
)
rightbtnbgColor
centerbtnColor
:(
NSArray
*
)
centerbtnColor
selectValueArry
:(
NSArray
*
)
selectValueArry
weightArry
:(
NSArray
*
)
weightArry
{
{
self
=
[
super
initWithFrame
:
frame
];
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
if
(
self
)
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
self
.
provinceArray
=
[[
NSMutableArray
alloc
]
init
];
self
.
provinceArray
=
[[
NSMutableArray
alloc
]
init
];
self
.
cityArray
=
[[
NSMutableArray
alloc
]
init
];
self
.
cityArray
=
[[
NSMutableArray
alloc
]
init
];
self
.
selectValueArry
=
selectValueArry
;
self
.
selectValueArry
=
selectValueArry
;
self
.
weightArry
=
weightArry
;
self
.
pickerDic
=
dic
;
self
.
pickerDic
=
dic
;
self
.
leftStr
=
leftStr
;
self
.
leftStr
=
leftStr
;
self
.
rightStr
=
rightStr
;
self
.
rightStr
=
rightStr
;
...
@@ -186,20 +187,117 @@
...
@@ -186,20 +187,117 @@
if
(
_Correlation
)
{
if
(
_Correlation
)
{
if
([
_numberCorrela
isEqualToString
:
@"three"
])
{
if
([
_numberCorrela
isEqualToString
:
@"three"
])
{
if
(
self
.
weightArry
.
count
>=
3
)
{
NSString
*
onestr
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
firstObject
]];
NSString
*
twostr
=
[
NSString
stringWithFormat
:
@"%@"
,
self
.
weightArry
[
1
]];
NSString
*
threestr
=
[
NSString
stringWithFormat
:
@"%@"
,
self
.
weightArry
[
2
]];
double
totalweight
=
onestr
.
doubleValue
+
twostr
.
doubleValue
+
threestr
.
doubleValue
;
if
(
component
==
0
)
{
return
SCREEN_WIDTH
*
onestr
.
doubleValue
/
totalweight
;
}
else
if
(
component
==
1
){
return
SCREEN_WIDTH
*
twostr
.
doubleValue
/
totalweight
;
}
else
{
return
SCREEN_WIDTH
*
threestr
.
doubleValue
/
totalweight
;
}
}
else
{
if
(
self
.
weightArry
.
count
>
0
)
{
NSInteger
totalNum
=
self
.
weightArry
.
count
;
double
totalweight
=
0
;
for
(
NSInteger
i
=
0
;
i
<
self
.
weightArry
.
count
;
i
++
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
i
]];
totalweight
=
totalweight
+
str
.
doubleValue
;
}
if
(
component
>
totalNum
-
1
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
totalweight
+
3
-
totalNum
];
return
SCREEN_WIDTH
/
str
.
doubleValue
;;
}
else
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
totalweight
+
3
-
totalNum
];
return
SCREEN_WIDTH
*
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
component
]].
doubleValue
/
str
.
doubleValue
;
}
}
else
{
return
SCREEN_WIDTH
/
3
;
return
SCREEN_WIDTH
/
3
;
}
}
}
else
{
if
(
self
.
weightArry
.
count
>=
2
)
{
NSString
*
onestr
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
firstObject
]];
NSString
*
twostr
=
[
NSString
stringWithFormat
:
@"%@"
,
self
.
weightArry
[
1
]];
double
totalweight
=
onestr
.
doubleValue
+
twostr
.
doubleValue
;
if
(
component
==
0
)
{
return
SCREEN_WIDTH
*
onestr
.
doubleValue
/
totalweight
;
}
else
{
return
SCREEN_WIDTH
*
twostr
.
doubleValue
/
totalweight
;
}
}
else
{
}
else
{
if
(
self
.
weightArry
.
count
>
0
)
{
double
twonum
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
firstObject
]].
doubleValue
;
if
(
component
==
0
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
twonum
+
1
];
return
SCREEN_WIDTH
*
twonum
/
str
.
doubleValue
;
}
else
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
twonum
+
1
];
return
SCREEN_WIDTH
/
str
.
doubleValue
;
}
}
else
{
return
SCREEN_WIDTH
/
2
;
return
SCREEN_WIDTH
/
2
;
}
}
}
}
}
else
{
}
else
{
if
(
_noArryElementBool
)
{
if
(
_noArryElementBool
)
{
//表示一个数组 特殊情况
//表示一个数组 特殊情况
return
SCREEN_WIDTH
;
return
SCREEN_WIDTH
;
}
else
{
if
(
self
.
weightArry
.
count
>=
self
.
dataDry
.
count
)
{
double
totalweight
=
0
;
for
(
NSInteger
i
=
0
;
i
<
self
.
dataDry
.
count
;
i
++
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
i
]];
totalweight
=
totalweight
+
str
.
doubleValue
;
}
NSString
*
comStr
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
component
]];
return
SCREEN_WIDTH
*
comStr
.
doubleValue
/
totalweight
;
}
else
{
if
(
self
.
weightArry
.
count
>
0
)
{
NSInteger
totalNum
=
self
.
weightArry
.
count
;
double
totalweight
=
0
;
for
(
NSInteger
i
=
0
;
i
<
self
.
weightArry
.
count
;
i
++
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
i
]];
totalweight
=
totalweight
+
str
.
doubleValue
;
}
if
(
component
>
totalNum
-
1
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
totalweight
+
self
.
dataDry
.
count
-
totalNum
];
return
SCREEN_WIDTH
/
str
.
doubleValue
;
}
else
{
}
else
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%f"
,
totalweight
+
self
.
dataDry
.
count
-
totalNum
];
return
SCREEN_WIDTH
*
[
NSString
stringWithFormat
:
@"%@"
,[
self
.
weightArry
objectAtIndex
:
component
]].
doubleValue
/
str
.
doubleValue
;
}
}
else
{
return
SCREEN_WIDTH
/
self
.
dataDry
.
count
;
return
SCREEN_WIDTH
/
self
.
dataDry
.
count
;
}
}
}
}
}
}
}
}
-
(
void
)
pickerView
:(
UIPickerView
*
)
pickerView
didSelectRow
:(
NSInteger
)
row
inComponent
:(
NSInteger
)
component
{
-
(
void
)
pickerView
:(
UIPickerView
*
)
pickerView
didSelectRow
:(
NSInteger
)
row
inComponent
:(
NSInteger
)
component
{
...
...
ios/RCTBEEPickerManager/RCTBEEPickerManager.m
View file @
f807257e
...
@@ -60,6 +60,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
...
@@ -60,6 +60,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
NSArray
*
pickerToolBarBg
=
indic
[
@"pickerToolBarBg"
];
NSArray
*
pickerToolBarBg
=
indic
[
@"pickerToolBarBg"
];
NSArray
*
pickerBg
=
indic
[
@"pickerBg"
];
NSArray
*
pickerBg
=
indic
[
@"pickerBg"
];
NSArray
*
selectArry
=
indic
[
@"selectedValue"
];
NSArray
*
selectArry
=
indic
[
@"selectedValue"
];
NSArray
*
weightArry
=
indic
[
@"wheelFlex"
];
id
pickerData
=
indic
[
@"pickerData"
];
id
pickerData
=
indic
[
@"pickerData"
];
...
@@ -78,7 +79,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
...
@@ -78,7 +79,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
}];
}];
self
.
pick
=
[[
BzwPicker
alloc
]
initWithFrame
:
CGRectMake
(
0
,
SCREEN_HEIGHT
,
SCREEN_WIDTH
,
250
)
dic
:
dataDic
leftStr
:
pickerCancelBtnText
centerStr
:
pickerTitleText
rightStr
:
pickerConfirmBtnText
topbgColor
:
pickerToolBarBg
bottombgColor
:
pickerBg
leftbtnbgColor
:
pickerCancelBtnColor
rightbtnbgColor
:
pickerConfirmBtnColor
centerbtnColor
:
pickerTitleColor
selectValueArry
:
selectArry
];
self
.
pick
=
[[
BzwPicker
alloc
]
initWithFrame
:
CGRectMake
(
0
,
SCREEN_HEIGHT
,
SCREEN_WIDTH
,
250
)
dic
:
dataDic
leftStr
:
pickerCancelBtnText
centerStr
:
pickerTitleText
rightStr
:
pickerConfirmBtnText
topbgColor
:
pickerToolBarBg
bottombgColor
:
pickerBg
leftbtnbgColor
:
pickerCancelBtnColor
rightbtnbgColor
:
pickerConfirmBtnColor
centerbtnColor
:
pickerTitleColor
selectValueArry
:
selectArry
weightArry
:
weightArry
];
_pick
.
bolock
=^
(
NSDictionary
*
backinfoArry
){
_pick
.
bolock
=^
(
NSDictionary
*
backinfoArry
){
...
...
package.json
View file @
f807257e
{
{
"name"
:
"react-native-picker"
,
"name"
:
"react-native-picker"
,
"version"
:
"4.0.
5
"
,
"version"
:
"4.0.
6
"
,
"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