-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update useAnimatedKeyboard docs (#5866)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR updates the `useAnimatedKeyboard` docs to current doc pattern + add more detailed remarks discovered while doing #5851. It's pointing to #5851 and assumes changes from that PR, so **should be merged after**. ## Test plan ``` cd docs yarn yarn start ``` and go to useAnimatedKeyboard section <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. --> --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com> Co-authored-by: Kacper Kapuściak <39658211+kacperkapusciak@users.noreply.github.com>
- Loading branch information
1 parent
8a792b6
commit 637429d
Showing
6 changed files
with
149 additions
and
47 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
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,46 @@ | ||
import React from 'react'; | ||
import Animated, { | ||
useAnimatedKeyboard, | ||
useAnimatedStyle, | ||
} from 'react-native-reanimated'; | ||
import { StyleSheet, TextInput, View, useColorScheme } from 'react-native'; | ||
|
||
export default function App() { | ||
const colorScheme = useColorScheme(); | ||
const keyboard = useAnimatedKeyboard(); | ||
|
||
const animatedStyles = useAnimatedStyle(() => ({ | ||
transform: [{ translateY: -keyboard.height.value }], | ||
})); | ||
|
||
return ( | ||
<Animated.View | ||
style={[ | ||
styles.container, | ||
animatedStyles, | ||
{ backgroundColor: colorScheme === 'light' ? '#fff' : '#000' }, | ||
]}> | ||
<View style={styles.box}> | ||
<TextInput placeholder="Text Input" /> | ||
</View> | ||
</Animated.View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
borderWidth: 5, | ||
borderColor: '#782aeb', | ||
borderRadius: 2, | ||
}, | ||
box: { | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
height: 200, | ||
backgroundColor: '#b58df1', | ||
borderRadius: 5, | ||
margin: 20, | ||
}, | ||
}); |
Binary file not shown.
Binary file not shown.