Skip to content

Fix/ segmentedControl paddings #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/components/segmentedControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const {interpolate: _interpolate, interpolateNode} = Reanimated;
const interpolate = interpolateNode || _interpolate;
const Easing = EasingNode || _Easing;
const BORDER_WIDTH = 1;
const HORIZONTAL_PADDING = Spacings.s2;

export type SegmentedControlItemProps = SegmentProps;
export type SegmentedControlProps = {
Expand Down Expand Up @@ -115,7 +114,7 @@ const SegmentedControl = (props: SegmentedControlProps) => {
const onLayout = useCallback((index: number, event: LayoutChangeEvent) => {
const {x, width, height} = event.nativeEvent.layout;
segmentsStyle.current[index] = {x, width};
segmentedControlHeight.current = height + 2 * (HORIZONTAL_PADDING - BORDER_WIDTH);
segmentedControlHeight.current = height - 2 * BORDER_WIDTH;
segmentsCounter.current++;

return segmentsCounter.current === segments?.length && setSelectedSegment(initialIndex);
Expand Down Expand Up @@ -184,7 +183,6 @@ const styles = StyleSheet.create({
container: {
backgroundColor: Colors.grey80,
borderColor: Colors.grey60,
paddingVertical: HORIZONTAL_PADDING,
borderWidth: BORDER_WIDTH
},
selectedSegment: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/segmentedControl/segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Segment = React.memo((props: SegmentProps) => {
const segmentedColor = useMemo(() => (isSelected ? activeColor : inactiveColor),
[isSelected, activeColor, inactiveColor]);

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

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