App.js 2.53 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import * as React from 'react';
YoonDongMin's avatar
YoonDongMin committed
2
import { StyleSheet, View, Text, TextInput, Button, Keyboard, TouchableWithoutFeedback } from 'react-native';
Choi Ga Young's avatar
Choi Ga Young committed
3
4
5
6
7
8
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Monthly from './Monthly';
import Analy from './Analy';
import MoneyDB from './MoneyDB';
Test User's avatar
Test User committed
9

YoonDongMin's avatar
YoonDongMin committed
10
11
12
13
14
15
16
17
18

const DismissKeyboard = ({ children }) => (
  <TouchableWithoutFeedback onPress={() => Keyboard.dismiss()} >
    {children}
  </TouchableWithoutFeedback>

);


Choi Ga Young's avatar
Choi Ga Young committed
19
20
21
22
23
24
25
26
27
function MainScreen({ navigation }) {
  const [number, onChangeNumber] = React.useState(null);
  return (
    <>
      <View>
        <Text style={style.Font}>여기는 메인 페이지 입니다.</Text>
        <Text style={style.Font}>아래는 input 테스트를 위한 것입니다.</Text>
        <TextInput
          style={style.TextInput}
YoonDongMin's avatar
YoonDongMin committed
28
          onChangeText={onChangeNumber}
Choi Ga Young's avatar
Choi Ga Young committed
29
30
31
32
33
34
35
          keyboardType="numeric"
        />
        <Text>입력한 숫자 보기: {number} </Text>
      </View>
      <Button
        title="월별 페이지로 이동"
        onPress={() => navigation.navigate('Monthly')}
YoonDongMin's avatar
YoonDongMin committed
36
      />
Choi Ga Young's avatar
Choi Ga Young committed
37
      <MoneyDB />
YoonDongMin's avatar
YoonDongMin committed
38
    </>
Choi Ga Young's avatar
Choi Ga Young committed
39
40
  )
}
Test User's avatar
Test User committed
41

YoonDongMin's avatar
YoonDongMin committed
42
43


Choi Ga Young's avatar
Choi Ga Young committed
44
const Tab = createBottomTabNavigator();
Test User's avatar
Test User committed
45

Choi Ga Young's avatar
Choi Ga Young committed
46
function App() {
Test User's avatar
Test User committed
47
  return (
YoonDongMin's avatar
YoonDongMin committed
48
49
50
    <DismissKeyboard>
      <NavigationContainer>
        <Tab.Navigator screenOptions={({ route }) => ({
Choi Ga Young's avatar
Choi Ga Young committed
51
52
          tabBarIcon: ({ focused, color, size }) => {
            let iconName;
Test User's avatar
Test User committed
53

Choi Ga Young's avatar
Choi Ga Young committed
54
            if (route.name === 'Main') {
YoonDongMin's avatar
YoonDongMin committed
55
              iconName = focused ? 'home' : 'home-outline';
Choi Ga Young's avatar
Choi Ga Young committed
56
57
58
            } else if (route.name === 'Monthly') {
              iconName = focused ? 'calendar' : 'calendar-outline';
            } else if (route.name === 'Analy') {
YoonDongMin's avatar
YoonDongMin committed
59
              iconName = focused ? 'bar-chart' : 'bar-chart-outline';
Choi Ga Young's avatar
Choi Ga Young committed
60
61
62
63
64
            }
            // You can return any component that you like here!
            return <Ionicons name={iconName} size={size} color={color} />;
          },
        })}
YoonDongMin's avatar
YoonDongMin committed
65
66
67
68
69
70
71
72
73
74
          tabBarOptions={{
            activeTintColor: 'tomato',
            inactiveTintColor: 'gray',
          }}>
          <Tab.Screen name="Main" component={MainScreen} />
          <Tab.Screen name="Monthly" component={Monthly} />
          <Tab.Screen name="Analy" component={Analy} />
        </Tab.Navigator>
      </NavigationContainer>
    </DismissKeyboard>
Test User's avatar
Test User committed
75
  );
Choi Ga Young's avatar
Choi Ga Young committed
76
}
Test User's avatar
Test User committed
77

Choi Ga Young's avatar
Choi Ga Young committed
78
79
80
81
82
83
const style = StyleSheet.create({
  TextInput: {
    borderColor: 'skyblue',
    height: 40,
    margin: 12,
    borderWidth: 1
Test User's avatar
Test User committed
84
  },
Choi Ga Young's avatar
Choi Ga Young committed
85
86
87
  Font: {
    fontSize: 24
  }
Test User's avatar
Test User committed
88
89
});
export default App;