Skip to content
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
7 changes: 5 additions & 2 deletions src/components/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useEffect} from 'react';
import {InteractionManager} from 'react-native';
import Animated, {interpolateColor, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -38,13 +38,16 @@ function Switch({isOn, onToggle, accessibilityLabel, disabled, showLockIcon, dis
const offsetX = useSharedValue(isOn ? OFFSET_X.ON : OFFSET_X.OFF);
const theme = useTheme();

useEffect(() => {
offsetX.set(withTiming(isOn ? OFFSET_X.ON : OFFSET_X.OFF, {duration: 300}));
}, [isOn, offsetX]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect caused minor bug.
More details: #79863 (comment), #79863 (comment)


const handleSwitchPress = () => {
InteractionManager.runAfterInteractions(() => {
if (disabled) {
disabledAction?.();
return;
}
offsetX.set(withTiming(isOn ? OFFSET_X.OFF : OFFSET_X.ON, {duration: 300}));
onToggle(!isOn);
});
};
Expand Down
2 changes: 2 additions & 0 deletions src/styles/utils/generators/TooltipStyleUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ const createTooltipStyleUtils: StyleUtilGenerator<GetTooltipStylesStyleUtil> = (

/** Utility function to create and manage scale animations with React Native Reanimated */
getTooltipAnimatedStyles: (props: TooltipAnimationProps) => {
'worklet';

const tooltipHorizontalPadding = spacing.ph2.paddingHorizontal * 2;
const tooltipWidth = props.tooltipContentWidth && props.tooltipContentWidth + tooltipHorizontalPadding + 1;
const isTooltipSizeReady = tooltipWidth !== undefined && props.tooltipWrapperHeight !== undefined;
Expand Down
Loading