File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,22 +2,19 @@ import { useNavigation, useRoute } from '@react-navigation/native';
22import { View , Text } from 'react-native' ;
33import { Button } from '@react-navigation/elements' ;
44
5- export type DetailsScreenProps = {
5+ export type AboutScreenProps = {
66 depth : number ;
77} ;
88
9- export function DetailsScreen ( ) {
9+ export function AboutScreen ( ) {
1010 const navigation = useNavigation ( ) ;
1111 const route = useRoute ( ) ;
1212
13- const { depth } = route . params as DetailsScreenProps ;
13+ const { depth } = route . params as AboutScreenProps ;
1414
1515 return (
1616 < View style = { { flex : 1 , alignItems : 'center' , justifyContent : 'center' } } >
1717 < Text > You are currently { depth } screens deep</ Text >
18- < Button onPress = { ( ) => navigation . setParams ( { depth : ( depth + 1 ) } ) } > Increment Depth</ Button >
19- < Button onPress = { ( ) => navigation . push ( 'Details' , { depth : ( depth + 1 ) } ) } > Go Deeper</ Button >
20- < Button onPress = { ( ) => navigation . goBack ( 'Details' ) } > Go Back</ Button >
2118 < Button onPress = { ( ) => navigation . popTo ( 'Home' ) } > Go Home</ Button >
2219 </ View >
2320 ) ;
Original file line number Diff line number Diff line change 11import { useNavigation , useRoute } from '@react-navigation/native' ;
2- import { View , Text } from 'react-native' ;
2+ import { View , Text , StyleSheet } from 'react-native' ;
33import { Button } from '@react-navigation/elements' ;
44
55export type HomeScreenProps = {
@@ -13,9 +13,21 @@ export function HomeScreen() {
1313 const { message } = route . params as HomeScreenProps ;
1414
1515 return (
16- < View style = { { flex : 1 , alignItems : 'center' , justifyContent : 'center' } } >
16+ < View style = { styles . container } >
1717 < Text > { message } </ Text >
18- < Button onPress = { ( ) => navigation . push ( 'Details ' ) } > Go to Details</ Button >
18+ < Button style = { styles . bottom } onPress = { ( ) => navigation . push ( 'About ' ) } > Go to Details</ Button >
1919 </ View >
2020 ) ;
21- }
21+ }
22+
23+ const styles = StyleSheet . create ( {
24+ container : {
25+ flex : 1 ,
26+ flexDirection : 'row' ,
27+ alignItems : 'center' ,
28+ justifyContent : 'center' ,
29+ } ,
30+ bottom : {
31+ alignSelf : 'flex-end' ,
32+ }
33+ } ) ;
You can’t perform that action at this time.
0 commit comments