Skip to content

Commit c8ab8e1

Browse files
Merge pull request #39 from SimformSolutionsPvtLtd/fix/UNT-T17038
fix(UNT-T17038): fix design and render issues
2 parents a2624ab + fe76c51 commit c8ab8e1

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/components/RadialSlider/ButtonContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const ButtonContent = (props: ButtonProps) => {
1616
style={style}>
1717
<Svg height="30" width="45">
1818
<G>
19-
<Circle cx="20" cy="20" r="20" />
19+
<Circle cx="20" cy="20" r="20" fill="none" />
2020
<Path
2121
d={
2222
buttonType === 'left-btn'
@@ -27,6 +27,7 @@ const ButtonContent = (props: ButtonProps) => {
2727
strokeWidth="2.4"
2828
strokeLinecap="round"
2929
strokeLinejoin="round"
30+
fill="none"
3031
/>
3132
</G>
3233
</Svg>

src/components/RadialSlider/RadialSlider.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Svg, {
55
LinearGradient,
66
Stop,
77
Circle,
8-
Color,
98
NumberProp,
109
} from 'react-native-svg';
1110
import { View, Platform, StyleSheet } from 'react-native';
@@ -48,7 +47,6 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
4847
leftIconStyle,
4948
rightIconStyle,
5049
stroke,
51-
onChange = () => {},
5250
} = props;
5351

5452
const { panResponder, value, setValue, curPoint, currentRadian, prevValue } =
@@ -109,14 +107,12 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
109107

110108
return prevState + step;
111109
});
112-
onChange(value);
113110
} else if (type === 'down' && min < value) {
114111
setValue((prevState: number) => {
115112
prevValue.current = prevState - step;
116113

117114
return prevState - step;
118115
});
119-
onChange(value);
120116
}
121117
};
122118

@@ -147,7 +143,7 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
147143
(
148144
item: {
149145
offset: NumberProp | undefined;
150-
color: Color | undefined;
146+
color: string | undefined;
151147
},
152148
index: React.Key | null | undefined
153149
) => (

src/components/RadialSlider/SpeedoMeter.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Svg, {
44
Defs,
55
LinearGradient,
66
Stop,
7-
Color,
87
NumberProp,
98
Linecap,
109
} from 'react-native-svg';
@@ -96,7 +95,7 @@ const SpeedoMeter = (
9695
(
9796
item: {
9897
offset: NumberProp | undefined;
99-
color: Color | undefined;
98+
color: string | undefined;
10099
},
101100
index: React.Key | null | undefined
102101
) => (

src/components/RadialSlider/hooks/useSilderAnimation.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useState, useRef, useEffect } from 'react';
1+
import { useEffect, useRef, useState } from 'react';
22
import {
3-
PanResponder,
43
GestureResponderEvent,
4+
PanResponder,
55
PanResponderGestureState,
66
} from 'react-native';
77
import {
@@ -51,6 +51,20 @@ const useSilderAnimation = (props: RadialSliderAnimationHookProps) => {
5151
// eslint-disable-next-line react-hooks/exhaustive-deps
5252
}, [max, min]);
5353

54+
useEffect(() => {
55+
if (min <= props?.value && max >= props?.value) {
56+
setValue(props?.value);
57+
prevValue.current = props?.value;
58+
}
59+
// eslint-disable-next-line react-hooks/exhaustive-deps
60+
}, [props?.value]);
61+
62+
useEffect(() => {
63+
onChange(value);
64+
prevValue.current = value;
65+
// eslint-disable-next-line react-hooks/exhaustive-deps
66+
}, [value]);
67+
5468
const handlePanResponderGrant = () => {
5569
moveStartValue = prevValue.current;
5670
moveStartRadian = getRadianByValue(
@@ -118,7 +132,7 @@ const useSilderAnimation = (props: RadialSliderAnimationHookProps) => {
118132
if (disabled) {
119133
return;
120134
}
121-
onComplete(value);
135+
onComplete(prevValue.current);
122136
};
123137

124138
const panResponder = useRef(

0 commit comments

Comments
 (0)