Skip to content

Commit

Permalink
Merge pull request #177 from ZeroGachis/task/fix-number-selector
Browse files Browse the repository at this point in the history
🐛 SORD - rewrite props
  • Loading branch information
ulricden authored Jan 30, 2024
2 parents 7a45602 + 12789d2 commit fdac469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/components/modifyQuantity/ModifyQuantity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export const ModifyQuantity = ({
justifyContent: 'center',
},
});

const onEndEditing = (value: string | undefined) => {
if (value) {
onValueChange(Number(value));
}
};

return (
<View style={styles.container}>
<View style={styles.iconContainer}>
Expand All @@ -76,15 +83,10 @@ export const ModifyQuantity = ({
<Body style={styles.text}>{text}</Body>
</View>
<NumberSelector
minValue={minValue}
maxValue={maxValue}
onValueChange={onValueChange}
value={value}
validator={new NumberValidator(0, 10, false)}
validator={new NumberValidator(minValue, maxValue, false)}
initialValue={undefined}
onEndEditing={function (_: string | undefined): void {
throw new Error('Function not implemented.');
}}
onEndEditing={onEndEditing}
/>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/numberSelector/NumberSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface Props {
validator: NumberValidator;
initialValue: number | undefined;
value: number | undefined;
onValueChange?: (value: number) => void;
onEndEditing: (value: string | undefined) => void;
style?: ViewStyle;
minusIcon?: IconName;
Expand All @@ -25,6 +24,7 @@ export interface Props {
export const RoundValue = (val: number): number => {
return Math.round(val * 10) / 10;
};

export const ComputeCrementedValue = (
value: number,
step: number,
Expand Down

0 comments on commit fdac469

Please sign in to comment.