react-native-wheel-pick 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,6 +24,8 @@ npm install @react-native-picker/picker --save-dev --legacy-peer-deps
24
24
  npm install @react-native-community/datetimepicker --save-dev --legacy-peer-deps
25
25
  npx pod-install
26
26
 
27
+ npx react-native start --reset-cache // clear cache
28
+
27
29
  npx react-native run-ios // re-build native-code
28
30
  npx react-native run-android // re-build native-code for gradle
29
31
  ```
@@ -60,6 +62,9 @@ onDateChange={(date: Date) => { console.log(date) }}
60
62
  ## More Example
61
63
 
62
64
  ```jsx
65
+ // Set Text Color
66
+ <Picker textColor="red" />
67
+
63
68
  // DatePicker set default select date
64
69
  <DatePicker
65
70
  style={{ height: 215, width: 300 }}
@@ -77,20 +82,19 @@ onDateChange={(date: Date) => { console.log(date) }}
77
82
 
78
83
  ```
79
84
  ```jsx
80
- // pickerData also support array of object. (Optional)
85
+ // pickerData also support array of object. (Optional Way)
81
86
 
82
- // Way 1
87
+ // Normal Way
83
88
  <Picker
84
89
  selectedValue='item4'
85
90
  pickerData={['item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7']}
86
91
  onValueChange={value => { console.log(value) }}
87
92
  />
88
93
 
89
- // Optional Way 2
94
+ // Optional Way
90
95
  // `label` only use for show Text to UI.
91
96
  // You cannot get `label` from onValueChange
92
97
  <Picker
93
- style={{ backgroundColor: 'white', width: 300, height: 215 }}
94
98
  selectedValue='5765387680'
95
99
  pickerData={[
96
100
  { value : '5765387677', label : 'item1' },
@@ -109,7 +113,6 @@ onDateChange={(date: Date) => { console.log(date) }}
109
113
  // These is special props for Android. (iOS not work)
110
114
  // You can also use these props for DatePicker, too.
111
115
  <Picker
112
- textColor='red'
113
116
  textSize={20}
114
117
 
115
118
  selectTextColor='green'
@@ -139,6 +142,18 @@ You can sponsor me
139
142
  OR you can fork this project instead.
140
143
 
141
144
  ## Release Note
145
+ ### 1.2.3 (Feb 15 2024)
146
+ - Fix state is not updating after onValueChange in Picker Component. Thanks to [@spasma
147
+ ](https://github.com/TronNatthakorn/react-native-wheel-pick/issues/52)
148
+ - Test on React Native Version 0.77
149
+
150
+ [Android]
151
+ - Support [UIManager New Architecture of React Native](https://github.com/reactwg/react-native-new-architecture/discussions/201)
152
+ - Use Handler for fix 23 index problem. Thanks to [@mykhailoperemitko](https://github.com/TronNatthakorn/react-native-wheel-pick/issues/44) [@A-ANing](https://github.com/A-ANing)
153
+
154
+ ### 1.2.2 (June 7 2023)
155
+ [iOS]
156
+ - Now iOS can use `textColor`, too. [Add missing color option for iOS](https://github.com/TronNatthakorn/react-native-wheel-pick/pull/38) [@aurotones](https://github.com/aurotones)
142
157
 
143
158
  ### 1.2.1 (June 4 2023)
144
159
  - Fix typescript warning
@@ -6,9 +6,25 @@ buildscript {
6
6
 
7
7
  apply plugin: 'com.android.library'
8
8
 
9
+ def isNewArchitectureEnabled() {
10
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
11
+ }
12
+
13
+ if (isNewArchitectureEnabled()) {
14
+ apply plugin: 'com.facebook.react'
15
+ }
16
+
9
17
  android {
10
18
  compileSdkVersion 33
11
19
  namespace 'com.tron'
20
+
21
+ defaultConfig {
22
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
23
+ }
24
+
25
+ buildFeatures {
26
+ buildConfig true
27
+ }
12
28
  }
13
29
 
14
30
  dependencies {
@@ -20,6 +20,11 @@ import com.facebook.react.uimanager.events.Event;
20
20
  import com.facebook.react.uimanager.events.EventDispatcher;
21
21
  import com.facebook.react.uimanager.events.RCTEventEmitter;
22
22
 
23
+ import com.facebook.react.uimanager.UIManagerHelper;
24
+
25
+ // UIManagerType;
26
+ import com.facebook.react.uimanager.common.UIManagerType;
27
+
23
28
  import java.util.Date;
24
29
  import java.util.List;
25
30
 
@@ -35,7 +40,13 @@ public class ReactWheelCurvedPicker extends WheelPicker {
35
40
 
36
41
  public ReactWheelCurvedPicker(ReactContext reactContext) {
37
42
  super(reactContext);
38
- mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
43
+
44
+ if(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
45
+ mEventDispatcher = (UIManagerHelper.getUIManager(reactContext, 1 /** UIManagerType */)).getEventDispatcher();
46
+ } else {
47
+ mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
48
+ }
49
+
39
50
  setOnWheelChangeListener(new OnWheelChangeListener() {
40
51
  @Override
41
52
  public void onWheelScrolled(int offset) {
@@ -1,6 +1,7 @@
1
1
  package com.tron;
2
2
 
3
3
  import android.graphics.Color;
4
+ import android.os.Handler;
4
5
 
5
6
  import com.aigestudio.wheelpicker.WheelPicker;
6
7
  import com.facebook.react.bridge.ReadableArray;
@@ -84,8 +85,18 @@ public class ReactWheelCurvedPickerManager extends SimpleViewManager<ReactWheelC
84
85
  //if (picker != null && picker.getState() == WheelPicker.SCROLL_STATE_IDLE) {
85
86
  // Log.d("Index from React", index + "");
86
87
  if (picker != null) {
87
- picker.setSelectedItemPosition(index);
88
- picker.invalidate();
88
+ // picker.setSelectedItemPosition(index);
89
+ // picker.invalidate();
90
+
91
+ final Handler handler = new Handler();
92
+
93
+ handler.post(new Runnable() {
94
+ @Override
95
+ public void run() {
96
+ picker.setSelectedItemPosition(index);
97
+ picker.invalidate();
98
+ }
99
+ });
89
100
  }
90
101
  }
91
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wheel-pick",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "React native wheel picker iOS style with android.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/picker.js CHANGED
@@ -45,6 +45,12 @@ export default class Picker extends Component {
45
45
  this.props.onValueChange(selectedValue);
46
46
  };
47
47
 
48
+ componentDidUpdate(prevProps) {
49
+ if (prevProps.selectedValue !== this.props.selectedValue) {
50
+ this.setState({ selectedValue: this.props.selectedValue });
51
+ }
52
+ }
53
+
48
54
  validateDeprecateProps = (oldProp = 'curtain', newProp = '') => {
49
55
  if(this.props){
50
56
  if(typeof this.props[oldProp] !== 'undefined'){
@@ -88,6 +94,7 @@ export default class Picker extends Component {
88
94
  key={index}
89
95
  value={typeof data.value !== 'undefined' ? data.value : data.toString()}
90
96
  label={typeof data.label !== 'undefined' ? data.label : data.toString()}
97
+ color={props.textColor}
91
98
  />
92
99
  ))}
93
100
  </WheelCurvedPicker>