@utilitywarehouse/hearth-react-native 0.24.0 → 0.26.0
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +13 -13
- package/CHANGELOG.md +72 -0
- package/build/components/DatePicker/DatePickerCalendar.js +4 -9
- package/build/components/Modal/Modal.d.ts +1 -1
- package/build/components/Modal/Modal.js +30 -7
- package/build/components/Modal/Modal.props.d.ts +4 -2
- package/build/components/TimePicker/TimePicker.d.ts +6 -0
- package/build/components/TimePicker/TimePicker.js +78 -0
- package/build/components/TimePicker/TimePicker.props.d.ts +45 -0
- package/build/components/TimePicker/TimePicker.props.js +1 -0
- package/build/components/TimePicker/TimePickerView.d.ts +12 -0
- package/build/components/TimePicker/TimePickerView.js +130 -0
- package/build/components/TimePicker/TimePickerWheel.d.ts +8 -0
- package/build/components/TimePicker/TimePickerWheel.js +78 -0
- package/build/components/{DatePicker/time-picker/wheel-web.d.ts → TimePicker/TimePickerWheel.web.d.ts} +4 -4
- package/build/components/TimePicker/TimePickerWheel.web.js +122 -0
- package/build/components/TimePicker/index.d.ts +6 -0
- package/build/components/TimePicker/index.js +3 -0
- package/build/components/TimePickerInput/TimePickerInput.d.ts +6 -0
- package/build/components/TimePickerInput/TimePickerInput.js +127 -0
- package/build/components/TimePickerInput/TimePickerInput.props.d.ts +52 -0
- package/build/components/TimePickerInput/TimePickerInput.props.js +1 -0
- package/build/components/TimePickerInput/TimePickerInputDoneButton.d.ts +8 -0
- package/build/components/TimePickerInput/TimePickerInputDoneButton.js +19 -0
- package/build/components/TimePickerInput/TimePickerInputDoneButton.web.d.ts +5 -0
- package/build/components/TimePickerInput/TimePickerInputDoneButton.web.js +5 -0
- package/build/components/TimePickerInput/index.d.ts +2 -0
- package/build/components/TimePickerInput/index.js +1 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/docs/components/AllComponents.web.tsx +30 -0
- package/package.json +3 -2
- package/src/components/DatePicker/DatePickerCalendar.tsx +30 -13
- package/src/components/Modal/Modal.docs.mdx +9 -3
- package/src/components/Modal/Modal.props.ts +4 -2
- package/src/components/Modal/Modal.tsx +44 -7
- package/src/components/TimePicker/TimePicker.docs.mdx +84 -0
- package/src/components/TimePicker/TimePicker.figma.tsx +29 -0
- package/src/components/TimePicker/TimePicker.props.ts +45 -0
- package/src/components/TimePicker/TimePicker.stories.tsx +85 -0
- package/src/components/TimePicker/TimePicker.tsx +150 -0
- package/src/components/TimePicker/TimePickerView.tsx +216 -0
- package/src/components/TimePicker/TimePickerWheel.tsx +154 -0
- package/src/components/TimePicker/TimePickerWheel.web.tsx +217 -0
- package/src/components/TimePicker/index.ts +8 -0
- package/src/components/TimePickerInput/TimePickerInput.docs.mdx +135 -0
- package/src/components/TimePickerInput/TimePickerInput.figma.tsx +34 -0
- package/src/components/TimePickerInput/TimePickerInput.props.ts +55 -0
- package/src/components/TimePickerInput/TimePickerInput.stories.tsx +175 -0
- package/src/components/TimePickerInput/TimePickerInput.tsx +283 -0
- package/src/components/TimePickerInput/TimePickerInputDoneButton.tsx +42 -0
- package/src/components/TimePickerInput/TimePickerInputDoneButton.web.tsx +7 -0
- package/src/components/TimePickerInput/index.ts +2 -0
- package/src/components/index.ts +2 -0
- package/build/components/DatePicker/TimePicker.d.ts +0 -3
- package/build/components/DatePicker/TimePicker.js +0 -84
- package/build/components/DatePicker/time-picker/animated-math.d.ts +0 -4
- package/build/components/DatePicker/time-picker/animated-math.js +0 -19
- package/build/components/DatePicker/time-picker/period-native.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-native.js +0 -17
- package/build/components/DatePicker/time-picker/period-picker.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-picker.js +0 -10
- package/build/components/DatePicker/time-picker/period-web.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-web.js +0 -21
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +0 -8
- package/build/components/DatePicker/time-picker/wheel-native.js +0 -19
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +0 -2
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +0 -2
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +0 -16
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +0 -97
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +0 -21
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +0 -88
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +0 -23
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +0 -21
- package/build/components/DatePicker/time-picker/wheel-web.js +0 -146
- package/build/components/DatePicker/time-picker/wheel.d.ts +0 -8
- package/build/components/DatePicker/time-picker/wheel.js +0 -10
- package/src/components/DatePicker/TimePicker.tsx +0 -141
- package/src/components/DatePicker/time-picker/animated-math.ts +0 -33
- package/src/components/DatePicker/time-picker/period-native.tsx +0 -34
- package/src/components/DatePicker/time-picker/period-picker.tsx +0 -16
- package/src/components/DatePicker/time-picker/period-web.tsx +0 -36
- package/src/components/DatePicker/time-picker/wheel-native.tsx +0 -37
- package/src/components/DatePicker/time-picker/wheel-picker/index.ts +0 -3
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.tsx +0 -132
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.ts +0 -22
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.tsx +0 -200
- package/src/components/DatePicker/time-picker/wheel-web.tsx +0 -180
- package/src/components/DatePicker/time-picker/wheel.tsx +0 -18
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Animated,
|
|
4
|
-
FlatList,
|
|
5
|
-
FlatListProps,
|
|
6
|
-
NativeScrollEvent,
|
|
7
|
-
NativeSyntheticEvent,
|
|
8
|
-
Platform,
|
|
9
|
-
StyleProp,
|
|
10
|
-
View,
|
|
11
|
-
ViewProps,
|
|
12
|
-
ViewStyle,
|
|
13
|
-
} from 'react-native';
|
|
14
|
-
import { PickerOption } from '../../DatePicker.props';
|
|
15
|
-
import WheelPickerItem from './wheel-picker-item';
|
|
16
|
-
import styles from './wheel-picker.style';
|
|
17
|
-
|
|
18
|
-
interface Props {
|
|
19
|
-
value: number | string;
|
|
20
|
-
options: PickerOption[];
|
|
21
|
-
onChange: (index: number | string) => void;
|
|
22
|
-
selectedIndicatorStyle?: StyleProp<ViewStyle>;
|
|
23
|
-
itemStyle?: ViewStyle;
|
|
24
|
-
itemHeight?: number;
|
|
25
|
-
containerStyle?: ViewStyle;
|
|
26
|
-
containerProps?: Omit<ViewProps, 'style'>;
|
|
27
|
-
scaleFunction?: (x: number) => number;
|
|
28
|
-
rotationFunction?: (x: number) => number;
|
|
29
|
-
opacityFunction?: (x: number) => number;
|
|
30
|
-
visibleRest?: number;
|
|
31
|
-
decelerationRate?: 'normal' | 'fast' | number;
|
|
32
|
-
flatListProps?: Omit<FlatListProps<PickerOption | null>, 'data' | 'renderItem'>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const WheelPicker: React.FC<Props> = ({
|
|
36
|
-
value,
|
|
37
|
-
options,
|
|
38
|
-
onChange,
|
|
39
|
-
selectedIndicatorStyle = {},
|
|
40
|
-
containerStyle = {},
|
|
41
|
-
itemStyle = {},
|
|
42
|
-
itemHeight = 40,
|
|
43
|
-
scaleFunction = (x: number) => 1.0 ** x,
|
|
44
|
-
rotationFunction = (x: number) => 1 - Math.pow(1 / 2, x),
|
|
45
|
-
opacityFunction = (x: number) => Math.pow(1 / 3, x),
|
|
46
|
-
visibleRest = 2,
|
|
47
|
-
decelerationRate = 'normal',
|
|
48
|
-
containerProps = {},
|
|
49
|
-
flatListProps = {},
|
|
50
|
-
}) => {
|
|
51
|
-
const momentumStarted = useRef(false);
|
|
52
|
-
const selectedIndex = options.findIndex(item => item.value === value);
|
|
53
|
-
|
|
54
|
-
const flatListRef = useRef<FlatList<PickerOption | null>>(null);
|
|
55
|
-
const [scrollY] = useState(new Animated.Value(selectedIndex * itemHeight));
|
|
56
|
-
|
|
57
|
-
const containerHeight = (1 + visibleRest * 2) * itemHeight;
|
|
58
|
-
const paddedOptions = useMemo(() => {
|
|
59
|
-
const array: (PickerOption | null)[] = [...options];
|
|
60
|
-
for (let i = 0; i < visibleRest; i++) {
|
|
61
|
-
array.unshift(null);
|
|
62
|
-
array.push(null);
|
|
63
|
-
}
|
|
64
|
-
return array;
|
|
65
|
-
}, [options, visibleRest]);
|
|
66
|
-
|
|
67
|
-
const offsets = useMemo(
|
|
68
|
-
() => [...Array(paddedOptions.length)].map((_, i) => i * itemHeight),
|
|
69
|
-
[paddedOptions, itemHeight]
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const currentScrollIndex = useMemo(
|
|
73
|
-
() => Animated.add(Animated.divide(scrollY, itemHeight), visibleRest),
|
|
74
|
-
[visibleRest, scrollY, itemHeight]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const handleScrollEnd = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
78
|
-
const offsetY = Math.min(
|
|
79
|
-
itemHeight * (options.length - 1),
|
|
80
|
-
Math.max(event.nativeEvent.contentOffset.y, 0)
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
let index = Math.floor(offsetY / itemHeight);
|
|
84
|
-
const remainder = offsetY % itemHeight;
|
|
85
|
-
if (remainder > itemHeight / 2) {
|
|
86
|
-
index++;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (index !== selectedIndex) {
|
|
90
|
-
onChange(options[index]?.value || 0);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const handleMomentumScrollBegin = () => {
|
|
95
|
-
momentumStarted.current = true;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const handleMomentumScrollEnd = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
99
|
-
momentumStarted.current = false;
|
|
100
|
-
handleScrollEnd(event);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const handleScrollEndDrag = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
104
|
-
// Capture the offset value immediately
|
|
105
|
-
const offsetY = event.nativeEvent.contentOffset?.y;
|
|
106
|
-
|
|
107
|
-
// We'll start a short timer to see if momentum scroll begins
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
// If momentum scroll hasn't started within the timeout,
|
|
110
|
-
// then it was a slow scroll that won't trigger momentum
|
|
111
|
-
if (!momentumStarted.current && offsetY !== undefined) {
|
|
112
|
-
// Create a synthetic event with just the data we need
|
|
113
|
-
const syntheticEvent = {
|
|
114
|
-
nativeEvent: {
|
|
115
|
-
contentOffset: { y: offsetY },
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
handleScrollEnd(syntheticEvent as any);
|
|
119
|
-
}
|
|
120
|
-
}, 50);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (selectedIndex < 0 || selectedIndex >= options.length) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
`Selected index ${selectedIndex} is out of bounds [0, ${options.length - 1}]`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}, [selectedIndex, options]);
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* If selectedIndex is changed from outside (not via onChange) we need to scroll to the specified index.
|
|
133
|
-
* This ensures that what the user sees as selected in the picker always corresponds to the value state.
|
|
134
|
-
*/
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
flatListRef.current?.scrollToIndex({
|
|
137
|
-
index: selectedIndex,
|
|
138
|
-
animated: Platform.OS === 'ios',
|
|
139
|
-
});
|
|
140
|
-
}, [selectedIndex, itemHeight]);
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<View
|
|
144
|
-
style={[styles.container, { height: containerHeight }, containerStyle]}
|
|
145
|
-
{...containerProps}
|
|
146
|
-
>
|
|
147
|
-
<View
|
|
148
|
-
style={[
|
|
149
|
-
styles.selectedIndicator,
|
|
150
|
-
selectedIndicatorStyle,
|
|
151
|
-
{
|
|
152
|
-
transform: [{ translateY: -itemHeight / 2 }],
|
|
153
|
-
height: itemHeight,
|
|
154
|
-
},
|
|
155
|
-
]}
|
|
156
|
-
/>
|
|
157
|
-
<Animated.FlatList<PickerOption | null>
|
|
158
|
-
{...flatListProps}
|
|
159
|
-
ref={flatListRef}
|
|
160
|
-
nestedScrollEnabled
|
|
161
|
-
style={styles.scrollView}
|
|
162
|
-
showsVerticalScrollIndicator={false}
|
|
163
|
-
onScroll={Animated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], {
|
|
164
|
-
useNativeDriver: true,
|
|
165
|
-
})}
|
|
166
|
-
onScrollEndDrag={handleScrollEndDrag}
|
|
167
|
-
onMomentumScrollBegin={handleMomentumScrollBegin}
|
|
168
|
-
onMomentumScrollEnd={handleMomentumScrollEnd}
|
|
169
|
-
snapToOffsets={offsets}
|
|
170
|
-
decelerationRate={decelerationRate}
|
|
171
|
-
initialScrollIndex={selectedIndex}
|
|
172
|
-
getItemLayout={(_, index) => ({
|
|
173
|
-
length: itemHeight,
|
|
174
|
-
offset: itemHeight * index,
|
|
175
|
-
index,
|
|
176
|
-
})}
|
|
177
|
-
data={paddedOptions}
|
|
178
|
-
keyExtractor={(item, index) =>
|
|
179
|
-
item ? `${item.value}-${item.text}-${index}` : `null-${index}`
|
|
180
|
-
}
|
|
181
|
-
renderItem={({ item: option, index }) => (
|
|
182
|
-
<WheelPickerItem
|
|
183
|
-
key={`option-${index}`}
|
|
184
|
-
index={index}
|
|
185
|
-
option={option}
|
|
186
|
-
style={itemStyle}
|
|
187
|
-
height={itemHeight}
|
|
188
|
-
currentScrollIndex={currentScrollIndex}
|
|
189
|
-
scaleFunction={scaleFunction}
|
|
190
|
-
rotationFunction={rotationFunction}
|
|
191
|
-
opacityFunction={opacityFunction}
|
|
192
|
-
visibleRest={visibleRest}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
/>
|
|
196
|
-
</View>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export default memo(WheelPicker);
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { memo, useMemo, useRef } from 'react';
|
|
2
|
-
import { Animated, PanResponder, Platform, View } from 'react-native';
|
|
3
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
import { isEqual } from '../../../utils';
|
|
5
|
-
import { BodyText } from '../../BodyText';
|
|
6
|
-
import { PickerOption } from '../DatePicker.props';
|
|
7
|
-
import { CONTAINER_HEIGHT } from '../enums';
|
|
8
|
-
import { sin } from './animated-math';
|
|
9
|
-
|
|
10
|
-
interface WheelProps {
|
|
11
|
-
value: number | string;
|
|
12
|
-
setValue?: (value: any) => void;
|
|
13
|
-
items: PickerOption[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const ITEM_HEIGHT = 44;
|
|
17
|
-
|
|
18
|
-
const WheelWeb = ({ value, setValue = () => {}, items }: WheelProps) => {
|
|
19
|
-
const displayCount = 5;
|
|
20
|
-
const translateY = useRef(new Animated.Value(0)).current;
|
|
21
|
-
const renderCount = displayCount * 2 < items.length ? displayCount * 8 : displayCount * 2 - 1;
|
|
22
|
-
const circular = items.length >= displayCount;
|
|
23
|
-
const height = 140;
|
|
24
|
-
const radius = height / 2;
|
|
25
|
-
|
|
26
|
-
const valueIndex = useMemo(() => {
|
|
27
|
-
return Math.max(
|
|
28
|
-
0,
|
|
29
|
-
items.findIndex(item => item.value === value)
|
|
30
|
-
);
|
|
31
|
-
}, [items, value]);
|
|
32
|
-
|
|
33
|
-
const panResponder = useMemo(() => {
|
|
34
|
-
return PanResponder.create({
|
|
35
|
-
onMoveShouldSetPanResponder: () => true,
|
|
36
|
-
onStartShouldSetPanResponderCapture: () => true,
|
|
37
|
-
onPanResponderGrant: () => {
|
|
38
|
-
translateY.setValue(0);
|
|
39
|
-
},
|
|
40
|
-
onPanResponderMove: (evt, gestureState) => {
|
|
41
|
-
translateY.setValue(gestureState.dy);
|
|
42
|
-
evt.stopPropagation();
|
|
43
|
-
},
|
|
44
|
-
onPanResponderRelease: (_, gestureState) => {
|
|
45
|
-
translateY.extractOffset();
|
|
46
|
-
let newValueIndex =
|
|
47
|
-
valueIndex - Math.round(gestureState.dy / ((radius * 2) / displayCount));
|
|
48
|
-
if (circular) {
|
|
49
|
-
newValueIndex = (newValueIndex + items.length) % items.length;
|
|
50
|
-
} else {
|
|
51
|
-
if (newValueIndex < 0) {
|
|
52
|
-
newValueIndex = 0;
|
|
53
|
-
} else if (newValueIndex >= items.length) {
|
|
54
|
-
newValueIndex = items.length - 1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const newValue = items[newValueIndex];
|
|
58
|
-
if (newValue?.value === value) {
|
|
59
|
-
translateY.setOffset(0);
|
|
60
|
-
translateY.setValue(0);
|
|
61
|
-
} else if (newValue?.value) {
|
|
62
|
-
setValue(newValue.value);
|
|
63
|
-
} else if (items[0]?.value) {
|
|
64
|
-
setValue(items[0].value);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}, [circular, displayCount, radius, setValue, value, valueIndex, items, translateY]);
|
|
69
|
-
|
|
70
|
-
const displayValues = useMemo(() => {
|
|
71
|
-
const centerIndex = Math.floor(renderCount / 2);
|
|
72
|
-
|
|
73
|
-
return Array.from({ length: renderCount }, (_, index) => {
|
|
74
|
-
let targetIndex = valueIndex + index - centerIndex;
|
|
75
|
-
if (circular) {
|
|
76
|
-
targetIndex = ((targetIndex % items.length) + items.length) % items.length;
|
|
77
|
-
} else {
|
|
78
|
-
targetIndex = Math.max(0, Math.min(targetIndex, items.length - 1));
|
|
79
|
-
}
|
|
80
|
-
return items[targetIndex] || items[0];
|
|
81
|
-
});
|
|
82
|
-
}, [renderCount, valueIndex, items, circular]);
|
|
83
|
-
|
|
84
|
-
const animatedAngles = useMemo(() => {
|
|
85
|
-
//translateY.setValue(0);
|
|
86
|
-
translateY.setOffset(0);
|
|
87
|
-
const currentIndex = displayValues.findIndex(item => item?.value === value);
|
|
88
|
-
return displayValues && displayValues.length > 0
|
|
89
|
-
? displayValues.map((_, index) =>
|
|
90
|
-
translateY
|
|
91
|
-
.interpolate({
|
|
92
|
-
inputRange: [-radius, radius],
|
|
93
|
-
outputRange: [
|
|
94
|
-
-radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
95
|
-
radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
96
|
-
],
|
|
97
|
-
extrapolate: 'extend',
|
|
98
|
-
})
|
|
99
|
-
.interpolate({
|
|
100
|
-
inputRange: [-radius, radius],
|
|
101
|
-
outputRange: [-Math.PI / 2, Math.PI / 2],
|
|
102
|
-
extrapolate: 'clamp',
|
|
103
|
-
})
|
|
104
|
-
)
|
|
105
|
-
: [];
|
|
106
|
-
}, [displayValues, radius, value, displayCount, translateY]);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<View style={[styles.container]} {...panResponder.panHandlers}>
|
|
110
|
-
<View
|
|
111
|
-
style={[
|
|
112
|
-
styles.selectedIndicator,
|
|
113
|
-
{
|
|
114
|
-
transform: [{ translateY: -ITEM_HEIGHT / 2 }],
|
|
115
|
-
height: ITEM_HEIGHT,
|
|
116
|
-
},
|
|
117
|
-
]}
|
|
118
|
-
/>
|
|
119
|
-
{displayValues?.map((displayValue, index) => {
|
|
120
|
-
const animatedAngle = animatedAngles[index];
|
|
121
|
-
return (
|
|
122
|
-
<Animated.View
|
|
123
|
-
key={`${displayValue?.text}-${index}`}
|
|
124
|
-
style={{
|
|
125
|
-
position: 'absolute',
|
|
126
|
-
height: ITEM_HEIGHT - 10,
|
|
127
|
-
transform: animatedAngle
|
|
128
|
-
? [
|
|
129
|
-
{
|
|
130
|
-
translateY: Animated.multiply(radius, sin(animatedAngle)),
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
rotateX: animatedAngle.interpolate({
|
|
134
|
-
inputRange: [-Math.PI / 2, Math.PI / 2],
|
|
135
|
-
outputRange: ['-89deg', '89deg'],
|
|
136
|
-
extrapolate: 'clamp',
|
|
137
|
-
}),
|
|
138
|
-
},
|
|
139
|
-
]
|
|
140
|
-
: [],
|
|
141
|
-
opacity: displayValue?.value !== value ? 0.3 : 1,
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
<BodyText>{displayValue?.text}</BodyText>
|
|
145
|
-
</Animated.View>
|
|
146
|
-
);
|
|
147
|
-
})}
|
|
148
|
-
</View>
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const styles = StyleSheet.create({
|
|
153
|
-
container: {
|
|
154
|
-
minWidth: 30,
|
|
155
|
-
overflow: 'hidden',
|
|
156
|
-
alignItems: 'center',
|
|
157
|
-
justifyContent: 'center',
|
|
158
|
-
height: CONTAINER_HEIGHT / 2,
|
|
159
|
-
...Platform.select({
|
|
160
|
-
web: {
|
|
161
|
-
cursor: 'pointer',
|
|
162
|
-
userSelect: 'none',
|
|
163
|
-
},
|
|
164
|
-
}),
|
|
165
|
-
},
|
|
166
|
-
selectedIndicator: {
|
|
167
|
-
position: 'absolute',
|
|
168
|
-
width: '100%',
|
|
169
|
-
top: '50%',
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const customComparator = (prev: Readonly<WheelProps>, next: Readonly<WheelProps>) => {
|
|
174
|
-
const areEqual =
|
|
175
|
-
prev.value === next.value && prev.setValue === next.setValue && isEqual(prev.items, next.items);
|
|
176
|
-
|
|
177
|
-
return areEqual;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default memo(WheelWeb, customComparator);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { PickerOption } from '../DatePicker.props';
|
|
4
|
-
import WheelNative from './wheel-native';
|
|
5
|
-
import WheelWeb from './wheel-web';
|
|
6
|
-
|
|
7
|
-
type WheelProps = {
|
|
8
|
-
value: number | string;
|
|
9
|
-
setValue?: (value: any) => void;
|
|
10
|
-
items: PickerOption[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Wheel = (props: WheelProps) => {
|
|
14
|
-
const Component = Platform.OS === 'web' ? WheelWeb : WheelNative;
|
|
15
|
-
return <Component {...props} />;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default memo(Wheel);
|