Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stack 과 bottom tab 이용하여 페이지 이동 구현 #1 #6 #7

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { QueryClientProvider, QueryClient } from 'react-query';
import { NavigationContainer } from '@react-navigation/native';
import Root from './src/Navigations/Root';

const queryClient = new QueryClient();

export default function App() {
return (
<QueryClientProvider client={queryClient}>
{/* <Router>
</Router> */}
<NavigationContainer>
<Root />
</NavigationContainer>
</QueryClientProvider>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
20 changes: 20 additions & 0 deletions src/Navigations/Root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Stacks from './Stacks';
import Tabs from './Tabs';

const Stack = createNativeStackNavigator();

const Root = () => {
return (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="Stacks" component={Stacks} />
<Stack.Screen name="Tabs" component={Tabs} />
</Stack.Navigator>
);
};

export default Root;
Empty file removed src/Navigations/Stack.js
Empty file.
17 changes: 17 additions & 0 deletions src/Navigations/Stacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import { SignupPage, LoginPage, EditPage } from '../screen/Index';

const Stack = createNativeStackNavigator();

const Stacks = () => {
return (
<Stack.Navigator initialRouteName="로그인">
<Stack.Screen name="회원가입" component={SignupPage} />
<Stack.Screen name="로그인" component={LoginPage} />
<Stack.Screen name="수정 페이지" component={EditPage} />
</Stack.Navigator>
);
};

export default Stacks;
Empty file removed src/Navigations/Tab.js
Empty file.
44 changes: 44 additions & 0 deletions src/Navigations/Tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { MyPage, MainPage } from '../screen/Index';
import { Entypo } from '@expo/vector-icons';
import { FontAwesome } from '@expo/vector-icons';

const Tab = createBottomTabNavigator();

const Tabs = () => {
return (
<Tab.Navigator>
<Tab.Screen
options={{
headerTitleAlign: 'center',
tabBarShowLabel: false,
tabBarIcon: ({ focused }) =>
focused ? (
<Entypo name="home" size={25} color="black" />
) : (
<Entypo name="home" size={25} color="lightgrey" />
),
}}
name="메인 페이지"
component={MainPage}
/>

<Tab.Screen
options={{
headerTitleAlign: 'center',
tabBarShowLabel: false,
tabBarIcon: ({ focused }) =>
focused ? (
<FontAwesome name="list-ul" size={23} color="black" />
) : (
<FontAwesome name="list-ul" size={23} color="lightgrey" />
),
}}
name="마이 페이지"
component={MyPage}
/>
</Tab.Navigator>
);
};

export default Tabs;
15 changes: 15 additions & 0 deletions src/screen/EditPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { View, Text, TouchableOpacity } from 'react-native';

const EditPage = ({ navigation: { navigate } }) => {
return (
<View>
<TouchableOpacity
onPress={() => navigate('Tabs', { screen: '마이 페이지' })}
>
<Text>마이 페이지로</Text>
</TouchableOpacity>
</View>
);
};

export default EditPage;
7 changes: 7 additions & 0 deletions src/screen/Index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import SignupPage from './SignupPage';
import MyPage from './MyPage';
import MainPage from './MainPage';
import LoginPage from './LoginPage';
import EditPage from './EditPage';

export { SignupPage, MyPage, MainPage, LoginPage, EditPage };
18 changes: 18 additions & 0 deletions src/screen/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TouchableOpacity, View, Text } from 'react-native';

const LoginPage = ({ navigation: { navigate } }) => {
return (
<View>
<TouchableOpacity
onPress={() => navigate('Tabs', { screen: '메인 페이지' })}
>
<Text>로그인</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => navigate('회원가입')}>
<Text>회원가입</Text>
</TouchableOpacity>
</View>
);
};

export default LoginPage;
15 changes: 15 additions & 0 deletions src/screen/MainPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { View, Text, TouchableOpacity } from 'react-native';

const MainPage = ({ navigation: { navigate } }) => {
return (
<View>
<TouchableOpacity
onPress={() => navigate('Stacks', { screen: '로그인' })}
>
<Text>로그아웃</Text>
</TouchableOpacity>
</View>
);
Comment on lines +3 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그아웃 기능 제공하나요?

};

export default MainPage;
21 changes: 21 additions & 0 deletions src/screen/MyPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { View, Text, TouchableOpacity } from 'react-native';

const MyPage = ({ navigation: { navigate } }) => {
return (
<View>
<TouchableOpacity
onPress={() => navigate('Stacks', { screen: '수정 페이지' })}
>
<Text>수정 페이지로</Text>
</TouchableOpacity>

<TouchableOpacity
onPress={() => navigate('Stacks', { screen: '로그인' })}
>
<Text>로그아웃</Text>
</TouchableOpacity>
</View>
Comment on lines +4 to +17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삭제 부탁드립니다.

);
};

export default MyPage;
18 changes: 18 additions & 0 deletions src/screen/SignupPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { View, Text, TouchableOpacity } from 'react-native';

const SignupPage = ({ navigation: { navigate } }) => {
return (
<View>
<TouchableOpacity
onPress={() => navigate('Tabs', { screen: '메인 페이지' })}
>
<Text>회원가입</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => navigate('로그인')}>
<Text>로그인 페이지로</Text>
</TouchableOpacity>
</View>
);
};

export default SignupPage;