@momo-kits/date-picker 0.109.1-rc.21 → 0.110.1-beta.1

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.
Files changed (2) hide show
  1. package/WheelPicker.tsx +34 -39
  2. package/package.json +2 -2
package/WheelPicker.tsx CHANGED
@@ -1,12 +1,5 @@
1
- import React, {
2
- FC,
3
- memo,
4
- useCallback,
5
- useContext,
6
- useEffect,
7
- useRef,
8
- } from 'react';
9
- import {Animated, View} from 'react-native';
1
+ import React, {FC, memo, useContext, useEffect, useMemo, useRef} from 'react';
2
+ import {Animated, ListRenderItemInfo, Platform, View} from 'react-native';
10
3
  import {FlatList} from 'react-native-gesture-handler';
11
4
  import styles from './styles';
12
5
  import {ApplicationContext, scaleSize} from '@momo-kits/foundation';
@@ -86,30 +79,8 @@ const WheelPicker: FC<WheelPickerProps> = ({
86
79
  };
87
80
 
88
81
  const ItemComponent: FC<any> = React.memo(props => {
89
- const {item, opacity, scale} = props;
82
+ const {item, index} = props;
90
83
 
91
- return (
92
- <Animated.View
93
- style={[
94
- styles.wheelItem,
95
- {
96
- opacity,
97
- },
98
- ]}>
99
- <Animated.Text
100
- style={{
101
- fontFamily: `${theme.font}-Semibold`,
102
- transform: [{scale}],
103
- fontSize: scaleSize(16),
104
- lineHeight: scaleSize(22),
105
- }}>
106
- {item}
107
- </Animated.Text>
108
- </Animated.View>
109
- );
110
- });
111
-
112
- const renderItem = useCallback(({item, index}) => {
113
84
  const opacityAnimated = (a: number, b: number, c: number) => {
114
85
  return {
115
86
  inputRange: [...data.map((_: any, i: number) => i * itemSize)],
@@ -145,13 +116,37 @@ const WheelPicker: FC<WheelPickerProps> = ({
145
116
  };
146
117
 
147
118
  return (
148
- <ItemComponent
149
- item={item}
150
- opacity={scrollAnimatedValue.interpolate(opacityAnimated(1, 0.8, 0.4))}
151
- scale={scrollAnimatedValue.interpolate(scaleAnimated(1, 0.87))}
152
- />
119
+ <Animated.View
120
+ style={[
121
+ styles.wheelItem,
122
+ {
123
+ opacity: scrollAnimatedValue.interpolate(
124
+ useMemo(() => opacityAnimated(1, 0.8, 0.4), [])
125
+ ),
126
+ },
127
+ ]}>
128
+ <Animated.Text
129
+ style={{
130
+ fontFamily: `${theme.font}-Semibold`,
131
+ transform: [
132
+ {
133
+ scale: scrollAnimatedValue.interpolate(
134
+ useMemo(() => scaleAnimated(1, 0.87), [])
135
+ ),
136
+ },
137
+ ],
138
+ fontSize: scaleSize(16),
139
+ lineHeight: scaleSize(22),
140
+ }}>
141
+ {item}
142
+ </Animated.Text>
143
+ </Animated.View>
153
144
  );
154
- }, []);
145
+ });
146
+
147
+ const renderItem = (props: ListRenderItemInfo<any>) => {
148
+ return <ItemComponent {...props} />;
149
+ };
155
150
 
156
151
  const renderOverlay = () => {
157
152
  return (
@@ -189,7 +184,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
189
184
  windowSize={15}
190
185
  initialNumToRender={15}
191
186
  maxToRenderPerBatch={15}
192
- pagingEnabled
187
+ pagingEnabled={Platform.OS === 'ios'}
193
188
  snapToInterval={itemSize}
194
189
  decelerationRate={'fast'}
195
190
  getItemLayout={getItemLayout}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/date-picker",
3
- "version": "0.109.1-rc.21",
3
+ "version": "0.110.1-beta.1",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
@@ -15,4 +15,4 @@
15
15
  },
16
16
  "license": "MoMo",
17
17
  "dependencies": {}
18
- }
18
+ }