react-native-wheel-pick 1.1.2 → 1.1.5

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ react-native-wheel-pick
2
+ Copyright 2022 tron.natthakorn@engineer.com
3
+
4
+ This project contains code copied from AigeStudio:
5
+ https://github.com/AigeStudio/WheelPicker
6
+ Copyright 2015-2017 AigeStudio
7
+ Licensed under the Apache License, Version 2.0
8
+
9
+ This project contains code copied from @leslisam/react-native-wheel-picker:
10
+ https://github.com/lesliesam/react-native-wheel-picker
11
+
12
+ This project contains code copied from @wusuopu/react-native-wheel-picker:
13
+ https://github.com/wusuopu/react-native-wheel-picker
14
+
15
+ This project contains code copied from @pinguinjkeke/react-native-wheel-datepicker
16
+ https://github.com/pinguinjkeke/react-native-wheel-datepicker
package/README.md CHANGED
@@ -1,29 +1,176 @@
1
- # FYI
2
-
3
- Hey guy I am so sorry, I do not have time to develop this project anymore. :(
4
-
5
- I recommend you to use [https://github.com/react-native-picker/picker](https://github.com/react-native-picker/picker) instead.
6
- I have many work to do :(
7
-
8
- You can also fork my project, but if you want to pay for my coffee for continue develop/update this project pls send message directly to [https://facebook.com/tron.onlyalone](https://facebook.com/tron.onlyalone)
9
1
 
10
2
  # react-native-wheel-pick
11
3
 
12
4
  React native wheel picker for both iOS and android. (Support DatePicker)
13
5
 
14
- This is not original but inspire by [react-native-wheel-datepicker](https://github.com/pinguinjkeke/react-native-wheel-datepicker)
6
+ This is not original but inspired by [react-native-wheel-datepicker](https://github.com/pinguinjkeke/react-native-wheel-datepicker)
15
7
 
16
- ![](https://preview.ibb.co/iUjDZo/screen1.png)
8
+ # Preview
9
+
10
+ ![](https://i.ibb.co/4W7h12M/rn-wl-pk-1-1-13.png)
17
11
 
18
12
  ## How to use
19
13
 
14
+ React Native >= 0.60+
15
+ ```
16
+ npm install react-native-wheel-pick
17
+ npx pod-install
18
+
19
+ npx react-native run-android // re-build native-code for gradle
20
+ ```
21
+
22
+ React Native < 0.60
20
23
  ```
21
24
  npm install react-native-wheel-pick
22
25
  react-native link react-native-wheel-pick
26
+
27
+ react-native run-android // re-build native-code for gradle
23
28
  ```
24
29
  [react-native-wheel-pick](https://www.npmjs.com/package/react-native-wheel-pick)
25
30
 
26
- ## Example code
31
+ ## Example code
32
+
33
+ ```jsx
34
+ import { Picker, DatePicker } from 'react-native-wheel-pick';
35
+
36
+ // use Picker
37
+ <Picker
38
+ style={{ backgroundColor: 'white', width: 300, height: 215 }}
39
+ selectedValue='item4'
40
+ pickerData={['item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7']}
41
+ onValueChange={value => { console.log(value) }}
42
+ />
43
+
44
+ // use DatePicker
45
+ <DatePicker
46
+ style={{ backgroundColor: 'white', width: 370, height: 240 }}
47
+ onDateChange={date => { console.log(date) }}
48
+ />
49
+
50
+ ```
51
+ ## Note
52
+
53
+ - For Picker of iOS use [@react-native-picker/picker](https://github.com/react-native-picker/picker)
54
+ - For DatePicker of iOS use [@react-native-community/datetimepicker](https://github.com/react-native-datetimepicker/datetimepicker)
55
+ - For Picker and DatePicker of Android use WheelPicker of [WheelPicker](https://github.com/AigeStudio/WheelPicker)
56
+ - Pull request are welcome.
57
+
58
+ ## More Example
59
+
60
+ ```jsx
61
+ // DatePicker set default select date
62
+ <DatePicker
63
+ style={{ height: 215, width: 300 }}
64
+ date={new Date('2018-06-27')} // Optional prop - default is Today
65
+ onDateChange={date => { console.log(date) }}
66
+ />
67
+
68
+ // DatePicker set min/max Date
69
+ <DatePicker
70
+ style={{ height: 215, width: 300 }}
71
+ minimumDate={new Date('2000-01-01')}
72
+ maximumDate={new Date('2050-12-31')}
73
+ onDateChange={date => { console.log(date) }}
74
+ />
75
+
76
+ ```
77
+ ```jsx
78
+ // pickerData also support array of object.
79
+
80
+ // Way 1
81
+ <Picker
82
+ selectedValue='item4'
83
+ pickerData={['item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7']}
84
+ onValueChange={value => { console.log(value) }}
85
+ />
86
+
87
+ // Optional Way 2
88
+ <Picker
89
+ style={{ backgroundColor: 'white', width: 300, height: 215 }}
90
+ selectedValue='5765387680'
91
+ pickerData={[
92
+ { value : '5765387677', label : 'item1' },
93
+ { value : '5765387678', label : 'item2' },
94
+ { value : '5765387679', label : 'item3' },
95
+ { value : '5765387680', label : 'item4' },
96
+ { value : '5765387681', label : 'item5' },
97
+ { value : '5765387682', label : 'item6' },
98
+ { value : '5765387683', label : 'item7' },
99
+ ]}
100
+ onValueChange={value => { console.log(value) }}
101
+ />
102
+ ```
103
+ ```jsx
104
+ // Android Only.
105
+ // These is special props for Android. (iOS not work)
106
+ // You can also use these props for DatePicker, too.
107
+ <Picker
108
+ textColor='red'
109
+ textSize={20}
110
+
111
+ selectTextColor='green'
112
+ isShowSelectBackground={false} // Default is true
113
+ selectBackgroundColor='#8080801A' // support HEXA color Style (#rrggbbaa)
114
+ // (Please always set 'aa' value for transparent)
115
+
116
+ isShowSelectLine={false} // Default is true
117
+ selectLineColor='black'
118
+ selectLineSize={6} // Default is 4
119
+ />
120
+
121
+ // Android Only.
122
+ <DatePicker
123
+ order='D-M-Y' // Default is M-D-Y
124
+ />
125
+ ```
126
+ ## Release Note
127
+
128
+ ### 1.1.5 (June 20 2022)
129
+ - Change License from MIT to Apache-2.0
130
+ - Add NOTICE file for credit original author.
131
+ - Fix peerDependency do not break other version.
132
+
133
+ [Android]
134
+ - Fix WheelCurvedPicker not found for first run.
135
+ - DatePicker support order prop.
136
+
137
+ ### 1.1.4 (June 19 2022)
138
+ - Fix Readme wrong type.
139
+
140
+ ### 1.1.3 (June 19 2022)
141
+ - Restructure code of Picker iOS and Android.
142
+ - pickerData support array of object.
143
+
144
+ [Android]
145
+ - Update sdk support for SDK Version 30 (Google Play need sdk version 30+)
146
+ - Now android support for style of selectLine / selectBackground. Special thanks to [@kaisv7n](https://github.com/kaisv7n) for his pull request,
147
+ [Update WheelPicker version, exposed more methods and fixed crash on android](https://github.com/TronNatthakorn/react-native-wheel-pick/pull/12) I changed prop name for more understandable.
148
+
149
+ - DatePicker of Android also support width.
150
+ - Deprecated some android prop that make library faster. (Atmospheric / Curved / visibleItemCount / itemSpace)
151
+ If you want it back pull request are welcome.
152
+ - Change some prop name for make code more understandable.
153
+ - If update from version <= 1.1.2. You will get warning about Deprecated prop if you still use, I write some logic for make app not crash. (Please fix warning if possible.)
154
+
155
+ [IOS]
156
+ - Do not use PickerIOS and DatePickerIOS of 'react-native' anymore.
157
+
158
+ # FYI
159
+
160
+ For version 1.1.3 - I update this library support for React Native Version 0.68.2 / Android 11 / iOS 15.2
161
+
162
+ If you use React Native Version less than 0.68.2 / Android older than 11 / iOS older than 15.2.
163
+ It is possible to have unexpected bug.
164
+
165
+ I rarely check this lib. (6 Months - 3 Years). Up on my life's time.
166
+
167
+ If you want to pay me coffee for quickly check & merge your request. Please contact me directly [facebook.com/tron.natthakorn](https://facebook.com/tron.natthakorn) OR you can fork this project.
168
+
169
+ ## Preview for version <= 1.12
170
+
171
+ ![](https://preview.ibb.co/iUjDZo/screen1.png)
172
+
173
+ ## Example code for version <= 1.12
27
174
 
28
175
  ```jsx
29
176
  import { Platform } from 'react-native';
@@ -48,16 +195,14 @@ const isIos = Platform.OS === 'ios'
48
195
  />
49
196
 
50
197
  ```
51
- ## Note
198
+ ## Note for version <= 1.12
52
199
 
53
200
  - For iOS use default PickerIOS / DatePickerIOS of React Native.
54
201
  - For Android use WheelPicker of [WheelPicker](https://github.com/AigeStudio/WheelPicker)
55
202
  - Line color is white in android. (Support Line style in future. Pull request welcome)
56
203
  - Line color is grey in IOS but it has bug line not show in Picker (iOS 11.4 not sure other version).
57
204
 
58
- ~~Pull request are welcome for more support in future (Text Style / Line Style / Line Bug)~~
59
-
60
- ## More Example
205
+ ## More Example for version <= 1.12
61
206
 
62
207
  ```jsx
63
208
  // DatePicker set default choose date
@@ -76,7 +221,7 @@ const isIos = Platform.OS === 'ios'
76
221
  />
77
222
  ```
78
223
 
79
- ## Release Note
224
+ ## Release Note for version <= 1.12
80
225
 
81
226
  ### 1.1.2 (April 13 2022)
82
227
  - Edit broken url.
@@ -114,3 +259,19 @@ const isIos = Platform.OS === 'ios'
114
259
  ### 1.0.4 (June 24 2018)
115
260
  [Android]
116
261
  - Support compileSDKVersion 26
262
+
263
+ ## License
264
+
265
+ Copyright 2022 tron.natthakorn@engineer.com
266
+
267
+ Licensed under the Apache License, Version 2.0 (the "License");
268
+ you may not use this file except in compliance with the License.
269
+ You may obtain a copy of the License at
270
+
271
+ http://www.apache.org/licenses/LICENSE-2.0
272
+
273
+ Unless required by applicable law or agreed to in writing, software
274
+ distributed under the License is distributed on an "AS IS" BASIS,
275
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
276
+ See the License for the specific language governing permissions and
277
+ limitations under the License.
@@ -1,15 +1,21 @@
1
+ buildscript {
2
+ repositories {
3
+ maven { url "https://jitpack.io" }
4
+ }
5
+ }
6
+
1
7
  apply plugin: 'com.android.library'
2
8
 
3
- def safeExtGet(prop, fallback) {
4
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
- }
9
+ //def safeExtGet(prop, fallback) {
10
+ // rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
11
+ //}
6
12
 
7
13
  android {
8
- compileSdkVersion safeExtGet('compileSdkVersion', 26)
9
- buildToolsVersion "27.0.3"
14
+ compileSdk 30
15
+ /// buildToolsVersion '30.0.2'
10
16
  defaultConfig {
11
17
  minSdkVersion 16
12
- targetSdkVersion 26
18
+ targetSdkVersion 30
13
19
  versionCode 1
14
20
  versionName "1.0"
15
21
  ndk {
@@ -20,6 +26,6 @@ android {
20
26
 
21
27
  dependencies {
22
28
  implementation fileTree(dir: 'libs', include: ['*.jar'])
23
- implementation "cn.aigestudio.wheelpicker:WheelPicker:1.0.3"
29
+ implementation "com.github.AigeStudio:WheelPicker:5913fa15fc"
24
30
  implementation 'com.facebook.react:react-native:+'
25
31
  }
@@ -8,8 +8,10 @@ import android.graphics.Shader;
8
8
  import android.os.SystemClock;
9
9
  import android.util.AttributeSet;
10
10
 
11
- import com.aigestudio.wheelpicker.core.AbstractWheelPicker;
12
- import com.aigestudio.wheelpicker.view.WheelCurvedPicker;
11
+ // import android.util.Log;
12
+
13
+ import com.aigestudio.wheelpicker.WheelPicker;
14
+ import com.aigestudio.wheelpicker.WheelPicker.OnWheelChangeListener;
13
15
  import com.facebook.react.bridge.Arguments;
14
16
  import com.facebook.react.bridge.ReactContext;
15
17
  import com.facebook.react.bridge.WritableMap;
@@ -24,60 +26,49 @@ import java.util.List;
24
26
  /**
25
27
  * Credit Author: Sam Yu
26
28
  */
27
- public class ReactWheelCurvedPicker extends WheelCurvedPicker {
29
+ public class ReactWheelCurvedPicker extends WheelPicker {
28
30
 
29
31
  private final EventDispatcher mEventDispatcher;
30
32
  private List<Object> mValueData;
31
33
 
34
+ //private int mState;
35
+
32
36
  public ReactWheelCurvedPicker(ReactContext reactContext) {
33
37
  super(reactContext);
34
38
  mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
35
39
  setOnWheelChangeListener(new OnWheelChangeListener() {
36
40
  @Override
37
- public void onWheelScrolling(float deltaX, float deltaY) {
41
+ public void onWheelScrolled(int offset) {
38
42
  }
39
43
 
40
44
  @Override
41
- public void onWheelSelected(int index, String data) {
42
- if (mValueData != null && index < mValueData.size()) {
45
+ public void onWheelSelected(int position) {
46
+ // Log.d("onWheelSelected", "Wheel Selected");
47
+ if (mValueData != null && position < mValueData.size()) {
43
48
  mEventDispatcher.dispatchEvent(
44
- new ItemSelectedEvent(getId(), mValueData.get(index)));
49
+ new ItemSelectedEvent(getId(), mValueData.get(position)));
45
50
  }
46
51
  }
47
52
 
48
53
  @Override
49
54
  public void onWheelScrollStateChanged(int state) {
55
+ //mState = state;
50
56
  }
51
57
  });
52
58
  }
53
59
 
54
60
  @Override
55
- protected void drawForeground(Canvas canvas) {
56
- super.drawForeground(canvas);
57
-
58
- Paint paint = new Paint();
59
- paint.setColor(Color.WHITE);
60
- int colorFrom = 0x00FFFFFF;//Color.BLACK;
61
- int colorTo = Color.WHITE;
62
- LinearGradient linearGradientShader = new LinearGradient(rectCurItem.left, rectCurItem.top, rectCurItem.right/2, rectCurItem.top, colorFrom, colorTo, Shader.TileMode.MIRROR);
63
- paint.setShader(linearGradientShader);
64
- canvas.drawLine(rectCurItem.left, rectCurItem.top, rectCurItem.right, rectCurItem.top, paint);
65
- canvas.drawLine(rectCurItem.left, rectCurItem.bottom, rectCurItem.right, rectCurItem.bottom, paint);
66
- }
67
-
68
- @Override
69
- public void setItemIndex(int index) {
70
- super.setItemIndex(index);
71
- unitDeltaTotal = 0;
72
- mHandler.post(this);
61
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
62
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
73
63
  }
74
64
 
75
65
  public void setValueData(List<Object> data) {
76
66
  mValueData = data;
77
67
  }
78
68
 
79
- public int getState() {
80
- return state;
69
+ public void getState() {
70
+ //public int getState() {
71
+ //return state;
81
72
  }
82
73
  }
83
74
 
@@ -114,4 +105,4 @@ class ItemSelectedEvent extends Event<ItemSelectedEvent> {
114
105
 
115
106
  return eventData;
116
107
  }
117
- }
108
+ }
@@ -2,7 +2,7 @@ package com.tron;
2
2
 
3
3
  import android.graphics.Color;
4
4
 
5
- import com.aigestudio.wheelpicker.core.AbstractWheelPicker;
5
+ import com.aigestudio.wheelpicker.WheelPicker;
6
6
  import com.facebook.react.bridge.ReadableArray;
7
7
  import com.facebook.react.bridge.ReadableType;
8
8
  import com.facebook.react.bridge.ReadableMap;
@@ -12,6 +12,8 @@ import com.facebook.react.uimanager.SimpleViewManager;
12
12
  import com.facebook.react.uimanager.ThemedReactContext;
13
13
  import com.facebook.react.uimanager.annotations.ReactProp;
14
14
 
15
+ // import android.util.Log;
16
+
15
17
  import java.util.ArrayList;
16
18
  import java.util.Map;
17
19
 
@@ -22,25 +24,38 @@ public class ReactWheelCurvedPickerManager extends SimpleViewManager<ReactWheelC
22
24
 
23
25
  private static final String REACT_CLASS = "WheelCurvedPicker";
24
26
 
25
- private static final int DEFAULT_TEXT_SIZE = 25 * 2;
26
- private static final int DEFAULT_ITEM_SPACE = 14 * 2;
27
+ private static final int DEFAULT_TEXT_SIZE = 24 * 2;
28
+ private static final int DEFAULT_ITEM_SPACE = 16 * 2;
29
+
30
+ @Override
31
+ public Map getExportedCustomDirectEventTypeConstants() {
32
+ return MapBuilder.of(
33
+ ItemSelectedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onValueChange")
34
+ );
35
+ }
27
36
 
28
37
  @Override
29
38
  protected ReactWheelCurvedPicker createViewInstance(ThemedReactContext reactContext) {
30
39
  ReactWheelCurvedPicker picker = new ReactWheelCurvedPicker(reactContext);
31
- picker.setTextColor(Color.LTGRAY);
32
- picker.setCurrentTextColor(Color.WHITE);
33
- picker.setTextSize(DEFAULT_TEXT_SIZE);
40
+ picker.setItemTextColor(Color.BLACK);
41
+ picker.setItemTextSize(DEFAULT_TEXT_SIZE);
42
+ picker.setSelectedItemTextColor(Color.WHITE);
34
43
  picker.setItemSpace(DEFAULT_ITEM_SPACE);
44
+ picker.setIndicator(true);
45
+ picker.setIndicatorSize(4);
46
+ picker.setIndicatorColor(Color.parseColor("#26808080"));
47
+ picker.setCurtain(true);
48
+ picker.setCurtainColor(Color.parseColor("#1A808080"));
49
+ picker.setAtmospheric(true);
50
+ picker.setCurved(true);
51
+ picker.setVisibleItemCount(7);
35
52
 
36
- return picker;
37
- }
53
+ picker.setItemAlign(0);
38
54
 
39
- @Override
40
- public Map getExportedCustomDirectEventTypeConstants() {
41
- return MapBuilder.of(
42
- ItemSelectedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onValueChange")
43
- );
55
+ // Trick Code - wake setSelectItemPosition
56
+ picker.setSelectedItemPosition(1); // Cannot 0 instead of 1, I Don Know why but need this line for make ReactProp selectIndex Work
57
+
58
+ return picker;
44
59
  }
45
60
 
46
61
  @ReactProp(name="data")
@@ -66,31 +81,101 @@ public class ReactWheelCurvedPickerManager extends SimpleViewManager<ReactWheelC
66
81
 
67
82
  @ReactProp(name="selectedIndex")
68
83
  public void setSelectedIndex(ReactWheelCurvedPicker picker, int index) {
69
- if (picker != null && picker.getState() == AbstractWheelPicker.SCROLL_STATE_IDLE) {
70
- picker.setItemIndex(index);
84
+ //if (picker != null && picker.getState() == WheelPicker.SCROLL_STATE_IDLE) {
85
+ // Log.d("Index from React", index + "");
86
+ if (picker != null) {
87
+ picker.setSelectedItemPosition(index);
71
88
  picker.invalidate();
72
89
  }
73
90
  }
74
91
 
92
+ // @ReactProp(name="atmospheric")
93
+ // public void setAtmospheric(ReactWheelCurvedPicker picker, boolean hasAtmospheric) {
94
+ // if (picker != null) {
95
+ // picker.setAtmospheric(hasAtmospheric);
96
+ // }
97
+ // }
98
+
99
+ // @ReactProp(name="curved")
100
+ // public void setCurved(ReactWheelCurvedPicker picker, boolean hasCurved) {
101
+ // if (picker != null) {
102
+ // picker.setCurved(hasCurved);
103
+ // }
104
+ // }
105
+
106
+ // @ReactProp(name="visibleItemCount")
107
+ // public void setVisibleItemCount(ReactWheelCurvedPicker picker, int num) {
108
+ // if (picker != null) {
109
+ // picker.setVisibleItemCount(num);
110
+ // }
111
+ // }
112
+
113
+ // // Didnot work on android 11
114
+ // @ReactProp(name="itemSpace")
115
+ // public void setItemSpace(ReactWheelCurvedPicker picker, int space) {
116
+ // if (picker != null) {
117
+ // picker.setItemSpace((int) PixelUtil.toPixelFromDIP(space));
118
+ // }
119
+ // }
120
+
75
121
  @ReactProp(name="textColor", customType = "Color")
76
122
  public void setTextColor(ReactWheelCurvedPicker picker, Integer color) {
77
123
  if (picker != null) {
78
- picker.setCurrentTextColor(color);
79
- picker.setTextColor(color);
124
+ picker.setItemTextColor(color);
80
125
  }
81
126
  }
82
127
 
83
128
  @ReactProp(name="textSize")
84
129
  public void setTextSize(ReactWheelCurvedPicker picker, int size) {
85
130
  if (picker != null) {
86
- picker.setTextSize((int) PixelUtil.toPixelFromDIP(size));
131
+ picker.setItemTextSize((int) PixelUtil.toPixelFromDIP(size));
132
+ }
133
+ }
134
+
135
+ @ReactProp(name="selectTextColor", customType = "Color")
136
+ public void setSelectedTextColor(ReactWheelCurvedPicker picker, Integer color) {
137
+ if (picker != null) {
138
+ picker.setSelectedItemTextColor(color);
139
+ }
140
+ }
141
+
142
+ //@ReactProp(name="curtain")
143
+ @ReactProp(name="isShowSelectBackground")
144
+ public void setCurtain(ReactWheelCurvedPicker picker, boolean hasCurtain) {
145
+ if (picker != null) {
146
+ picker.setCurtain(hasCurtain);
147
+ }
148
+ }
149
+
150
+ //@ReactProp(name="curtainColor", customType = "Color")
151
+ @ReactProp(name="selectBackgroundColor", customType = "Color")
152
+ public void setCurtainColor(ReactWheelCurvedPicker picker, Integer color) {
153
+ if (picker != null) {
154
+ picker.setCurtainColor(color);
155
+ }
156
+ }
157
+
158
+ // @ReactProp(name="indicator")
159
+ @ReactProp(name="isShowSelectLine")
160
+ public void setIndicator(ReactWheelCurvedPicker picker, boolean hasIndicator) {
161
+ if (picker != null) {
162
+ picker.setIndicator(hasIndicator);
163
+ }
164
+ }
165
+
166
+ //@ReactProp(name="indicatorColor", customType = "Color")
167
+ @ReactProp(name="selectLineColor", customType = "Color")
168
+ public void setIndicatorColor(ReactWheelCurvedPicker picker, Integer color) {
169
+ if (picker != null) {
170
+ picker.setIndicatorColor(color);
87
171
  }
88
172
  }
89
173
 
90
- @ReactProp(name="itemSpace")
91
- public void setItemSpace(ReactWheelCurvedPicker picker, int space) {
174
+ //@ReactProp(name="indicatorSize")
175
+ @ReactProp(name="selectLineSize")
176
+ public void setIndicatorSize(ReactWheelCurvedPicker picker, int size) {
92
177
  if (picker != null) {
93
- picker.setItemSpace((int) PixelUtil.toPixelFromDIP(space));
178
+ picker.setIndicatorSize(size);
94
179
  }
95
180
  }
96
181
 
@@ -98,4 +183,4 @@ public class ReactWheelCurvedPickerManager extends SimpleViewManager<ReactWheelC
98
183
  public String getName() {
99
184
  return REACT_CLASS;
100
185
  }
101
- }
186
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wheel-pick",
3
- "version": "1.1.2",
3
+ "version": "1.1.5",
4
4
  "description": "React native wheel picker iOS style with android.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -12,11 +12,12 @@
12
12
  },
13
13
  "keywords": [
14
14
  "react-native",
15
- "picker",
16
- "wheel"
15
+ "react-native-wheel",
16
+ "react-native-wheel-pick",
17
+ "react-native-wheel-picker"
17
18
  ],
18
- "author": "Natthakorn Nakhaseno <tron.natthakorn@engineer.com>",
19
- "license": "MIT",
19
+ "author": "Tron Natthakorn <tron.natthakorn@engineer.com>",
20
+ "license": "Apache-2.0",
20
21
  "bugs": {
21
22
  "url": "https://github.com/TronNatthakorn/react-native-wheel-pick/issues"
22
23
  },
@@ -27,6 +28,9 @@
27
28
  "peerDependencies": {
28
29
  "moment": ">=2.0.0",
29
30
  "prop-types": "*",
30
- "react-native": ">=0.45.0"
31
+ "react-native": ">=0.45.0",
32
+ "deprecated-react-native-prop-types": ">=2.3.0",
33
+ "@react-native-community/datetimepicker": ">=6.1.3",
34
+ "@react-native-picker/picker": ">=2.4.1"
31
35
  }
32
36
  }
@@ -1,5 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { ColorPropType, requireNativeComponent, View, ViewPropTypes as RNViewPropTypes } from 'react-native';
2
+ import { requireNativeComponent, View } from 'react-native';
3
+ import { ColorPropType, ViewPropTypes as RNViewPropTypes, } from 'deprecated-react-native-prop-types'
3
4
  import PropTypes from 'prop-types';
4
5
 
5
6
  const ViewPropTypes = RNViewPropTypes || View.propTypes;
@@ -25,30 +26,30 @@ class WheelCurvedPicker extends PureComponent {
25
26
  data: PropTypes.array,
26
27
  textColor: ColorPropType,
27
28
  textSize: PropTypes.number,
28
- itemSpace: PropTypes.number,
29
29
  onValueChange: PropTypes.func.isRequired,
30
30
  selectedValue: PropTypes.any,
31
- selectedIndex: PropTypes.number,
31
+ // selectedIndex: PropTypes.number,
32
32
  };
33
33
 
34
34
  static defaultProps = {
35
35
  textSize: 26,
36
- itemSpace: 20,
37
36
  textColor: '#333',
38
37
  };
39
38
 
40
- state = {}
39
+ state = {
40
+ selectedIndex: 0
41
+ }
41
42
 
42
43
  onValueChange = ({ nativeEvent: { data } }) => {
44
+ this.props.onValueChange(data);
43
45
  if(firstTimeOnChange) {
44
46
  return firstTimeOnChange = false
45
47
  }
46
- this.props.onValueChange(data);
47
48
  }
48
49
 
49
- componentDidMount() {
50
- this.setState(stateFromProps(this.props));
51
- }
50
+ // componentDidMount() {
51
+ // this.setState(stateFromProps(this.props));
52
+ // }
52
53
 
53
54
  static getDerivedStateFromProps(nextProps) {
54
55
  return stateFromProps(nextProps)
@@ -75,7 +76,7 @@ class Item extends PureComponent {
75
76
  };
76
77
 
77
78
  // These items don't get rendered directly.
78
- render = () => null;
79
+ render = () => <></>;
79
80
  }
80
81
 
81
82
  WheelCurvedPicker.Item = Item;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { PickerIOS } from 'react-native';
2
+ import { Picker } from '@react-native-picker/picker';
3
3
 
4
- export default PickerIOS;
4
+ export default Picker;
@@ -1,5 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { ColorPropType, StyleSheet, View, ViewPropTypes as RNViewPropTypes } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import { ColorPropType, ViewPropTypes as RNViewPropTypes } from 'deprecated-react-native-prop-types'
3
4
  import PropTypes from 'prop-types';
4
5
  import moment from 'moment';
5
6
  import Picker from './picker';
@@ -23,7 +24,6 @@ const styles = StyleSheet.create({
23
24
  });
24
25
 
25
26
  const stylesFromProps = props => ({
26
- itemSpace: props.itemSpace,
27
27
  textColor: props.textColor,
28
28
  textSize: props.textSize,
29
29
  style: props.style,
@@ -45,7 +45,6 @@ export default class DatePicker extends PureComponent {
45
45
  style: ViewPropTypes.style,
46
46
  textColor: ColorPropType,
47
47
  textSize: PropTypes.number,
48
- itemSpace: PropTypes.number,
49
48
  };
50
49
 
51
50
  static defaultProps = {
@@ -62,7 +61,6 @@ export default class DatePicker extends PureComponent {
62
61
  style: null,
63
62
  textColor: '#333',
64
63
  textSize: 26,
65
- itemSpace: 20,
66
64
  };
67
65
 
68
66
  constructor(props) {
@@ -97,7 +95,10 @@ export default class DatePicker extends PureComponent {
97
95
 
98
96
  static getDerivedStateFromProps(nextProps, prevState) {
99
97
  if (prevState.date !== nextProps.date) {
100
- this.parseDate(nextProps.date);
98
+
99
+ if(typeof this === 'object' && typeof this.parseDate === 'function'){
100
+ this.parseDate(nextProps.date);
101
+ }
101
102
 
102
103
  return { date: nextProps.date }
103
104
  }
@@ -116,7 +117,7 @@ export default class DatePicker extends PureComponent {
116
117
  this.newValue.year = year;
117
118
  this.checkDate(oldYear, this.newValue.month);
118
119
  if(firstTimeOnChange.year) {
119
- return firstTimeOnChange.year = false
120
+ firstTimeOnChange.year = false
120
121
  }
121
122
  this.props.onDateChange(this.getValue());
122
123
  };
@@ -127,7 +128,7 @@ export default class DatePicker extends PureComponent {
127
128
  this.newValue.month = month - 1;
128
129
  this.checkDate(this.newValue.year, oldMonth);
129
130
  if(firstTimeOnChange.month) {
130
- return firstTimeOnChange.month = false
131
+ firstTimeOnChange.month = false
131
132
  }
132
133
  this.props.onDateChange(this.getValue());
133
134
  };
@@ -136,7 +137,7 @@ export default class DatePicker extends PureComponent {
136
137
  this.newValue.date = date;
137
138
  this.checkDate(this.newValue.year, this.newValue.month);
138
139
  if(firstTimeOnChange.date) {
139
- return firstTimeOnChange.date = false
140
+ firstTimeOnChange.date = false
140
141
  }
141
142
  this.props.onDateChange(this.getValue());
142
143
  };
@@ -144,7 +145,7 @@ export default class DatePicker extends PureComponent {
144
145
  onHourChange = (hour) => {
145
146
  this.newValue.hour = hour;
146
147
  if(firstTimeOnChange.hour) {
147
- return firstTimeOnChange.hour = false
148
+ firstTimeOnChange.hour = false
148
149
  }
149
150
  this.props.onDateChange(this.getValue());
150
151
  };
@@ -152,7 +153,7 @@ export default class DatePicker extends PureComponent {
152
153
  onMinuteChange = (minute) => {
153
154
  this.newValue.minute = minute;
154
155
  if(firstTimeOnChange.minute) {
155
- return firstTimeOnChange.minute = false
156
+ firstTimeOnChange.minute = false
156
157
  }
157
158
  this.props.onDateChange(this.getValue());
158
159
  };
@@ -168,8 +169,10 @@ export default class DatePicker extends PureComponent {
168
169
  }
169
170
 
170
171
  render() {
172
+ const width_wrapper = this.props.style.width || '100%';
173
+
171
174
  return (
172
- <View style={styles.row}>
175
+ <View style={{...styles.row, width: width_wrapper}}>
173
176
  {['date', 'datetime'].includes(this.props.mode) && this.datePicker}
174
177
  {['time', 'datetime'].includes(this.props.mode) && this.timePicker}
175
178
  </View>
@@ -191,7 +194,8 @@ export default class DatePicker extends PureComponent {
191
194
  <View key='date' style={styles.picker}>
192
195
  <Picker
193
196
  {...propsStyles}
194
- style={this.props.style}
197
+ {...this.props}
198
+ style={{...this.props.style, width: '100%'}}
195
199
  ref={(date) => { this.dateComponent = date; }}
196
200
  selectedValue={this.state.date.getDate()}
197
201
  pickerData={this.state.dayRange}
@@ -203,7 +207,8 @@ export default class DatePicker extends PureComponent {
203
207
  <View key='month' style={styles.picker}>
204
208
  <Picker
205
209
  {...propsStyles}
206
- style={this.props.style}
210
+ {...this.props}
211
+ style={{...this.props.style, width: '100%'}}
207
212
  ref={(month) => { this.monthComponent = month; }}
208
213
  selectedValue={this.state.date.getMonth() + 1}
209
214
  pickerData={this.state.monthRange}
@@ -215,7 +220,8 @@ export default class DatePicker extends PureComponent {
215
220
  <View key='year' style={styles.picker}>
216
221
  <Picker
217
222
  {...propsStyles}
218
- style={this.props.style}
223
+ {...this.props}
224
+ style={{...this.props.style, width: '100%'}}
219
225
  ref={(year) => { this.yearComponent = year; }}
220
226
  selectedValue={this.state.date.getFullYear()}
221
227
  pickerData={this.state.yearRange}
@@ -1,5 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { DatePickerIOS } from 'react-native';
2
+ // import { DatePickerIOS } from 'react-native';
3
+ import DateTimePicker from '@react-native-community/datetimepicker';
3
4
  import PropTypes from 'prop-types';
4
5
 
5
6
  export default class DatePicker extends PureComponent {
@@ -20,12 +21,16 @@ export default class DatePicker extends PureComponent {
20
21
  date: new Date(),
21
22
  };
22
23
 
24
+ // @react-native-community/datetimepicker
25
+ //2022 use value instead of date
26
+ //2022 use onChange instead of onDateChange (and first param not date anymore)
23
27
  render() {
24
28
  return (
25
- <DatePickerIOS
29
+ <DateTimePicker
26
30
  {...this.props}
27
- onDateChange={this.onDateChange}
28
- date={this.state.date}
31
+ onChange={(event, date) => this.onDateChange(date)}
32
+ display='spinner'
33
+ value={this.state.date}
29
34
  />
30
35
  );
31
36
  }
package/src/picker.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
- import { ColorPropType, StyleSheet, View, ViewPropTypes as RNViewPropTypes, Text } from 'react-native';
2
+ import { StyleSheet, View, Text, Platform } from 'react-native';
3
+ import { ColorPropType, ViewPropTypes as RNViewPropTypes, } from 'deprecated-react-native-prop-types'
3
4
  import PropTypes from 'prop-types';
4
5
  import WheelCurvedPicker from './WheelCurvedPicker';
5
6
 
@@ -19,7 +20,6 @@ export default class Picker extends Component {
19
20
  static propTypes = {
20
21
  textColor: ColorPropType,
21
22
  textSize: PropTypes.number,
22
- itemSpace: PropTypes.number,
23
23
  itemStyle: ViewPropTypes.style,
24
24
  onValueChange: PropTypes.func.isRequired,
25
25
  pickerData: PropTypes.array.isRequired,
@@ -30,9 +30,11 @@ export default class Picker extends Component {
30
30
  static defaultProps = {
31
31
  textColor: '#333',
32
32
  textSize: 26,
33
- itemSpace: 20,
34
33
  itemStyle: null,
35
- style: null,
34
+ // onValueChange: () => {}, // Require
35
+ // pickerData: [''], // Require
36
+ style: {},
37
+ selectedValue: '',
36
38
  };
37
39
 
38
40
  state = {
@@ -44,9 +46,37 @@ export default class Picker extends Component {
44
46
  this.props.onValueChange(selectedValue);
45
47
  };
46
48
 
49
+ validateDeprecateProps = (oldProp = 'curtain', newProp = '') => {
50
+ if(this.props){
51
+ if(typeof this.props[oldProp] !== 'undefined'){
52
+ this.props[oldProp] = undefined;
53
+
54
+ if(newProp === ''){
55
+ console.warn(`react-native-wheel-pick : "${oldProp}" Prop was deprecated. Please remove it for improve native performance.`)
56
+ } else {
57
+ console.warn(`react-native-wheel-pick : "${oldProp}" Prop was deprecated. Please use "${newProp}" instead.`)
58
+ }
59
+ }
60
+ }
61
+ }
62
+
47
63
  render() {
48
64
  const { pickerData, style, ...props } = this.props;
49
65
 
66
+ if(Platform.OS === 'android'){
67
+ //checkDeprecatedProp
68
+ this.validateDeprecateProps('atmospheric');
69
+ this.validateDeprecateProps('curved');
70
+ this.validateDeprecateProps('visibleItemCount');
71
+ this.validateDeprecateProps('itemSpace');
72
+ this.validateDeprecateProps('curtain', 'isShowSelectBackground');
73
+ this.validateDeprecateProps('curtainColor', 'selectBackgroundColor');
74
+
75
+ this.validateDeprecateProps('indicator', 'isShowSelectLine');
76
+ this.validateDeprecateProps('indicatorColor', 'selectLineColor');
77
+ this.validateDeprecateProps('indicatorSize', 'selectLineSize');
78
+ }
79
+
50
80
  return (
51
81
  <WheelCurvedPicker
52
82
  {...props}
@@ -57,7 +87,7 @@ export default class Picker extends Component {
57
87
  {pickerData.map((data, index) => (
58
88
  <PickerItem
59
89
  key={index}
60
- value={typeof data.value !== 'undefined' ? data.value : data}
90
+ value={typeof data.value !== 'undefined' ? data.value : data.toString()}
61
91
  label={typeof data.label !== 'undefined' ? data.label : data.toString()}
62
92
  />
63
93
  ))}