This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const onChangeToggle = () => { | |
| setToggled(!toggled); | |
| onChange?.(!toggled); | |
| }; | |
| const onPressSwitch = () => { | |
| if (shareValue.value === 0) { | |
| shareValue.value = withTiming(1, { | |
| duration: 800, | |
| easing: Easing.bezier(0.4, 0.0, 0.2, 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///... | |
| const containerScale = { | |
| height: BUTTON_HEIGHT, | |
| width: BUTTON_WIDTH, | |
| }; | |
| const switchScale = { | |
| height: SWITCH_BUTTON_AREA, | |
| width: SWITCH_BUTTON_AREA, | |
| }; | |
| //... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///... | |
| const BUTTON_WIDTH = width; | |
| const BUTTON_HEIGHT = height; | |
| const SWITCH_BUTTON_AREA = BUTTON_HEIGHT - SWITCH_BUTTON_PADDING; | |
| const [toggled, setToggled] = useState(value); | |
| const shareValue = useSharedValue(value ? 1 : 0); | |
| ///... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {useState, useRef} from 'react'; | |
| import {Animated, Easing, TextInput, StyleSheet} from 'react-native'; | |
| const FlaotingTextInput = ({ | |
| label = 'New Title', | |
| titleActiveSize = 12, | |
| titleInActiveSize = 14, | |
| titleActiveColor = '#444444', | |
| titleInactiveColor = '#c2c2c2', | |
| }) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .../ | |
| <Animated.View style={[styles.subContainer, viewStyles]}> | |
| <Animated.Text style={[returnAnimatedTitleStyles]}>{label}</Animated.Text> | |
| <TextInput | |
| onChangeText={onChangeText} | |
| value={text} | |
| style={styles.textStyle} | |
| onBlur={onBlur} | |
| onFocus={onFocus} | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Animated.timing(animatedValue?.current, { | |
| toValue: 1, | |
| duration: 500, | |
| easing: Easing.bezier(0.4, 0.0, 0.2, 1), | |
| useNativeDriver: false, | |
| }).start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const returnAnimatedTitleStyles = { | |
| transform: [ | |
| { | |
| translateY: animatedValue?.current?.interpolate({ | |
| inputRange: [0, 1], | |
| outputRange: [22, -4], | |
| extrapolate: 'clamp', | |
| }), | |
| }, | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock')); | |
| jest.mock("react-native-reanimated", () => ({ | |
| ...mock, | |
| useSharedValue: jest.fn().mockReturnValue(0), | |
| useAnimatedStyle: jest.fn().mockReturnValue({}), | |
| useAnimatedScrollHandler: jest.fn().mockReturnValue({}), | |
| createAnimatedComponent: (component) => jest.fn().mockReturnValue(component), | |
| __reanimatedWorkletInit: jest.fn(), | |
| ScrollView: "ScrollView", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const animatedStyle = useAnimatedStyle(() => { | |
| return { | |
| backgroundColor: interpolateColor( | |
| progress.value, | |
| [0, 1], | |
| ['red', 'green'] | |
| ), | |
| }; | |
| }); |