Skip to content

Commit bf7fe36

Browse files
committed
Merge branch 'master' into release
2 parents 5b5e024 + 9b677ee commit bf7fe36

File tree

14 files changed

+318
-250
lines changed

14 files changed

+318
-250
lines changed

src/components/WheelPicker/Item.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const WheelPickerItem = memo(({
7373
return [animatedColorStyle, style, fakeLabel ? textWithLabelPaddingStyle : styles.textPadding];
7474
}, [style, fakeLabel, animatedColorStyle, textWithLabelPaddingStyle]);
7575

76+
const _fakeLabelStyle = useMemo(() => StyleSheet.flatten([fakeLabelStyle, styles.hidden]), [fakeLabelStyle]);
7677
return (
7778
<AnimatedTouchableOpacity
7879
activeOpacity={1}
@@ -88,22 +89,11 @@ const WheelPickerItem = memo(({
8889
testID={testID}
8990
row
9091
>
91-
<AnimatedText
92-
text60R
93-
testID={`${testID}.text`}
94-
numberOfLines={1}
95-
style={textStyle}
96-
recorderTag={'unmask'}
97-
>
92+
<AnimatedText text60R testID={`${testID}.text`} numberOfLines={1} style={textStyle} recorderTag={'unmask'}>
9893
{label}
9994
</AnimatedText>
10095
{fakeLabel && (
101-
<Text
102-
text80M
103-
$textDefaultLight
104-
{...fakeLabelProps}
105-
style={fakeLabelStyle}
106-
>
96+
<Text text80M $textDefaultLight {...fakeLabelProps} style={_fakeLabelStyle}>
10797
{fakeLabel}
10898
</Text>
10999
)}
@@ -122,5 +112,8 @@ const styles = StyleSheet.create({
122112
},
123113
disableRTL: {
124114
flexDirection: 'row-reverse'
115+
},
116+
hidden: {
117+
opacity: 0
125118
}
126119
});

src/components/colorPicker/index.tsx

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {PureComponent} from 'react';
1+
import React, {useCallback, useState} from 'react';
22
import {StyleSheet} from 'react-native';
33
import {asBaseComponent} from '../../commons/new';
44
import Assets from '../../assets';
@@ -58,77 +58,65 @@ const ACCESSIBILITY_LABELS = {
5858
* @notes: This is a screen width component
5959
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/ColorPicker/ColorPicker.gif?raw=true
6060
*/
61-
class ColorPicker extends PureComponent<Props> {
62-
static displayName = 'ColorPicker';
61+
const ColorPicker = (props: Props) => {
62+
const {
63+
accessibilityLabels = ACCESSIBILITY_LABELS,
64+
backgroundColor = Colors.$backgroundDefault,
65+
initialColor,
66+
colors,
67+
value,
68+
testID,
69+
onValueChange,
70+
animatedIndex
71+
} = props;
72+
const [show, setShow] = useState(false);
6373

64-
static defaultProps = {
65-
accessibilityLabels: ACCESSIBILITY_LABELS,
66-
backgroundColor: Colors.$backgroundDefault
67-
};
68-
69-
state = {
70-
show: false
71-
};
74+
const showDialog = useCallback(() => setShow(true), []);
7275

73-
get animatedIndex() {
74-
const {animatedIndex, colors} = this.props;
75-
if (animatedIndex === undefined) {
76-
return colors.length - 1;
77-
}
78-
return animatedIndex;
79-
}
76+
const hideDialog = useCallback(() => setShow(false), []);
8077

81-
showDialog = () => {
82-
this.setState({show: true});
83-
};
84-
85-
hideDialog = () => {
86-
this.setState({show: false});
87-
};
88-
89-
render() {
90-
const {initialColor, colors, value, testID, accessibilityLabels, backgroundColor, onValueChange} = this.props;
91-
const {show} = this.state;
92-
return (
93-
<View row testID={testID} style={{backgroundColor}}>
94-
<ColorPalette
95-
value={value}
96-
colors={colors}
97-
style={styles.palette}
98-
usePagination={false}
99-
animatedIndex={this.animatedIndex}
100-
onValueChange={onValueChange}
101-
testID={`${testID}-palette`}
102-
backgroundColor={backgroundColor}
103-
/>
104-
<View style={[styles.buttonContainer, {backgroundColor}]}>
105-
<Button
106-
color={Colors.$textDefault}
107-
outlineColor={Colors.$textDefault}
108-
style={styles.button}
109-
round
110-
outline
111-
iconSource={Assets.icons.plusSmall}
112-
onPress={this.showDialog}
113-
testID={`${testID}-button`}
114-
accessibilityLabel={accessibilityLabels?.addButton}
115-
/>
116-
</View>
117-
<ColorPickerDialog
118-
{...this.props}
119-
key={initialColor}
120-
visible={show}
121-
onDismiss={this.hideDialog}
122-
accessibilityLabels={{
123-
dismissButton: accessibilityLabels?.dismissButton,
124-
doneButton: accessibilityLabels?.doneButton,
125-
input: accessibilityLabels?.input
126-
}}
78+
return (
79+
<View row testID={testID} style={{backgroundColor}}>
80+
<ColorPalette
81+
value={value}
82+
colors={colors}
83+
style={styles.palette}
84+
usePagination={false}
85+
animatedIndex={animatedIndex ?? colors.length - 1}
86+
onValueChange={onValueChange}
87+
testID={`${testID}-palette`}
88+
backgroundColor={backgroundColor}
89+
/>
90+
<View style={[styles.buttonContainer, {backgroundColor}]}>
91+
<Button
92+
color={Colors.$textDefault}
93+
outlineColor={Colors.$textDefault}
94+
style={styles.button}
95+
round
96+
outline
97+
iconSource={Assets.icons.plusSmall}
98+
onPress={showDialog}
99+
testID={`${testID}-button`}
100+
accessibilityLabel={accessibilityLabels?.addButton}
127101
/>
128102
</View>
129-
);
130-
}
131-
}
103+
<ColorPickerDialog
104+
{...props}
105+
key={initialColor}
106+
visible={show}
107+
onDismiss={hideDialog}
108+
accessibilityLabels={{
109+
dismissButton: accessibilityLabels?.dismissButton,
110+
doneButton: accessibilityLabels?.doneButton,
111+
input: accessibilityLabels?.input
112+
}}
113+
migrate
114+
/>
115+
</View>
116+
);
117+
};
118+
119+
ColorPicker.displayName = 'ColorPicker';
132120

133121
export default asBaseComponent<Props>(ColorPicker);
134122

src/components/image/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Image extends PureComponent<Props, State> {
207207
renderImage = (useImageInsideContainer: boolean) => {
208208
const {error} = this.state;
209209
const source = error ? this.getVerifiedSource(this.props.errorSource) : this.getImageSource();
210+
210211
const {
211212
tintColor,
212213
style,

src/components/numberInput/Presenter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function factor(options: Options): number {
5050
}
5151

5252
export function getInitialNumber(propsInitialNumber = 0, options: Options) {
53-
return propsInitialNumber * factor(options);
53+
return Number((propsInitialNumber * factor(options)).toFixed(0));
5454
}
5555

5656
export function parseInput(text: string, options: Options, initialNumber?: number): NumberInputData {

src/components/numberInput/__tests__/Presenter.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ describe('NumberInput', () => {
3939
it('should return 10 for 1 if fractionDigits is 1', () => {
4040
expect(getInitialNumber(1, {...EN_OPTIONS, fractionDigits: 1})).toEqual(10);
4141
});
42+
43+
it('Handle wrong result with some X.XX numbers', () => {
44+
expect(getInitialNumber(8.97, {...EN_OPTIONS})).toEqual(897);
45+
});
4246
});
4347

4448
describe('getInitialData', () => {

0 commit comments

Comments
 (0)