Skip to content

Commit

Permalink
Merge pull request #859 from thundersdata-frontend/rn-issue
Browse files Browse the repository at this point in the history
fix: 修复slider组件滑动不到最后的bug
  • Loading branch information
chj-damon authored Apr 30, 2024
2 parents 2edc68a + d7cda0b commit 5cb3dc2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-bottles-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native': patch
---

fix: 修复slider组件滑动不到最后的bug
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ const NumberKeyboardModal: FC<
<SvgIcon name="down" size={px(20)} color={theme.colors.gray500} />
</Pressable>
</Flex>
<NumberKeyboardView type={type} allowNegative={allowNegative} onPress={handleChange} onDelete={handleDelete} onSubmit={handleSubmit} />
<NumberKeyboardView
type={type}
allowNegative={allowNegative}
onPress={handleChange}
onDelete={handleDelete}
onSubmit={handleSubmit}
/>
</Modal>
);
};
Expand Down
80 changes: 42 additions & 38 deletions packages/react-native/src/number-keyboard/NumberKeyboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,44 +49,48 @@ const NumberKeyboardView: FC<NumberKeyboardViewProps> = ({
});

const keyTypes = useMemo(() => {
const numberType = allowNegative ? [
{
key: '0',
flex: 1,
},
{
key: '.',
flex: 1,
},
{
key: '-',
flex: 1,
},
] : [
{
key: '0',
flex: 2,
},
{
key: '.',
flex: 1,
},
];
const integerType = allowNegative ? [
{
key: '0',
flex: 2,
},
{
key: '-',
flex: 1,
},
] : [
{
key: '0',
flex: 1,
},
];
const numberType = allowNegative
? [
{
key: '0',
flex: 1,
},
{
key: '.',
flex: 1,
},
{
key: '-',
flex: 1,
},
]
: [
{
key: '0',
flex: 2,
},
{
key: '.',
flex: 1,
},
];
const integerType = allowNegative
? [
{
key: '0',
flex: 2,
},
{
key: '-',
flex: 1,
},
]
: [
{
key: '0',
flex: 1,
},
];

const types = {
number: numberType,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/src/number-keyboard/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export interface NumberKeyboardViewProps {
allowNegative?: boolean;
}

export interface NumberKeyboardItemProps extends Pick<NumberKeyboardViewProps, 'type' | 'activeOpacity' | 'allowNegative'> {
export interface NumberKeyboardItemProps
extends Pick<NumberKeyboardViewProps, 'type' | 'activeOpacity' | 'allowNegative'> {
value?: string;
onChange?: (value: string) => void;
onCheck?: (value: string) => Promise<any>;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Slider: FC<SliderProps> = props => {
} = props;
const KNOB_WIDTH = height;
const sliderRange = width - KNOB_WIDTH;
const oneStepValue = Math.floor(sliderRange / (max - min)) || 1;
const oneStepValue = Math.ceil(sliderRange / (max - min)) || 1;

const { progressStyle, knobStyle, onGestureEvent, label } = useSlider({
min,
Expand Down

0 comments on commit 5cb3dc2

Please sign in to comment.