Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-native-pickers",
"name": "react-native-pickers-1",
"version": "2.0.0",
"description": "纯JS实现的React-Native 各种弹窗、日期选择控件、地址选择控件等",
"main": "index.js",
Expand All @@ -22,4 +22,4 @@
],
"author": "iBerHK",
"license": "ISC"
}
}
23 changes: 13 additions & 10 deletions view/AreaPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ class AreaPicker extends BaseDialog {
let province = [];
let city = [];
let county = [];
let firstCity = null;
let firstCountry = null;
let firstCity = firstCountry = '';
let areaData = this.getAreaData();
areaData.map((pitem) => {
for (let pname in pitem) {
province.push(pname)
if (pname == this.props.selectedValue[0]) {
pitem[pname].map(citem => {
if (this.props.selectedValue[1] && pname == this.props.selectedValue[0]) {
pitem[pname] && pitem[pname].map(citem => {
for (let cname in citem) {
if (firstCity == null) {
if (!firstCity) {
firstCity = cname;
}
city.push(cname);
if (cname == this.props.selectedValue[1]) {
if (this.props.selectedValue[2] && cname == this.props.selectedValue[1]) {
county = citem[cname];
if (firstCountry == null) {
if (!firstCountry) {
firstCountry = citem[cname][0];
}
}
Expand All @@ -90,17 +89,21 @@ class AreaPicker extends BaseDialog {
}
});

if (county.indexOf(this.props.selectedValue[2]) == -1) {
if (this.props.selectedValue[2] && county.indexOf(this.props.selectedValue[2]) == -1 && firstCountry) {
this.props.selectedValue[2] = firstCountry;
}

if (county.length == 0 && firstCity != null) {
if (this.props.selectedValue[1] && city.indexOf(this.props.selectedValue[1]) == -1 && firstCity) {
this.props.selectedValue[1] = firstCity;
return this.formatPickerData();
}

let pickerData = [province]
city.length && pickerData.push(city)
county.length && pickerData.push(county)

return {
pickerData: [province, city, county], visible: true
pickerData, visible: true
};
}

Expand Down
6 changes: 3 additions & 3 deletions view/PickerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class PickerView extends BaseComponent {
</Animated.View>
<View style={{ position: 'absolute', width: this.props.itemWidth, height: this.mOnePixel, top: this.props.itemHeight * 4 / 2, backgroundColor: '#E8EEF0' }} />
<View style={{ position: 'absolute', width: this.props.itemWidth, height: this.mOnePixel, top: this.props.itemHeight * 6 / 2, backgroundColor: '#E8EEF0' }} />
<Svg
{/*<Svg
onStartShouldSetResponder={() => {
return false;
}}
Expand Down Expand Up @@ -333,12 +333,12 @@ class PickerView extends BaseComponent {
fill="url(#grad)"
clipPath="url(#clip)"
/>
</Svg>
</Svg>*/}
<View style={{ width: this.mScreenWidth, height: this.getSize(15), bottom: 0, backgroundColor: '#ffffff', position: 'absolute' }} />
</View>

</View>
}
}

export default PickerView;
export default PickerView;