Skip to content

Commit e901250

Browse files
committed
refactor: rename details screen
1 parent 697c4c1 commit e901250

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ import { useNavigation, useRoute } from '@react-navigation/native';
22
import { View, Text } from 'react-native';
33
import { 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
);

src/screens/home.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useNavigation, useRoute } from '@react-navigation/native';
2-
import { View, Text } from 'react-native';
2+
import { View, Text, StyleSheet } from 'react-native';
33
import { Button } from '@react-navigation/elements';
44

55
export 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+
});

0 commit comments

Comments
 (0)