-
-
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.
Add border radii to snapshots (#5988)
## Summary This PR adds the possibility to animate the border radius of all 4 corners separately with shared elements transitions. ## Test plan Check the behavior of `BorderRadiiExample` and also check for regressions in other SET/LA examples.
- Loading branch information
1 parent
0c962f9
commit 6cb1a66
Showing
7 changed files
with
231 additions
and
16 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
109 changes: 109 additions & 0 deletions
109
app/src/examples/SharedElementTransitions/BorderRadii.tsx
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,109 @@ | ||
import * as React from 'react'; | ||
import { View, Button, StyleSheet } from 'react-native'; | ||
import { ParamListBase } from '@react-navigation/native'; | ||
import { | ||
createNativeStackNavigator, | ||
NativeStackScreenProps, | ||
} from '@react-navigation/native-stack'; | ||
import Animated, { | ||
SharedTransition, | ||
SharedTransitionType, | ||
} from 'react-native-reanimated'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const photo = require('./assets/image.jpg'); | ||
|
||
const transition = SharedTransition.duration(1000).defaultTransitionType( | ||
SharedTransitionType.ANIMATION | ||
); | ||
|
||
function Screen1({ navigation }: NativeStackScreenProps<ParamListBase>) { | ||
return ( | ||
<View style={styles.flexOne}> | ||
<Button | ||
onPress={() => navigation.navigate('Screen2')} | ||
title="go to screen2" | ||
/> | ||
|
||
<Animated.View | ||
style={styles.greenBoxScreenOne} | ||
sharedTransitionTag="tag" | ||
sharedTransitionStyle={transition}> | ||
<Animated.Image | ||
style={styles.imageOne} | ||
sharedTransitionTag="image" | ||
sharedTransitionStyle={transition} | ||
source={photo} | ||
/> | ||
</Animated.View> | ||
</View> | ||
); | ||
} | ||
|
||
function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) { | ||
return ( | ||
<View style={styles.flexOne}> | ||
<Button title="go back" onPress={() => navigation.navigate('Screen1')} /> | ||
<Animated.View | ||
style={styles.greenBoxScreenTwo} | ||
sharedTransitionTag="tag" | ||
sharedTransitionStyle={transition}> | ||
<Animated.Image | ||
style={styles.imageTwo} | ||
sharedTransitionTag="image" | ||
sharedTransitionStyle={transition} | ||
source={photo} | ||
/> | ||
</Animated.View> | ||
</View> | ||
); | ||
} | ||
|
||
export default function CustomTransitionExample() { | ||
return ( | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="Screen1" | ||
component={Screen1} | ||
options={{ headerShown: false }} | ||
/> | ||
<Stack.Screen | ||
name="Screen2" | ||
component={Screen2} | ||
options={{ headerShown: false }} | ||
/> | ||
</Stack.Navigator> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
flexOne: { flex: 1, justifyContent: 'flex-end', alignItems: 'center' }, | ||
greenBoxScreenOne: { | ||
width: 300, | ||
height: 150, | ||
borderTopLeftRadius: 25, | ||
borderTopRightRadius: 25, | ||
backgroundColor: 'pink', | ||
}, | ||
greenBoxScreenTwo: { | ||
width: 350, | ||
height: 500, | ||
marginBottom: 100, | ||
borderRadius: 50, | ||
backgroundColor: 'pink', | ||
}, | ||
imageOne: { | ||
margin: 10, | ||
width: 280, | ||
height: 140, | ||
borderTopLeftRadius: 15, | ||
borderTopRightRadius: 15, | ||
}, | ||
imageTwo: { | ||
margin: 10, | ||
width: 330, | ||
height: 200, | ||
borderRadius: 40, | ||
}, | ||
}); |
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