Skip to content

Commit af9cb1d

Browse files
authored
fix vertical paddings (#1401)
1 parent bb5f9f9 commit af9cb1d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/components/segmentedControl/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const {interpolate: _interpolate, interpolateNode} = Reanimated;
1111
const interpolate = interpolateNode || _interpolate;
1212
const Easing = EasingNode || _Easing;
1313
const BORDER_WIDTH = 1;
14-
const HORIZONTAL_PADDING = Spacings.s2;
1514

1615
export type SegmentedControlItemProps = SegmentProps;
1716
export type SegmentedControlProps = {
@@ -115,7 +114,7 @@ const SegmentedControl = (props: SegmentedControlProps) => {
115114
const onLayout = useCallback((index: number, event: LayoutChangeEvent) => {
116115
const {x, width, height} = event.nativeEvent.layout;
117116
segmentsStyle.current[index] = {x, width};
118-
segmentedControlHeight.current = height + 2 * (HORIZONTAL_PADDING - BORDER_WIDTH);
117+
segmentedControlHeight.current = height - 2 * BORDER_WIDTH;
119118
segmentsCounter.current++;
120119

121120
return segmentsCounter.current === segments?.length && setSelectedSegment(initialIndex);
@@ -184,7 +183,6 @@ const styles = StyleSheet.create({
184183
container: {
185184
backgroundColor: Colors.grey80,
186185
borderColor: Colors.grey60,
187-
paddingVertical: HORIZONTAL_PADDING,
188186
borderWidth: BORDER_WIDTH
189187
},
190188
selectedSegment: {

src/components/segmentedControl/segment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const Segment = React.memo((props: SegmentProps) => {
7474
const segmentedColor = useMemo(() => (isSelected ? activeColor : inactiveColor),
7575
[isSelected, activeColor, inactiveColor]);
7676

77-
const segmentStyle = useMemo(() => ({paddingHorizontal: Spacings.s3, borderColor: segmentedColor}), [segmentedColor]);
77+
const segmentStyle = useMemo(() => ({paddingHorizontal: Spacings.s3, paddingVertical: Spacings.s2}), []);
7878

7979
const renderIcon = useCallback(() => {
8080
return iconSource && <Image source={iconSource} style={[{tintColor: segmentedColor}, iconStyle]}/>;

0 commit comments

Comments
 (0)