-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stack_Navigation_with_button_and_text_input.tsx
71 lines (65 loc) · 1.75 KB
/
Stack_Navigation_with_button_and_text_input.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, {useEffect} from 'react';
import {useState} from 'react';
import {
Text, //First letter Capital
View,
Button,
StyleSheet,
TextInput,
FlatList,
ScrollView,
KeyboardAvoidingView,
} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {Home} from './components/Home';
import {Login} from './components/Login';
const stack = createNativeStackNavigator();
const App = () => {
const btnAction = () => {
console.warn('btn pressed');
};
return (
<NavigationContainer>
<stack.Navigator>
<stack.Screen
name="Login"
component={Login}
options={{
headerTitle: props => <Button onPress={btnAction} title="left" />,
headerRight: () => <Header />,
title: 'User Login',
headerStyle: {backgroundColor: 'skyblue'},
headerTintColor: 'white',
headerTitleStyle: {
fontSize: 30,
},
}}
/>
<stack.Screen name="Home" component={Home} />
</stack.Navigator>
</NavigationContainer>
);
};
const Header = () => {
return <TextInput placeholder="Enter Name Buddy" />;
};
const Home = () => {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 30}}>Home Screen</Text>
</View>
);
};
const Login = props => {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 30}}>Login Screen</Text>
<Button
title="Go to Home Screen"
onPress={() => props.navigation.navigate('Home')}
/>
</View>
);
};
export default App;