-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: `useHeaderMeasurements` now returns the `height` as an `Animated.SharedValue`
- Loading branch information
1 parent
90de549
commit 73ee5d7
Showing
6 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// courtesy of https://github.com/wcandillon/react-native-redash/blob/fd0b0ddb3b4c10ae88cf1f8a95890c7c5eb3c475/src/ReText.tsx | ||
|
||
import React from 'react' | ||
import type { TextProps as RNTextProps } from 'react-native' | ||
import { StyleSheet, TextInput } from 'react-native' | ||
import Animated, { useAnimatedProps } from 'react-native-reanimated' | ||
|
||
const styles = StyleSheet.create({ | ||
baseStyle: { | ||
color: 'black', | ||
}, | ||
}) | ||
Animated.addWhitelistedNativeProps({ text: true }) | ||
|
||
interface TextProps { | ||
text: Animated.SharedValue<string> | ||
style?: Animated.AnimateProps<RNTextProps>['style'] | ||
} | ||
|
||
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput) | ||
|
||
const ReText = (props: TextProps) => { | ||
const { text, style } = { style: {}, ...props } | ||
const animatedProps = useAnimatedProps(() => { | ||
return { | ||
text: text.value, | ||
// Here we use any because the text prop is not available in the type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} as any | ||
}) | ||
return ( | ||
<AnimatedTextInput | ||
underlineColorAndroid="transparent" | ||
editable={false} | ||
value={text.value} | ||
style={[styles.baseStyle, style]} | ||
{...{ animatedProps }} | ||
/> | ||
) | ||
} | ||
|
||
export default ReText |
This file contains 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
This file contains 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
This file contains 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