-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrap Screen with ScreenContext (#1539)
* fix: wrap screen with screen context * chore: add reproduction * chore: make tests self-contained
- Loading branch information
1 parent
7e4a348
commit 67d1fd1
Showing
9 changed files
with
132 additions
and
61 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,58 @@ | ||
import {NavigationContainer, useNavigation} from '@react-navigation/native'; | ||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||
import * as React from 'react'; | ||
import { | ||
ReanimatedScreenProvider, | ||
useReanimatedTransitionProgress, | ||
} from 'react-native-screens/reanimated'; | ||
import Reanimated, { | ||
useAnimatedStyle, | ||
useDerivedValue, | ||
} from 'react-native-reanimated'; | ||
import {Button} from 'react-native'; | ||
|
||
export default function App() { | ||
return ( | ||
<ReanimatedScreenProvider> | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen name="Root" component={RootScreen} /> | ||
<Stack.Screen name="Second" component={SecondScreen} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
</ReanimatedScreenProvider> | ||
); | ||
} | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
function RootScreen() { | ||
const {navigate} = useNavigation(); | ||
const reaProgress = useReanimatedTransitionProgress(); | ||
const sv = useDerivedValue( | ||
() => | ||
(reaProgress.progress.value < 0.5 | ||
? reaProgress.progress.value * 50 | ||
: (1 - reaProgress.progress.value) * 50) + 50, | ||
); | ||
const reaStyle = useAnimatedStyle(() => { | ||
return { | ||
width: sv.value, | ||
height: sv.value, | ||
backgroundColor: 'blue', | ||
}; | ||
}); | ||
|
||
return ( | ||
<> | ||
<Reanimated.View style={reaStyle} /> | ||
<Button | ||
title="Navigate to second screen" | ||
onPress={() => navigate('Second')} | ||
/> | ||
</> | ||
); | ||
} | ||
function SecondScreen() { | ||
return <></>; | ||
} |
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
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