Skip to content

Commit

Permalink
彻底解决PickerIOS的警告问题,并兼容老的RN版本
Browse files Browse the repository at this point in the history
  • Loading branch information
yz1311 committed Apr 2, 2021
1 parent f7482a9 commit c3be418
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
11 changes: 10 additions & 1 deletion WheelCurvedPicker.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
import React from 'react';
import {
View,
NativeModules
} from 'react-native';
import PickerIOS from "./src/PickerIOS";

module.exports = View;
let PickerIOSComponent = null;
if("RNWPicker" in NativeModules.UIManager) {
PickerIOSComponent = PickerIOS;
} else {
PickerIOSComponent = require('react-native').PickerIOS;
}

module.exports = PickerIOSComponent;
15 changes: 1 addition & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

import React,{} from 'react';

import {
Platform,
NativeModules
} from 'react-native';

import WheelCurvedPicker from './WheelCurvedPicker'

import PickerHeader from './src/PickerHeader';
Expand All @@ -19,14 +14,6 @@ import DatePicker from './src/DatePicker';

import DateRangePicker from './src/DateRangePicker';

let PickerIOS = null;
if(Platform.OS === 'ios') {
if(NativeModules.RNWPicker) {
PickerIOS = require('./src/PickerIOS').default;
} else {
PickerIOS = require('react-native').PickerIOS;
}
}

export {
PickerHeader,
Expand All @@ -36,4 +23,4 @@ export {
DateRangePicker
};

export default (Platform.OS === 'ios' ? PickerIOS : WheelCurvedPicker);
export default WheelCurvedPicker;
8 changes: 1 addition & 7 deletions src/CommonPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ import React, {Component} from 'react';
import {
StyleSheet,
View,
Text,
Animated,
Platform,
Dimensions,
PickerIOS,
ViewPropTypes, StyleProp, ViewStyle, TextStyle,
} from 'react-native';
//@ts-ignore
import WheelCurvedPicker from '../WheelCurvedPicker';
import PickerHeader from './PickerHeader';
import {ICommonPickerProps as IProps} from '../types';
import {isIPhoneX} from './utils';

const Picker = (Platform.OS === 'ios' ? PickerIOS : WheelCurvedPicker)
const Picker = WheelCurvedPicker;
let PickerItem = Picker.Item;


Expand Down

0 comments on commit c3be418

Please sign in to comment.